[PATCH rdma-next v2 7/9] RDMA/uverbs: Use uverbs_attr_bundle to pass udata for write_ex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>

The core code needs to compute the udata so we may as well pass it in the
uverbs_attr_bundle instead of on the stack. This converts the simple case
of write_ex() which already has a core calculation.

Also change the write() path to use the attrs for ib_uverbs_init_udata()
instead of on the stack. This lets the write to write_ex compatibility
path continue to follow the lead of the _ex path.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/rdma_core.h   |   2 +-
 drivers/infiniband/core/uverbs_cmd.c  | 153 +++++++++++---------------
 drivers/infiniband/core/uverbs_main.c |   5 +-
 drivers/infiniband/core/uverbs_uapi.c |   2 +-
 include/rdma/uverbs_ioctl.h           |   4 +-
 5 files changed, 73 insertions(+), 93 deletions(-)

diff --git a/drivers/infiniband/core/rdma_core.h b/drivers/infiniband/core/rdma_core.h
index df4cc0d18d26..b11396536d8e 100644
--- a/drivers/infiniband/core/rdma_core.h
+++ b/drivers/infiniband/core/rdma_core.h
@@ -139,7 +139,7 @@ struct uverbs_api_write_method {
 	int (*handler)(struct uverbs_attr_bundle *attrs, const char __user *buf,
 		       int in_len, int out_len);
 	int (*handler_ex)(struct uverbs_attr_bundle *attrs,
-			  struct ib_udata *ucore, struct ib_udata *uhw);
+			  struct ib_udata *ucore);
 	u8 disabled:1;
 	u8 is_ex:1;
 	u8 has_udata:1;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 894f0f79423a..3ee827047cb1 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -72,7 +72,6 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
 	struct ib_uverbs_file *file = attrs->ufile;
 	struct ib_uverbs_get_context      cmd;
 	struct ib_uverbs_get_context_resp resp;
-	struct ib_udata                   udata;
 	struct ib_ucontext		 *ucontext;
 	struct file			 *filp;
 	struct ib_rdmacg_object		 cg_obj;
@@ -98,7 +97,7 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
 		goto err;
 	}
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
@@ -107,7 +106,7 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
 	if (ret)
 		goto err;
 
-	ucontext = ib_dev->alloc_ucontext(ib_dev, &udata);
+	ucontext = ib_dev->alloc_ucontext(ib_dev, &attrs->driver_udata);
 	if (IS_ERR(ucontext)) {
 		ret = PTR_ERR(ucontext);
 		goto err_alloc;
@@ -342,7 +341,6 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_alloc_pd      cmd;
 	struct ib_uverbs_alloc_pd_resp resp;
-	struct ib_udata                udata;
 	struct ib_uobject             *uobj;
 	struct ib_pd                  *pd;
 	int                            ret;
@@ -354,7 +352,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
                    in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
                    out_len - sizeof(resp));
@@ -363,7 +361,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
 	if (IS_ERR(uobj))
 		return PTR_ERR(uobj);
 
-	pd = ib_dev->alloc_pd(ib_dev, uobj->context, &udata);
+	pd = ib_dev->alloc_pd(ib_dev, uobj->context, &attrs->driver_udata);
 	if (IS_ERR(pd)) {
 		ret = PTR_ERR(pd);
 		goto err;
@@ -497,7 +495,6 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
 	struct ib_uverbs_device *ibudev = attrs->ufile->device;
 	struct ib_uverbs_open_xrcd	cmd;
 	struct ib_uverbs_open_xrcd_resp	resp;
-	struct ib_udata			udata;
 	struct ib_uxrcd_object         *obj;
 	struct ib_xrcd                 *xrcd = NULL;
 	struct fd			f = {NULL, 0};
@@ -512,7 +509,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
                    in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
                    out_len - sizeof(resp));
@@ -549,7 +546,8 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
 	}
 
 	if (!xrcd) {
-		xrcd = ib_dev->alloc_xrcd(ib_dev, obj->uobject.context, &udata);
+		xrcd = ib_dev->alloc_xrcd(ib_dev, obj->uobject.context,
+					  &attrs->driver_udata);
 		if (IS_ERR(xrcd)) {
 			ret = PTR_ERR(xrcd);
 			goto err;
@@ -653,7 +651,6 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_reg_mr      cmd;
 	struct ib_uverbs_reg_mr_resp resp;
-	struct ib_udata              udata;
 	struct ib_uobject           *uobj;
 	struct ib_pd                *pd;
 	struct ib_mr                *mr;
@@ -666,7 +663,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
                    in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
                    out_len - sizeof(resp));
@@ -698,7 +695,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
 	}
 
 	mr = pd->device->reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
-				     cmd.access_flags, &udata);
+				     cmd.access_flags, &attrs->driver_udata);
 	if (IS_ERR(mr)) {
 		ret = PTR_ERR(mr);
 		goto err_put;
@@ -744,7 +741,6 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_rereg_mr      cmd;
 	struct ib_uverbs_rereg_mr_resp resp;
-	struct ib_udata              udata;
 	struct ib_pd                *pd = NULL;
 	struct ib_mr                *mr;
 	struct ib_pd		    *old_pd;
@@ -757,7 +753,7 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof(cmd)))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
                    in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
                    out_len - sizeof(resp));
@@ -797,9 +793,9 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
 	}
 
 	old_pd = mr->pd;
-	ret = mr->device->rereg_user_mr(mr, cmd.flags, cmd.start,
-					cmd.length, cmd.hca_va,
-					cmd.access_flags, pd, &udata);
+	ret = mr->device->rereg_user_mr(mr, cmd.flags, cmd.start, cmd.length,
+					cmd.hca_va, cmd.access_flags, pd,
+					&attrs->driver_udata);
 	if (!ret) {
 		if (cmd.flags & IB_MR_REREG_PD) {
 			atomic_inc(&pd->usecnt);
@@ -848,7 +844,6 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
 	struct ib_uobject             *uobj;
 	struct ib_pd                  *pd;
 	struct ib_mw                  *mw;
-	struct ib_udata		       udata;
 	int                            ret;
 	struct ib_device *ib_dev;
 
@@ -868,12 +863,12 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
 		goto err_free;
 	}
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
 
-	mw = pd->device->alloc_mw(pd, cmd.mw_type, &udata);
+	mw = pd->device->alloc_mw(pd, cmd.mw_type, &attrs->driver_udata);
 	if (IS_ERR(mw)) {
 		ret = PTR_ERR(mw);
 		goto err_put;
@@ -954,13 +949,12 @@ static int ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs,
 
 static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
 				       struct ib_udata *ucore,
-				       struct ib_udata *uhw,
 				       struct ib_uverbs_ex_create_cq *cmd,
 				       size_t cmd_sz,
 				       int (*cb)(struct uverbs_attr_bundle *attrs,
 						 struct ib_ucq_object *obj,
 						 struct ib_uverbs_ex_create_cq_resp *resp,
-						 struct ib_udata *udata,
+						 struct ib_udata *ucore,
 						 void *context),
 				       void *context)
 {
@@ -1000,7 +994,8 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
 	if (cmd_sz > offsetof(typeof(*cmd), flags) + sizeof(cmd->flags))
 		attr.flags = cmd->flags;
 
-	cq = ib_dev->create_cq(ib_dev, &attr, obj->uobject.context, uhw);
+	cq = ib_dev->create_cq(ib_dev, &attr, obj->uobject.context,
+			       &attrs->driver_udata);
 	if (IS_ERR(cq)) {
 		ret = PTR_ERR(cq);
 		goto err_file;
@@ -1064,7 +1059,6 @@ static int ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
 	struct ib_uverbs_ex_create_cq	cmd_ex;
 	struct ib_uverbs_create_cq_resp resp;
 	struct ib_udata                 ucore;
-	struct ib_udata                 uhw;
 	struct ib_ucq_object           *obj;
 
 	if (out_len < sizeof(resp))
@@ -1076,7 +1070,7 @@ static int ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
 	ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response),
 			     sizeof(cmd), sizeof(resp));
 
-	ib_uverbs_init_udata(&uhw, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
@@ -1087,10 +1081,10 @@ static int ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
 	cmd_ex.comp_vector = cmd.comp_vector;
 	cmd_ex.comp_channel = cmd.comp_channel;
 
-	obj = create_cq(attrs, &ucore, &uhw, &cmd_ex,
+	obj = create_cq(attrs, &ucore, &cmd_ex,
 			offsetof(typeof(cmd_ex), comp_channel) +
-			sizeof(cmd.comp_channel), ib_uverbs_create_cq_cb,
-			NULL);
+				sizeof(cmd.comp_channel),
+			ib_uverbs_create_cq_cb, NULL);
 
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
@@ -1110,7 +1104,7 @@ static int ib_uverbs_ex_create_cq_cb(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_create_cq(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_create_cq_resp resp;
 	struct ib_uverbs_ex_create_cq  cmd;
@@ -1134,8 +1128,7 @@ static int ib_uverbs_ex_create_cq(struct uverbs_attr_bundle *attrs,
 			     sizeof(resp.response_length)))
 		return -ENOSPC;
 
-	obj = create_cq(attrs, ucore, uhw, &cmd,
-			min(ucore->inlen, sizeof(cmd)),
+	obj = create_cq(attrs, ucore, &cmd, min(ucore->inlen, sizeof(cmd)),
 			ib_uverbs_ex_create_cq_cb, NULL);
 
 	return PTR_ERR_OR_ZERO(obj);
@@ -1146,14 +1139,13 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_resize_cq	cmd;
 	struct ib_uverbs_resize_cq_resp	resp = {};
-	struct ib_udata                 udata;
 	struct ib_cq			*cq;
 	int				ret = -EINVAL;
 
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
@@ -1162,7 +1154,7 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs,
 	if (!cq)
 		return -EINVAL;
 
-	ret = cq->device->resize_cq(cq, cmd.cqe, &udata);
+	ret = cq->device->resize_cq(cq, cmd.cqe, &attrs->driver_udata);
 	if (ret)
 		goto out;
 
@@ -1309,7 +1301,6 @@ static int ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs,
 
 static int create_qp(struct uverbs_attr_bundle *attrs,
 		     struct ib_udata *ucore,
-		     struct ib_udata *uhw,
 		     struct ib_uverbs_ex_create_qp *cmd,
 		     size_t cmd_sz,
 		     int (*cb)(struct uverbs_attr_bundle *attrs,
@@ -1487,7 +1478,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
 	if (cmd->qp_type == IB_QPT_XRC_TGT)
 		qp = ib_create_qp(pd, &attr);
 	else
-		qp = _ib_create_qp(device, pd, &attr, uhw,
+		qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata,
 				   &obj->uevent.uobject);
 
 	if (IS_ERR(qp)) {
@@ -1599,7 +1590,6 @@ static int ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
 	struct ib_uverbs_create_qp      cmd;
 	struct ib_uverbs_ex_create_qp	cmd_ex;
 	struct ib_udata			ucore;
-	struct ib_udata			uhw;
 	ssize_t resp_size = sizeof(struct ib_uverbs_create_qp_resp);
 	int				err;
 
@@ -1611,7 +1601,7 @@ static int ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
 
 	ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response),
 		   sizeof(cmd), resp_size);
-	ib_uverbs_init_udata(&uhw, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + resp_size,
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - resp_size);
@@ -1631,10 +1621,9 @@ static int ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
 	cmd_ex.qp_type = cmd.qp_type;
 	cmd_ex.is_srq = cmd.is_srq;
 
-	err = create_qp(attrs, &ucore, &uhw, &cmd_ex,
-			offsetof(typeof(cmd_ex), is_srq) +
-			sizeof(cmd.is_srq), ib_uverbs_create_qp_cb,
-			NULL);
+	err = create_qp(attrs, &ucore, &cmd_ex,
+			offsetof(typeof(cmd_ex), is_srq) + sizeof(cmd.is_srq),
+			ib_uverbs_create_qp_cb, NULL);
 
 	if (err)
 		return err;
@@ -1653,7 +1642,7 @@ static int ib_uverbs_ex_create_qp_cb(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_create_qp(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_create_qp_resp resp;
 	struct ib_uverbs_ex_create_qp cmd = {0};
@@ -1677,7 +1666,7 @@ static int ib_uverbs_ex_create_qp(struct uverbs_attr_bundle *attrs,
 			     sizeof(resp.response_length)))
 		return -ENOSPC;
 
-	err = create_qp(attrs, ucore, uhw, &cmd,
+	err = create_qp(attrs, ucore, &cmd,
 			min(ucore->inlen, sizeof(cmd)),
 			ib_uverbs_ex_create_qp_cb, NULL);
 
@@ -1692,7 +1681,6 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_open_qp        cmd;
 	struct ib_uverbs_create_qp_resp resp;
-	struct ib_udata                 udata;
 	struct ib_uqp_object           *obj;
 	struct ib_xrcd		       *xrcd;
 	struct ib_uobject	       *uninitialized_var(xrcd_uobj);
@@ -1707,7 +1695,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
@@ -1909,7 +1897,7 @@ static void copy_ah_attr_from_uverbs(struct ib_device *dev,
 }
 
 static int modify_qp(struct uverbs_attr_bundle *attrs,
-		     struct ib_uverbs_ex_modify_qp *cmd, struct ib_udata *udata)
+		     struct ib_uverbs_ex_modify_qp *cmd)
 {
 	struct ib_qp_attr *attr;
 	struct ib_qp *qp;
@@ -2057,7 +2045,7 @@ static int modify_qp(struct uverbs_attr_bundle *attrs,
 	ret = ib_modify_qp_with_udata(qp, attr,
 				      modify_qp_mask(qp->qp_type,
 						     cmd->base.attr_mask),
-				      udata);
+				      &attrs->driver_udata);
 
 release_qp:
 	uobj_put_obj_read(qp);
@@ -2071,7 +2059,6 @@ static int ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs,
 			       const char __user *buf, int in_len, int out_len)
 {
 	struct ib_uverbs_ex_modify_qp cmd = {};
-	struct ib_udata udata;
 
 	if (copy_from_user(&cmd.base, buf, sizeof(cmd.base)))
 		return -EFAULT;
@@ -2080,15 +2067,15 @@ static int ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs,
 	    ~((IB_USER_LEGACY_LAST_QP_ATTR_MASK << 1) - 1))
 		return -EOPNOTSUPP;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd.base), NULL,
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd.base), NULL,
 		   in_len - sizeof(cmd.base) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len);
 
-	return modify_qp(attrs, &cmd, &udata);
+	return modify_qp(attrs, &cmd);
 }
 
 static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_modify_qp cmd = {};
 	int ret;
@@ -2116,7 +2103,7 @@ static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs,
 			return -EOPNOTSUPP;
 	}
 
-	ret = modify_qp(attrs, &cmd, uhw);
+	ret = modify_qp(attrs, &cmd);
 
 	return ret;
 }
@@ -2544,7 +2531,6 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
 	struct ib_ah			*ah;
 	struct rdma_ah_attr		attr = {};
 	int ret;
-	struct ib_udata                   udata;
 	struct ib_device *ib_dev;
 
 	if (out_len < sizeof resp)
@@ -2553,7 +2539,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
@@ -2591,7 +2577,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
 		rdma_ah_set_ah_flags(&attr, 0);
 	}
 
-	ah = rdma_create_user_ah(pd, &attr, &udata);
+	ah = rdma_create_user_ah(pd, &attr, &attrs->driver_udata);
 	if (IS_ERR(ah)) {
 		ret = PTR_ERR(ah);
 		goto err_put;
@@ -3045,7 +3031,7 @@ static int kern_spec_to_ib_spec(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_create_wq	  cmd = {};
 	struct ib_uverbs_ex_create_wq_resp resp = {};
@@ -3109,7 +3095,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs,
 	obj->uevent.events_reported = 0;
 	INIT_LIST_HEAD(&obj->uevent.event_list);
 
-	wq = pd->device->create_wq(pd, &wq_init_attr, uhw);
+	wq = pd->device->create_wq(pd, &wq_init_attr, &attrs->driver_udata);
 	if (IS_ERR(wq)) {
 		err = PTR_ERR(wq);
 		goto err_put_cq;
@@ -3156,7 +3142,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_destroy_wq(struct uverbs_attr_bundle *attrs,
-				   struct ib_udata *ucore, struct ib_udata *uhw)
+				   struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_destroy_wq	cmd = {};
 	struct ib_uverbs_ex_destroy_wq_resp	resp = {};
@@ -3201,7 +3187,7 @@ static int ib_uverbs_ex_destroy_wq(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_modify_wq cmd = {};
 	struct ib_wq *wq;
@@ -3238,14 +3224,14 @@ static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs,
 		wq_attr.flags = cmd.flags;
 		wq_attr.flags_mask = cmd.flags_mask;
 	}
-	ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask, uhw);
+	ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask,
+				    &attrs->driver_udata);
 	uobj_put_obj_read(wq);
 	return ret;
 }
 
 static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs,
-					     struct ib_udata *ucore,
-					     struct ib_udata *uhw)
+					     struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_create_rwq_ind_table	  cmd = {};
 	struct ib_uverbs_ex_create_rwq_ind_table_resp  resp = {};
@@ -3336,7 +3322,8 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs,
 	init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size;
 	init_attr.ind_tbl = wqs;
 
-	rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr, uhw);
+	rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr,
+						   &attrs->driver_udata);
 
 	if (IS_ERR(rwq_ind_tbl)) {
 		err = PTR_ERR(rwq_ind_tbl);
@@ -3383,8 +3370,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_destroy_rwq_ind_table(struct uverbs_attr_bundle *attrs,
-					      struct ib_udata *ucore,
-					      struct ib_udata *uhw)
+					      struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_destroy_rwq_ind_table	cmd = {};
 	int			ret;
@@ -3412,8 +3398,7 @@ static int ib_uverbs_ex_destroy_rwq_ind_table(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
-				    struct ib_udata *ucore,
-				    struct ib_udata *uhw)
+				    struct ib_udata *ucore)
 {
 	struct ib_uverbs_create_flow	  cmd;
 	struct ib_uverbs_create_flow_resp resp;
@@ -3544,8 +3529,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
 		goto err_free;
 	}
 
-	flow_id = qp->device->create_flow(qp, flow_attr,
-					  IB_FLOW_DOMAIN_USER, uhw);
+	flow_id = qp->device->create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER,
+					  &attrs->driver_udata);
 
 	if (IS_ERR(flow_id)) {
 		err = PTR_ERR(flow_id);
@@ -3585,8 +3570,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_destroy_flow(struct uverbs_attr_bundle *attrs,
-				     struct ib_udata *ucore,
-				     struct ib_udata *uhw)
+				     struct ib_udata *ucore)
 {
 	struct ib_uverbs_destroy_flow	cmd;
 	int				ret;
@@ -3746,7 +3730,6 @@ static int ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs,
 	struct ib_uverbs_create_srq      cmd;
 	struct ib_uverbs_create_xsrq     xcmd;
 	struct ib_uverbs_create_srq_resp resp;
-	struct ib_udata                  udata;
 
 	if (out_len < sizeof resp)
 		return -ENOSPC;
@@ -3763,12 +3746,12 @@ static int ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs,
 	xcmd.max_sge	 = cmd.max_sge;
 	xcmd.srq_limit	 = cmd.srq_limit;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
 
-	return __uverbs_create_xsrq(attrs, &xcmd, &udata);
+	return __uverbs_create_xsrq(attrs, &xcmd, &attrs->driver_udata);
 }
 
 static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
@@ -3777,7 +3760,6 @@ static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
 {
 	struct ib_uverbs_create_xsrq     cmd;
 	struct ib_uverbs_create_srq_resp resp;
-	struct ib_udata                  udata;
 
 	if (out_len < sizeof resp)
 		return -ENOSPC;
@@ -3785,19 +3767,18 @@ static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof(cmd),
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof(cmd),
 		   u64_to_user_ptr(cmd.response) + sizeof(resp),
 		   in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
 		   out_len - sizeof(resp));
 
-	return __uverbs_create_xsrq(attrs, &cmd, &udata);
+	return __uverbs_create_xsrq(attrs, &cmd, &attrs->driver_udata);
 }
 
 static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
 				const char __user *buf, int in_len, int out_len)
 {
 	struct ib_uverbs_modify_srq cmd;
-	struct ib_udata             udata;
 	struct ib_srq              *srq;
 	struct ib_srq_attr          attr;
 	int                         ret;
@@ -3805,8 +3786,8 @@ static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
-		   out_len);
+	ib_uverbs_init_udata(&attrs->driver_udata, buf + sizeof cmd, NULL,
+			     in_len - sizeof cmd, out_len);
 
 	srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs);
 	if (!srq)
@@ -3815,7 +3796,8 @@ static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
 	attr.max_wr    = cmd.max_wr;
 	attr.srq_limit = cmd.srq_limit;
 
-	ret = srq->device->modify_srq(srq, &attr, cmd.attr_mask, &udata);
+	ret = srq->device->modify_srq(srq, &attr, cmd.attr_mask,
+				      &attrs->driver_udata);
 
 	uobj_put_obj_read(srq);
 
@@ -3889,8 +3871,7 @@ static int ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs,
-				     struct ib_udata *ucore,
-				     struct ib_udata *uhw)
+				     struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_query_device_resp resp = { {0} };
 	struct ib_uverbs_ex_query_device  cmd;
@@ -3922,7 +3903,7 @@ static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs,
 	if (ucore->outlen < resp.response_length)
 		return -ENOSPC;
 
-	err = ib_dev->query_device(ib_dev, &attr, uhw);
+	err = ib_dev->query_device(ib_dev, &attr, &attrs->driver_udata);
 	if (err)
 		return err;
 
@@ -4013,7 +3994,7 @@ static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs,
-				  struct ib_udata *ucore, struct ib_udata *uhw)
+				  struct ib_udata *ucore)
 {
 	struct ib_uverbs_ex_modify_cq cmd = {};
 	struct ib_cq *cq;
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index bcbee8fc83a9..fc8d3d1c7048 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -697,7 +697,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
 					  hdr.out_words * 4);
 	} else {
 		struct ib_udata ucore;
-		struct ib_udata uhw;
 
 		buf += sizeof(ex_hdr);
 
@@ -705,13 +704,13 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
 					u64_to_user_ptr(ex_hdr.response),
 					hdr.in_words * 8, hdr.out_words * 8);
 
-		ib_uverbs_init_udata_buf_or_null(&uhw,
+		ib_uverbs_init_udata_buf_or_null(&bundle.driver_udata,
 					buf + ucore.inlen,
 					u64_to_user_ptr(ex_hdr.response) + ucore.outlen,
 					ex_hdr.provider_in_words * 8,
 					ex_hdr.provider_out_words * 8);
 
-		ret = method_elm->handler_ex(&bundle, &ucore, &uhw);
+		ret = method_elm->handler_ex(&bundle, &ucore);
 	}
 
 	srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c
index 4870c9c16084..e16137cc5b28 100644
--- a/drivers/infiniband/core/uverbs_uapi.c
+++ b/drivers/infiniband/core/uverbs_uapi.c
@@ -15,7 +15,7 @@ static int ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs,
 }
 
 static int ib_uverbs_ex_notsupp(struct uverbs_attr_bundle *attrs,
-				struct ib_udata *ucore, struct ib_udata *uhw)
+				struct ib_udata *ucore)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h
index 7bed0bb4211c..5fa8d63aa838 100644
--- a/include/rdma/uverbs_ioctl.h
+++ b/include/rdma/uverbs_ioctl.h
@@ -375,8 +375,7 @@ struct uapi_definition {
 				  const char __user *buf, int in_len,
 				  int out_len);
 		int (*func_write_ex)(struct uverbs_attr_bundle *attrs,
-				     struct ib_udata *ucore,
-				     struct ib_udata *uhw);
+				     struct ib_udata *ucore);
 		const struct uapi_definition *chain;
 		const struct uverbs_object_def *chain_obj_tree;
 		size_t needs_fn_offset;
@@ -643,6 +642,7 @@ struct uverbs_attr {
 };
 
 struct uverbs_attr_bundle {
+	struct ib_udata driver_udata;
 	struct ib_uverbs_file *ufile;
 	DECLARE_BITMAP(attr_present, UVERBS_API_ATTR_BKEY_LEN);
 	struct uverbs_attr attrs[];
-- 
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux