Commit ef87df2c authored by Jason Gunthorpe's avatar Jason Gunthorpe
Browse files

RDMA/uverbs: Use uverbs_attr_bundle to pass udata for write_ex



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: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent da0f60df
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+67 −86

File changed.

Preview size limit exceeded, changes collapsed.

+2 −3
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
}
+2 −2
Original line number Diff line number Diff line
@@ -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[];