public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/core: Add writev to uverbs file descriptor
@ 2026-03-11 17:33 Dennis Dalessandro
  2026-03-16 13:46 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dennis Dalessandro @ 2026-03-11 17:33 UTC (permalink / raw)
  To: jgg, leon; +Cc: Dean Luick, linux-rdma

From: Dean Luick <dean.luick@cornelisnetworks.com>

Add a writev pass-through between the uverbs file descriptor and
infiniband devices.  Interested devices may subscribe to this
functionality.

The goal is to keep all the semantics of the user interface the same so
it's an easy migration to the uverbs cdev from the private cdev. The idea
is that all the command and control is still ioctl, but the "data path" is
still using the writev() to pass in the iovecs.

Signed-off-by: Dean Luick <dean.luick@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>

---
Changes since v1:
Updated commit message to indiate why we are keeping the
writev semantic.
---
 drivers/infiniband/core/device.c      |    1 +
 drivers/infiniband/core/uverbs_main.c |   22 ++++++++++++++++++++++
 include/rdma/ib_verbs.h               |    2 ++
 3 files changed, 25 insertions(+)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 1b5f1ee0a557..e94aebea16e1 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2805,6 +2805,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
 	SET_DEVICE_OP(dev_ops, set_vf_link_state);
 	SET_DEVICE_OP(dev_ops, ufile_hw_cleanup);
 	SET_DEVICE_OP(dev_ops, report_port_event);
+	SET_DEVICE_OP(dev_ops, write_iter);
 
 	SET_OBJ_SIZE(dev_ops, ib_ah);
 	SET_OBJ_SIZE(dev_ops, ib_counters);
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 7b68967a6301..b393d3a0f11c 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -713,6 +713,26 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
 	return ret;
 }
 
+static ssize_t ib_uverbs_write_iter(struct kiocb *kiocb, struct iov_iter *from)
+{
+	struct ib_uverbs_file *file = kiocb->ki_filp->private_data;
+	struct ib_ucontext *ucontext;
+	ssize_t ret = -EOPNOTSUPP;
+	int srcu_key;
+
+	srcu_key = srcu_read_lock(&file->device->disassociate_srcu);
+	ucontext = ib_uverbs_get_ucontext_file(file);
+	if (IS_ERR(ucontext)) {
+		ret = PTR_ERR(ucontext);
+		goto out;
+	}
+	if (ucontext->device->ops.write_iter)
+		ret = ucontext->device->ops.write_iter(ucontext, from);
+out:
+	srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
+	return ret;
+}
+
 /*
  * The VMA has been dup'd, initialize the vm_private_data with a new tracking
  * struct
@@ -1031,6 +1051,7 @@ static const struct file_operations uverbs_fops = {
 	.release = ib_uverbs_close,
 	.unlocked_ioctl = ib_uverbs_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
+	.write_iter = ib_uverbs_write_iter,
 };
 
 static const struct file_operations uverbs_mmap_fops = {
@@ -1041,6 +1062,7 @@ static const struct file_operations uverbs_mmap_fops = {
 	.release = ib_uverbs_close,
 	.unlocked_ioctl = ib_uverbs_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
+	.write_iter = ib_uverbs_write_iter,
 };
 
 static int ib_uverbs_get_nl_info(struct ib_device *ibdev, void *client_data,
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3f3827e1c711..c92496783028 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2757,6 +2757,8 @@ struct ib_device_ops {
 	 * Everyone else relies on Linux memory management model.
 	 */
 	int (*get_numa_node)(struct ib_device *dev);
+	/* subscribe to file ops write_iter callback */
+	ssize_t (*write_iter)(struct ib_ucontext *context, struct iov_iter *from);
 
 	/*
 	 * add_sub_dev - Add a sub IB device



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for-next] RDMA/core: Add writev to uverbs file descriptor
  2026-03-11 17:33 [PATCH for-next] RDMA/core: Add writev to uverbs file descriptor Dennis Dalessandro
@ 2026-03-16 13:46 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-03-16 13:46 UTC (permalink / raw)
  To: Dennis Dalessandro; +Cc: jgg, Dean Luick, linux-rdma

On Wed, Mar 11, 2026 at 01:33:37PM -0400, Dennis Dalessandro wrote:
> From: Dean Luick <dean.luick@cornelisnetworks.com>
> 
> Add a writev pass-through between the uverbs file descriptor and
> infiniband devices.  Interested devices may subscribe to this
> functionality.
> 
> The goal is to keep all the semantics of the user interface the same so
> it's an easy migration to the uverbs cdev from the private cdev. The idea
> is that all the command and control is still ioctl, but the "data path" is
> still using the writev() to pass in the iovecs.
> 
> Signed-off-by: Dean Luick <dean.luick@cornelisnetworks.com>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
> 
> ---
> Changes since v1:
> Updated commit message to indiate why we are keeping the
> writev semantic.
> ---
>  drivers/infiniband/core/device.c      |    1 +
>  drivers/infiniband/core/uverbs_main.c |   22 ++++++++++++++++++++++
>  include/rdma/ib_verbs.h               |    2 ++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 1b5f1ee0a557..e94aebea16e1 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -2805,6 +2805,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
>  	SET_DEVICE_OP(dev_ops, set_vf_link_state);
>  	SET_DEVICE_OP(dev_ops, ufile_hw_cleanup);
>  	SET_DEVICE_OP(dev_ops, report_port_event);
> +	SET_DEVICE_OP(dev_ops, write_iter);
>  
>  	SET_OBJ_SIZE(dev_ops, ib_ah);
>  	SET_OBJ_SIZE(dev_ops, ib_counters);
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index 7b68967a6301..b393d3a0f11c 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -713,6 +713,26 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
>  	return ret;
>  }
>  
> +static ssize_t ib_uverbs_write_iter(struct kiocb *kiocb, struct iov_iter *from)
> +{
> +	struct ib_uverbs_file *file = kiocb->ki_filp->private_data;
> +	struct ib_ucontext *ucontext;
> +	ssize_t ret = -EOPNOTSUPP;
> +	int srcu_key;

I see that this function is modeled after ib_uverbs_mmap(), not
ib_uverbs_write(). Why is ib_safe_file_access(ki_filp) not used here?

Also, this should be documented as a narrow, migration‑only path for the
legacy hfi1 driver, and it must not be used by any other new code.

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-16 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 17:33 [PATCH for-next] RDMA/core: Add writev to uverbs file descriptor Dennis Dalessandro
2026-03-16 13:46 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox