> As promised, here is a patch that converts ehca to use
 > ib_copy_to_udata() in the create_qp method in exactly the same way it
 > is used in the create_cq method.

 > Please test and commit if it looks OK.  (I have an eHCA test machine
 > that I'll get set up soon so I can test myself, I promise).

Err... here's a patch that at least compiles....

As a bonus it deletes even more code:

 linux-kernel/infiniband/hw/ehca/ehca_classes.h |   10 +---------
 linux-kernel/infiniband/hw/ehca/ehca_cq.c      |    8 --------
 linux-kernel/infiniband/hw/ehca/ehca_qp.c      |   15 ++-------------
 userspace/libehca/src/ehca_uclasses.h          |   13 ++-----------
 userspace/libehca/src/ehca_umain.c             |   23 ++++++++++-------------
 5 files changed, 15 insertions(+), 54 deletions(-)

sorry for the screw-up with the previous patch.

 - Roland

Signed-off-by: Roland Dreier <[EMAIL PROTECTED]>

--- userspace/libehca/src/ehca_uclasses.h       (revision 5421)
+++ userspace/libehca/src/ehca_uclasses.h       (working copy)
@@ -142,13 +142,8 @@ int ehcau_attach_mcast(struct ibv_qp *qp
 int ehcau_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
 
 /**
- * cmd and resp structs to pass to kernel space
+ * resp structs from kernel space
  */
-struct ehcau_create_cq {
-       struct ibv_create_cq ibv_cmd;
-       u64 respbuf;
-};
-
 struct ehcau_create_cq_resp {
        struct ibv_create_cq_resp ibv_resp;
        u32 cq_number;
@@ -156,12 +151,8 @@ struct ehcau_create_cq_resp {
        struct ehca_cq_core ehca_cq_core;
 };
 
-struct ehcau_create_qp {
-       struct ibv_create_qp ibv_cmd;
-       u64 respbuf;
-};
-
 struct ehcau_create_qp_resp {
+       struct ibv_create_qp_resp ibv_resp;
        u32 qp_num;
        u32 token;
        struct ehca_qp_core ehca_qp_core;
--- userspace/libehca/src/ehca_umain.c  (revision 5424)
+++ userspace/libehca/src/ehca_umain.c  (working copy)
@@ -200,7 +200,7 @@ int ehcau_dealloc_pd(struct ibv_pd *pd)
 struct ibv_cq *ehcau_create_cq(struct ibv_context *context, int cqe, 
                               struct ibv_comp_channel *channel, int 
comp_vector)
 {
-       struct ehcau_create_cq cmd;
+       struct ibv_create_cq cmd;
        struct ehcau_create_cq_resp resp;
        struct ehcau_cq *my_cq = NULL;
        int ret = 0;
@@ -220,9 +220,9 @@ struct ibv_cq *ehcau_create_cq(struct ib
                         "context=%p cqe=%x", context, cqe);
                goto create_cq_exit0;
        }
-       cmd.respbuf = (uintptr_t) & resp;
+
        ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector, 
&my_cq->ib_cq,
-                               &cmd.ibv_cmd, sizeof(cmd),
+                               &cmd, sizeof(cmd),
                                &resp.ibv_resp, sizeof(resp));
        if (ret) {
                EDEB_ERR(4, "ibv_cmd_create_cq() failed "
@@ -282,9 +282,8 @@ struct ibv_qp *ehcau_create_qp(struct ib
 {
        int ret = 0;
        struct ehcau_qp *my_qp = NULL;
-       struct ehcau_create_qp cmd;
-       struct ehcau_create_qp_resp ehca_resp;
-       struct ibv_create_qp_resp resp;
+       struct ibv_create_qp cmd;
+       struct ehcau_create_qp_resp resp;
        struct ibv_context *context = NULL;
        int ret2 = 0;
 
@@ -301,8 +300,6 @@ struct ibv_qp *ehcau_create_qp(struct ib
 
        memset(my_qp, 0, sizeof(*my_qp));
        memset(&cmd, 0, sizeof(cmd));
-       memset(&ehca_resp, 0, sizeof(ehca_resp));
-       cmd.respbuf = (uintptr_t) &ehca_resp;   /* TODO: better include resp in 
ibv_cmd_create_qp call */
 
        if (pthread_spin_init(&my_qp->spinlock_s, PTHREAD_PROCESS_PRIVATE) ||
            pthread_spin_init(&my_qp->spinlock_r, PTHREAD_PROCESS_PRIVATE)) {
@@ -310,8 +307,8 @@ struct ibv_qp *ehcau_create_qp(struct ib
        }
 
        ret = ibv_cmd_create_qp(pd, &my_qp->ib_qp, attr,
-                               &cmd.ibv_cmd, sizeof(cmd),
-                               &resp, sizeof resp);
+                               &cmd, sizeof(cmd),
+                               &resp.ibv_resp, sizeof resp);
 
        if (ret != 0) {
                EDEB_ERR(4, "ibv_cmd_create_qp() failed ret=%x pd=%p", 
@@ -319,9 +316,9 @@ struct ibv_qp *ehcau_create_qp(struct ib
                goto create_qp_exit0;
        }
        /* copy data returned from kernel */
-       my_qp->qp_num = ehca_resp.qp_num;
-       my_qp->token = ehca_resp.token;
-       my_qp->ehca_qp_core = ehca_resp.ehca_qp_core;
+       my_qp->qp_num = resp.qp_num;
+       my_qp->token = resp.token;
+       my_qp->ehca_qp_core = resp.ehca_qp_core;
        my_qp->ehca_qp_core.ipz_rqueue.current_q_addr =
            my_qp->ehca_qp_core.ipz_rqueue.queue;
        my_qp->ehca_qp_core.ipz_squeue.current_q_addr =
--- linux-kernel/infiniband/hw/ehca/ehca_classes.h      (revision 5421)
+++ linux-kernel/infiniband/hw/ehca/ehca_classes.h      (working copy)
@@ -345,22 +345,14 @@ extern struct idr ehca_qp_idr;
 extern struct idr ehca_cq_idr;
 
 /*
- * cmd and resp structs for comm bw user and kernel space
+ * resp structs for comm bw user and kernel space
  */
-struct ehca_create_cq {
-       u64 respbuf;
-};
-
 struct ehca_create_cq_resp {
        u32 cq_number;
        u32 token;
        struct ehca_cq_core ehca_cq_core;
 };
 
-struct ehca_create_qp {
-       u64 respbuf;
-};
-
 struct ehca_create_qp_resp {
        u32 qp_num;
        u32 token;
--- linux-kernel/infiniband/hw/ehca/ehca_cq.c   (revision 5421)
+++ linux-kernel/infiniband/hw/ehca/ehca_cq.c   (working copy)
@@ -132,7 +132,6 @@ struct ib_cq *ehca_create_cq(struct ib_d
        u64 hipz_rc = H_Success;
        int ipz_rc = 0;
        int ret = 0;
-       struct ehca_create_cq ucmd;
        const u32 additional_cqe=20;
        int i= 0;
 
@@ -147,13 +146,6 @@ struct ib_cq *ehca_create_cq(struct ib_d
        }
        number_of_entries += additional_cqe;
 
-       if (context) {
-               if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
-                       EDEB_ERR(4,  "Copy from udata failed.");
-                       return ERR_PTR(-EFAULT);
-               }
-       }
-
        my_cq = ehca_cq_new();
        if (my_cq == NULL) {
                cq = ERR_PTR(-ENOMEM);
--- linux-kernel/infiniband/hw/ehca/ehca_qp.c   (revision 5421)
+++ linux-kernel/infiniband/hw/ehca/ehca_qp.c   (working copy)
@@ -404,7 +404,6 @@ struct ib_qp *ehca_create_qp(struct ib_p
        struct ehca_cq *recv_ehca_cq = NULL;
        struct ehca_cq *send_ehca_cq = NULL;
        struct ib_ucontext *context = NULL;
-       struct ehca_create_qp ucmd;
        u64 hipz_rc = H_Parameter;
        int max_send_sge;
        int max_recv_sge;
@@ -449,13 +448,6 @@ struct ib_qp *ehca_create_qp(struct ib_p
        if (pd->uobject && udata != NULL) {
                context = pd->uobject->context;
        }
-       if (context != NULL) {
-               if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
-                       EDEB_ERR(4, "copy_from_user() failed udata=%p ",
-                                udata);
-                       return ERR_PTR(-EFAULT);
-               }
-       }
 
        my_qp = ehca_qp_new();
        if (!my_qp) {
@@ -670,11 +662,8 @@ struct ib_qp *ehca_create_qp(struct ib_p
                                   &vma);
                my_qp->uspace_fwh = 
(u64)resp.ehca_qp_core.galpas.kernel.fw_handle;
 
-
-               if (copy_to_user
-                   ((u64 __user *) (unsigned long)ucmd.respbuf, &resp,
-                    sizeof(resp))) {
-                       EDEB_ERR(4, "copy_to_user() failed");
+               if (ib_copy_to_udata(udata, &resp, sizeof resp)) {
+                       EDEB_ERR(4, "Copy to udata failed");
                        ret = -EINVAL;
                        goto create_qp_exit3;
                }
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to