All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] uring-passthrough for admin commands
       [not found] <CGME20220520091211epcas5p3bf0725dce4d84f1fdde8cc4a4050ca37@epcas5p3.samsung.com>
@ 2022-05-20  9:06 ` Kanchan Joshi
       [not found]   ` <CGME20220520091212epcas5p4da8c22b626a6b30bff00c9d4e0c7c265@epcas5p4.samsung.com>
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kanchan Joshi @ 2022-05-20  9:06 UTC (permalink / raw)
  To: axboe, hch, kbusch; +Cc: linux-nvme, gost.dev, joshiiitr

Hi Jens,

The series enables uring-passthrough for admin-commands.
Please see if this can go in.

Patch 1 is prep.
Patch 2 adds new opcodes for admin uring-passthrough, and enables it on
nvme controller dev(/dev/nvmeX).It reuses the code of io-command
passthrough, with the only difference that commands are issued on admin
queue.

Changes since v2:
- add vectored variant too
- apply reviewed-by tag

Changes since v1:
- drop the code that supports this op over ns char device
- apply reviewed-by tag

Kanchan Joshi (2):
  nvme: helper for uring-passthrough checks
  nvme: enable uring-passthrough for admin commands

 drivers/nvme/host/core.c        |  1 +
 drivers/nvme/host/ioctl.c       | 47 +++++++++++++++++++++++++++------
 drivers/nvme/host/nvme.h        |  1 +
 include/uapi/linux/nvme_ioctl.h |  2 ++
 4 files changed, 43 insertions(+), 8 deletions(-)

-- 
2.25.1



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

* [PATCH v3 1/2] nvme: helper for uring-passthrough checks
       [not found]   ` <CGME20220520091212epcas5p4da8c22b626a6b30bff00c9d4e0c7c265@epcas5p4.samsung.com>
@ 2022-05-20  9:06     ` Kanchan Joshi
  0 siblings, 0 replies; 4+ messages in thread
From: Kanchan Joshi @ 2022-05-20  9:06 UTC (permalink / raw)
  To: axboe, hch, kbusch; +Cc: linux-nvme, gost.dev, joshiiitr

Factor out a helper consolidating the error checks, and fix typo in a
comment too. This is in preparation to support admin commands on this
path.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/ioctl.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 7b0e2c9cdcae..114b490592b0 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -556,22 +556,30 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return __nvme_ioctl(ns, cmd, (void __user *)arg);
 }
 
-static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
-			     unsigned int issue_flags)
+static int nvme_uring_cmd_checks(unsigned int issue_flags)
 {
-	struct nvme_ctrl *ctrl = ns->ctrl;
-	int ret;
-
-	BUILD_BUG_ON(sizeof(struct nvme_uring_cmd_pdu) > sizeof(ioucmd->pdu));
-
 	/* IOPOLL not supported yet */
 	if (issue_flags & IO_URING_F_IOPOLL)
 		return -EOPNOTSUPP;
 
-	/* NVMe passthrough requires bit SQE/CQE support */
+	/* NVMe passthrough requires big SQE/CQE support */
 	if ((issue_flags & (IO_URING_F_SQE128|IO_URING_F_CQE32)) !=
 	    (IO_URING_F_SQE128|IO_URING_F_CQE32))
 		return -EOPNOTSUPP;
+	return 0;
+}
+
+static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
+			     unsigned int issue_flags)
+{
+	struct nvme_ctrl *ctrl = ns->ctrl;
+	int ret;
+
+	BUILD_BUG_ON(sizeof(struct nvme_uring_cmd_pdu) > sizeof(ioucmd->pdu));
+
+	ret = nvme_uring_cmd_checks(issue_flags);
+	if (ret)
+		return ret;
 
 	switch (ioucmd->cmd_op) {
 	case NVME_URING_CMD_IO:
-- 
2.25.1



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

* [PATCH v3 2/2] nvme: enable uring-passthrough for admin commands
       [not found]   ` <CGME20220520091213epcas5p2f54b3eacb5f9698bdee1c81a39281418@epcas5p2.samsung.com>
@ 2022-05-20  9:06     ` Kanchan Joshi
  0 siblings, 0 replies; 4+ messages in thread
From: Kanchan Joshi @ 2022-05-20  9:06 UTC (permalink / raw)
  To: axboe, hch, kbusch; +Cc: linux-nvme, gost.dev, joshiiitr

Add two new opcodes that userspace can use for admin commands:
NVME_URING_CMD_ADMIN : non-vectroed
NVME_URING_CMD_ADMIN_VEC : vectored variant

Wire up support when these are issued on controller node(/dev/nvmeX).

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c        |  1 +
 drivers/nvme/host/ioctl.c       | 23 +++++++++++++++++++++++
 drivers/nvme/host/nvme.h        |  1 +
 include/uapi/linux/nvme_ioctl.h |  2 ++
 4 files changed, 27 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b7095ef6586b..895f70d8f56c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3148,6 +3148,7 @@ static const struct file_operations nvme_dev_fops = {
 	.release	= nvme_dev_release,
 	.unlocked_ioctl	= nvme_dev_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
+	.uring_cmd	= nvme_dev_uring_cmd,
 };
 
 static ssize_t nvme_sysfs_reset(struct device *dev,
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 114b490592b0..096b1b47d750 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -686,6 +686,29 @@ int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
 }
 #endif /* CONFIG_NVME_MULTIPATH */
 
+int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
+{
+	struct nvme_ctrl *ctrl = ioucmd->file->private_data;
+	int ret;
+
+	ret = nvme_uring_cmd_checks(issue_flags);
+	if (ret)
+		return ret;
+
+	switch (ioucmd->cmd_op) {
+	case NVME_URING_CMD_ADMIN:
+		ret = nvme_uring_cmd_io(ctrl, NULL, ioucmd, issue_flags, false);
+		break;
+	case NVME_URING_CMD_ADMIN_VEC:
+		ret = nvme_uring_cmd_io(ctrl, NULL, ioucmd, issue_flags, true);
+		break;
+	default:
+		ret = -ENOTTY;
+	}
+
+	return ret;
+}
+
 static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp)
 {
 	struct nvme_ns *ns;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index d60024032012..9b72b6ecf33c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -788,6 +788,7 @@ int nvme_ns_chr_uring_cmd(struct io_uring_cmd *ioucmd,
 int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
 		unsigned int issue_flags);
 int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
+int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags);
 
 extern const struct attribute_group *nvme_ns_id_attr_groups[];
 extern const struct pr_ops nvme_pr_ops;
diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index 0b1876aa5a59..2f76cba67166 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -108,5 +108,7 @@ struct nvme_uring_cmd {
 /* io_uring async commands: */
 #define NVME_URING_CMD_IO	_IOWR('N', 0x80, struct nvme_uring_cmd)
 #define NVME_URING_CMD_IO_VEC	_IOWR('N', 0x81, struct nvme_uring_cmd)
+#define NVME_URING_CMD_ADMIN	_IOWR('N', 0x82, struct nvme_uring_cmd)
+#define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd)
 
 #endif /* _UAPI_LINUX_NVME_IOCTL_H */
-- 
2.25.1



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

* Re: [PATCH v3 0/2] uring-passthrough for admin commands
  2022-05-20  9:06 ` [PATCH v3 0/2] uring-passthrough for admin commands Kanchan Joshi
       [not found]   ` <CGME20220520091212epcas5p4da8c22b626a6b30bff00c9d4e0c7c265@epcas5p4.samsung.com>
       [not found]   ` <CGME20220520091213epcas5p2f54b3eacb5f9698bdee1c81a39281418@epcas5p2.samsung.com>
@ 2022-05-20 12:18   ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-05-20 12:18 UTC (permalink / raw)
  To: joshi.k, kbusch, Christoph Hellwig; +Cc: joshiiitr, linux-nvme, gost.dev

On Fri, 20 May 2022 14:36:28 +0530, Kanchan Joshi wrote:
> The series enables uring-passthrough for admin-commands.
> Please see if this can go in.
> 
> Patch 1 is prep.
> Patch 2 adds new opcodes for admin uring-passthrough, and enables it on
> nvme controller dev(/dev/nvmeX).It reuses the code of io-command
> passthrough, with the only difference that commands are issued on admin
> queue.
> 
> [...]

Applied, thanks!

[1/2] nvme: helper for uring-passthrough checks
      commit: 00fc2eeb15acc7f7e8713edc6d4d9855936226cb
[2/2] nvme: enable uring-passthrough for admin commands
      commit: 58e5bdeb9c2b06895e723c0b1e670f54510ff782

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2022-05-20 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220520091211epcas5p3bf0725dce4d84f1fdde8cc4a4050ca37@epcas5p3.samsung.com>
2022-05-20  9:06 ` [PATCH v3 0/2] uring-passthrough for admin commands Kanchan Joshi
     [not found]   ` <CGME20220520091212epcas5p4da8c22b626a6b30bff00c9d4e0c7c265@epcas5p4.samsung.com>
2022-05-20  9:06     ` [PATCH v3 1/2] nvme: helper for uring-passthrough checks Kanchan Joshi
     [not found]   ` <CGME20220520091213epcas5p2f54b3eacb5f9698bdee1c81a39281418@epcas5p2.samsung.com>
2022-05-20  9:06     ` [PATCH v3 2/2] nvme: enable uring-passthrough for admin commands Kanchan Joshi
2022-05-20 12:18   ` [PATCH v3 0/2] " Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.