From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99351C54EE9 for ; Tue, 27 Sep 2022 17:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:References:Content-Type: Content-Transfer-Encoding:MIME-Version:In-Reply-To:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2f95MMw1JaP2a2qx6h2pgrT8vnSnYyP4Ul8WVop1exo=; b=jckrOZhd/gx8PG7g+gq9+WDjLV CC9MzjzZRRozs39Wi2Lj1uNlB0Xcms+23stDPR8m0w8ks9FetzQC/s412ddI9j7bF3ge5EqQKiJKo 9D7MDy+tLNRTZQ6s8Fo25nlDeHozySVzVi/uIiXHwSAx6df3qEvBcEt1zdHdV3thnNfub5+xLSA1T NNf8y4yBHip8nhLRXGqeu06b2kXBeZ2mh5OlnB2vktV2sJt9krbMqU1CqRwMc1LbOFLPTo0ZJgGOR YITCWgheq7zK3DHIqqUCtiTTtIRCn/WHC8ki5BEyS2DSKD0yLmZVUPtwi6c2qpqzXdYQY/JHtvlMT 6O8amCug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odEfZ-00C1cw-TD; Tue, 27 Sep 2022 17:46:57 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odEfI-00C1T9-P6 for linux-nvme@lists.infradead.org; Tue, 27 Sep 2022 17:46:43 +0000 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220927174633epoutp0144211a0e4ac4a4460d23af5a2b0e1e12~YyMDmZckm2246822468epoutp011 for ; Tue, 27 Sep 2022 17:46:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220927174633epoutp0144211a0e4ac4a4460d23af5a2b0e1e12~YyMDmZckm2246822468epoutp011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300793; bh=2f95MMw1JaP2a2qx6h2pgrT8vnSnYyP4Ul8WVop1exo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAYR9N16uW6TydQQ47rPf3EDd5FHo5A1xi9JAR4IphjcwKxfClKl4eu7Nb2T47arf hbiaWUxqWIiXJencq0hfP8QESlRuqBxmYAihSzLHKGUN6OHByngj4oyar6a+lJo3NH vm2ZtZ5Wo278J70UMKcluYIt6KdVnK6i0Dbmq7ls= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220927174632epcas5p4dd6448ae88ebad9737e3589bf0e1f4be~YyMCltHJ72946929469epcas5p4_; Tue, 27 Sep 2022 17:46:32 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4McRrP44FSz4x9Pv; Tue, 27 Sep 2022 17:46:29 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 93.1F.39477.5F633336; Wed, 28 Sep 2022 02:46:29 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4~YyL-pGxQ51324413244epcas5p2z; Tue, 27 Sep 2022 17:46:28 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174628epsmtrp23f8d0307799fd395005bf7627abf1dae~YyL-oZzhm3251332513epsmtrp2e; Tue, 27 Sep 2022 17:46:28 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-8c-633336f5910b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 43.86.18644.4F633336; Wed, 28 Sep 2022 02:46:28 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174627epsmtip13333a33747e87502e44e237be49767b0~YyL_O04190699506995epsmtip1i; Tue, 27 Sep 2022 17:46:27 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v10 2/7] io_uring: introduce fixed buffer support for io_uring_cmd Date: Tue, 27 Sep 2022 23:06:05 +0530 Message-Id: <20220927173610.7794-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplk+LIzCtJLcpLzFFi42LZdlhTQ/ermXGywesHshZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJ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FrrELMWRmVeSWpSXmKPExsWy7bCSnO4XM+Nkg7/zDC2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJVxZMtExoKPohW3f81ia2D8LtjFyMkhIWAi Mf/OFNYuRi4OIYEdjBL3305jhUiISzRf+8EOYQtLrPz3nB2i6COjxKxTk5i7GDk42AQ0JS5M LgWpEREwk1h6eA0LSA2zwEFGicvPnrCAJIQFoiUaF/5gA7FZBFQlNh2axwxi8wqYS1w+O4MR YoG8xMxL39lBZnIKWEgc/pgJEhYCKtm66QMLRLmgxMmZECOZgcqbt85mnsAoMAtJahaS1AJG plWMkqkFxbnpucWGBUZ5qeV6xYm5xaV56XrJ+bmbGMHBrqW1g3HPqg96hxiZOBgPMUpwMCuJ 8P4+apgsxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dUA9OK G+avP2116Tqc8S9+4nyWDB03x898shNXdxYnqO//XLHiX5bqbKOuzU4FAQmpqZ5nnYq2RcaY yE871Ou0x+nNqkLzu+8Stmorx1+smfarT6k71/jotbSz01IPMn2eclZZuXc3S59UwLn53Exa 9q+3idQEczFMMH643ounQW+SxKl766VaxbwaL/BMFDJcbV99+ojc/2o/hctN/B0Krkt5Imwr j0yed295i8KTpaGPDuclhr5ceGBpZ/Nsdr7jkjUR994kvHwg3CL6k6GeZVrV2bPLDU99Fi4W umB8cEP8xeIHnR/vGjyP2msR+UExcYm4lPlsc3Hndd93q9yfKyy9pL2fnze25YF644959Uos xRmJhlrMRcWJAGlfBJTlAgAA X-CMS-MailID: 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4 References: <20220927173610.7794-1-joshi.k@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220927_104641_172554_8744A061 X-CRM114-Status: GOOD ( 22.92 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Anuj Gupta Add IORING_URING_CMD_FIXED flag that is to be used for sending io_uring command with previously registered buffers. User-space passes the buffer index in sqe->buf_index, same as done in read/write variants that uses fixed buffers. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/io_uring.h | 2 +- include/uapi/linux/io_uring.h | 9 +++++++++ io_uring/uring_cmd.c | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 1dbf51115c30..e10c5cc81082 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -28,7 +28,7 @@ struct io_uring_cmd { void *cookie; }; u32 cmd_op; - u32 pad; + u32 flags; u8 pdu[32]; /* available inline for free use */ }; diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 92f29d9505a6..ab7458033ee3 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -56,6 +56,7 @@ struct io_uring_sqe { __u32 hardlink_flags; __u32 xattr_flags; __u32 msg_ring_flags; + __u32 uring_cmd_flags; }; __u64 user_data; /* data to be passed back at completion time */ /* pack this to avoid bogus arm OABI complaints */ @@ -219,6 +220,14 @@ enum io_uring_op { IORING_OP_LAST, }; +/* + * sqe->uring_cmd_flags + * IORING_URING_CMD_FIXED use registered buffer; pass thig flag + * along with setting sqe->buf_index. + */ +#define IORING_URING_CMD_FIXED (1U << 0) + + /* * sqe->fsync_flags */ diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 6a6d69523d75..faefa9f6f259 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -77,8 +78,21 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); - if (sqe->rw_flags || sqe->__pad1) + if (sqe->__pad1) return -EINVAL; + + ioucmd->flags = READ_ONCE(sqe->uring_cmd_flags); + if (ioucmd->flags & IORING_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 index; + + req->buf_index = READ_ONCE(sqe->buf_index); + if (unlikely(req->buf_index >= ctx->nr_user_bufs)) + return -EFAULT; + index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); + req->imu = ctx->user_bufs[index]; + io_req_set_rsrc_node(req, ctx, 0); + } ioucmd->cmd = sqe->cmd; ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); return 0; -- 2.25.1