[PATCH v2 5/5] nvme: support dma-buf registered buffers for passthrough
Pavel Begunkov
asml.silence at gmail.com
Thu Oct 29 03:53:07 PDT 2026
On 10/22/26 15:44, Anuj Gupta wrote:
> From: Anuj Gupta <anuj20.g at samsung.com>
>
> Allow registering a dma-buf against an NVMe namespace character device
> and using it as the data buffer of fixed uring_cmd passthrough I/O.
> Complete through io_uring_cmd_hw_done(), so the dma-buf map is released
> at hardware completion.
>
> Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
> ---
> drivers/nvme/host/core.c | 16 ++++++++++++++++
> drivers/nvme/host/ioctl.c | 5 +++--
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index d81462e864a4..6157ff839929 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -8,6 +8,7 @@
> #include <linux/blkdev.h>
> #include <linux/blk-mq.h>
> #include <linux/blk-integrity.h>
> +#include <linux/dma-buf-io.h>
> #include <linux/compat.h>
> #include <linux/delay.h>
> #include <linux/errno.h>
> @@ -3982,6 +3983,20 @@ static int nvme_ns_chr_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> +static int nvme_ns_chr_init_dma_buf_io_ctx(struct file *file,
> + struct dma_buf_io_ctx *ctx)
> +{
> + struct nvme_ns *ns =
> + container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
> + struct nvme_ctrl *ctrl = ns->ctrl;
> +
> + if (ctx->dmabuf->size > UINT_MAX)
> + return -EINVAL;
> + if (!ctrl->ops->init_dma_buf_io_ctx)
> + return -EINVAL;
Let's return -EOPNOTSUPP for consistency, with that
Reviewed-by: Pavel Begunkov <asml.silence at gmail.com>
--
Pavel Begunkov
More information about the Linux-nvme
mailing list