linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kanchan Joshi <joshi.k@samsung.com>
To: hch@lst.de, kbusch@kernel.org, axboe@kernel.dk
Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
	joshiiitr@gmail.com
Subject: [PATCH 2/2] nvme: add vectored-io support for user passthru
Date: Thu, 27 Jan 2022 13:55:36 +0530	[thread overview]
Message-ID: <20220127082536.7243-3-joshi.k@samsung.com> (raw)
In-Reply-To: <20220127082536.7243-1-joshi.k@samsung.com>

wire up support for passthru that takes an array of buffers (using
iovec). Enable it for NVME_IOCTL_IO64_CMD; same ioctl code to be used
with following differences -

1. NVME_IOVEC to be set as cmd.flags
2. cmd.addr, base addr of user iovec array
3. cmd.data_len, count of iovec array elements

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
 drivers/nvme/host/ioctl.c       | 9 ++++++---
 include/uapi/linux/nvme_ioctl.h | 4 ++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 22314962842d..3a896443e110 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -65,6 +65,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
 	struct bio *bio = NULL;
 	void *meta = NULL;
 	int ret;
+	u8 cmd_flags = cmd->common.flags;
 
 	req = nvme_alloc_request(q, cmd, 0);
 	if (IS_ERR(req))
@@ -75,7 +76,11 @@ static int nvme_submit_user_cmd(struct request_queue *q,
 	nvme_req(req)->flags |= NVME_REQ_USERCMD;
 
 	if (ubuffer && bufflen) {
-		ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
+		if (!(cmd_flags & NVME_IOVEC))
+			ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
+				GFP_KERNEL);
+		else
+			ret = blk_rq_map_user_vec(q, req, NULL, ubuffer, bufflen,
 				GFP_KERNEL);
 		if (ret)
 			goto out;
@@ -246,8 +251,6 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 		return -EACCES;
 	if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
 		return -EFAULT;
-	if (cmd.flags)
-		return -EINVAL;
 	if (!nvme_validate_passthru_nsid(ctrl, ns, cmd.nsid))
 		return -EINVAL;
 
diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index d99b5a772698..d4999e3930f8 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -9,6 +9,10 @@
 
 #include <linux/types.h>
 
+enum nvme_ioc_flags {
+	NVME_IOVEC	= 1 << 0 /* vectored io */
+};
+
 struct nvme_user_io {
 	__u8	opcode;
 	__u8	flags;
-- 
2.25.1


  parent reply	other threads:[~2022-01-27  9:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220127083033epcas5p3ce9565e4b5e21e897571e48e73e4f9af@epcas5p3.samsung.com>
2022-01-27  8:25 ` [PATCH 0/2] nvme-passthru with vectored-io Kanchan Joshi
2022-01-27  8:25   ` [PATCH 1/2] block: introduce and export blk_rq_map_user_vec Kanchan Joshi
2022-01-27  9:27     ` Christoph Hellwig
2022-01-27 14:38       ` Kanchan Joshi
2022-01-28  9:04     ` Chaitanya Kulkarni
2022-01-27  8:25   ` Kanchan Joshi [this message]
2022-01-27  9:29     ` [PATCH 2/2] nvme: add vectored-io support for user passthru Christoph Hellwig
2022-01-27 14:43       ` Kanchan Joshi
2022-01-28  9:08         ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220127082536.7243-3-joshi.k@samsung.com \
    --to=joshi.k@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=joshiiitr@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).