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

The series enables uring-passthrough for admin-commands.

Patch 1 is prep.
Patch 2 adds new opcode 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 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       | 44 +++++++++++++++++++++++++++------
 drivers/nvme/host/nvme.h        |  1 +
 include/uapi/linux/nvme_ioctl.h |  1 +
 4 files changed, 39 insertions(+), 8 deletions(-)

-- 
2.25.1



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

* [PATCH v2 1/2] nvme: helper for uring-passthrough checks
       [not found]   ` <CGME20220520050119epcas5p3de7be37ffc16b99627173bd1c4900439@epcas5p3.samsung.com>
@ 2022-05-20  4:55     ` Kanchan Joshi
  0 siblings, 0 replies; 6+ messages in thread
From: Kanchan Joshi @ 2022-05-20  4:55 UTC (permalink / raw)
  To: hch, kbusch, axboe; +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] 6+ messages in thread

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

Add a new opcode NVME_URING_CMD_ADMIN that userspace can use.
Wire up support for the case when this is issued on controller node
(/dev/nvmeX).

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
 drivers/nvme/host/core.c        |  1 +
 drivers/nvme/host/ioctl.c       | 20 ++++++++++++++++++++
 drivers/nvme/host/nvme.h        |  1 +
 include/uapi/linux/nvme_ioctl.h |  1 +
 4 files changed, 23 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..7902fd5c69e1 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -686,6 +686,26 @@ 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;
+	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..6bcda1be6456 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -108,5 +108,6 @@ 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)
 
 #endif /* _UAPI_LINUX_NVME_IOCTL_H */
-- 
2.25.1



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

* Re: [PATCH v2 0/2] uring-passthrough for admin commands
  2022-05-20  4:55 ` [PATCH v2 0/2] uring-passthrough for admin commands Kanchan Joshi
       [not found]   ` <CGME20220520050119epcas5p3de7be37ffc16b99627173bd1c4900439@epcas5p3.samsung.com>
       [not found]   ` <CGME20220520050120epcas5p41c6262e3c3ac9029f5895c696c233228@epcas5p4.samsung.com>
@ 2022-05-20  6:01   ` Christoph Hellwig
  2022-05-20  8:21     ` Kanchan Joshi
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2022-05-20  6:01 UTC (permalink / raw)
  To: Kanchan Joshi; +Cc: hch, kbusch, axboe, linux-nvme, gost.dev, joshiiitr

On Fri, May 20, 2022 at 10:25:58AM +0530, Kanchan Joshi wrote:
> The series enables uring-passthrough for admin-commands.
> 
> Patch 1 is prep.
> Patch 2 adds new opcode 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.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Can we add vectored admin commands as well, please?  We basically
get them for free, so I see no reason not to add them.


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

* Re: [PATCH v2 0/2] uring-passthrough for admin commands
  2022-05-20  6:01   ` [PATCH v2 0/2] " Christoph Hellwig
@ 2022-05-20  8:21     ` Kanchan Joshi
  2022-05-20  9:15       ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Kanchan Joshi @ 2022-05-20  8:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, axboe, linux-nvme, gost.dev, joshiiitr

[-- Attachment #1: Type: text/plain, Size: 1192 bytes --]

On Fri, May 20, 2022 at 08:01:43AM +0200, Christoph Hellwig wrote:
>On Fri, May 20, 2022 at 10:25:58AM +0530, Kanchan Joshi wrote:
>> The series enables uring-passthrough for admin-commands.
>>
>> Patch 1 is prep.
>> Patch 2 adds new opcode 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.
>
>Looks good:
>
>Reviewed-by: Christoph Hellwig <hch@lst.de>
>
>Can we add vectored admin commands as well, please?  We basically
>get them for free, so I see no reason not to add them.

Sure. By free, you mean this I suppose: 

--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -699,6 +699,9 @@ int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
        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;

anything else? I will fold this in, and submit v3 before Jens takes a
look.

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v2 0/2] uring-passthrough for admin commands
  2022-05-20  8:21     ` Kanchan Joshi
@ 2022-05-20  9:15       ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2022-05-20  9:15 UTC (permalink / raw)
  To: Kanchan Joshi
  Cc: Christoph Hellwig, kbusch, axboe, linux-nvme, gost.dev, joshiiitr

On Fri, May 20, 2022 at 01:51:34PM +0530, Kanchan Joshi wrote:
> Sure. By free, you mean this I suppose: 
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -699,6 +699,9 @@ int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
>        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;
>
> anything else? I will fold this in, and submit v3 before Jens takes a
> look.

We need a definition for NVME_URING_CMD_ADMIN_VEC, but yes, that's it.


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220520050118epcas5p1f6a930419285ecdac65afaa22255c03f@epcas5p1.samsung.com>
2022-05-20  4:55 ` [PATCH v2 0/2] uring-passthrough for admin commands Kanchan Joshi
     [not found]   ` <CGME20220520050119epcas5p3de7be37ffc16b99627173bd1c4900439@epcas5p3.samsung.com>
2022-05-20  4:55     ` [PATCH v2 1/2] nvme: helper for uring-passthrough checks Kanchan Joshi
     [not found]   ` <CGME20220520050120epcas5p41c6262e3c3ac9029f5895c696c233228@epcas5p4.samsung.com>
2022-05-20  4:56     ` [PATCH v2 2/2] nvme: enable uring-passthrough for admin commands Kanchan Joshi
2022-05-20  6:01   ` [PATCH v2 0/2] " Christoph Hellwig
2022-05-20  8:21     ` Kanchan Joshi
2022-05-20  9:15       ` Christoph Hellwig

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.