From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: <jgg@ziepe.ca>, <leon@kernel.org>
Cc: <allen.hubbe@amd.com>, <nikhil.agarwal@amd.com>,
<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Abhijit Gangurde" <abhijit.gangurde@amd.com>
Subject: [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
Date: Thu, 3 Dec 2026 16:38:05 +0530 [thread overview]
Message-ID: <20261203110805.2577721-5-abhijit.gangurde@amd.com> (raw)
In-Reply-To: <20261203110805.2577721-1-abhijit.gangurde@amd.com>
Userspace passes each QP ring to create_qp as a
struct ib_uverbs_buffer_desc on the core attributes
UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and
UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM. Those attributes are already
optional on UVERBS_METHOD_QP_CREATE. The get_context bit
IONIC_CTX_CMASK_CQ_QP_BUF_UMEM tells userspace it may send them.
ionic_get_user_q_umem() now pins a ring with ib_umem_get_attr_or_va().
The core resolves the descriptor, so the ring can be a virtual address
or a dma-buf and the driver does not look inside it. The qdesc address
is not used when the attribute is present. Without the attribute the
ring is pinned from the qdesc address, as before.
A ring passed in the attribute must be exactly the qdesc size, so the
page table given to the device covers the ring and nothing else. Any
other length is rejected with -EINVAL.
Access is 0, so the VA mapping direction stays DMA_TO_DEVICE. SRQ
creation passes no attribute bundle and still pins the qdesc address.
An SRQ QP still only checks that the RQ qdesc is zero.
ionic_qp_req is not changed, so a provider that does not send the
attributes still creates a QP on the write path.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
.../infiniband/hw/ionic/ionic_controlpath.c | 34 +++++++++++++------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index c3a47aa108e4..a2a191f2af78 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -2009,7 +2009,8 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
}
static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
- struct ib_umem **umem_out)
+ const struct uverbs_attr_bundle *attrs,
+ u16 attr_id, struct ib_umem **umem_out)
{
struct ib_umem *umem;
int rc;
@@ -2018,12 +2019,13 @@ static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
if (rc)
return rc;
- umem = ib_umem_get_va(&dev->ibdev, q->addr, q->size, 0);
+ umem = ib_umem_get_attr_or_va(&dev->ibdev, attrs, attr_id,
+ q->addr, q->size, 0);
if (IS_ERR(umem))
return PTR_ERR(umem);
- /* The ring is given to the device as whole pages */
- if (ib_umem_offset(umem)) {
+ /* The device is given whole pages, and only those of the ring */
+ if (umem->length != q->size || ib_umem_offset(umem)) {
ib_umem_release(umem);
return -EINVAL;
}
@@ -2035,7 +2037,8 @@ static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_qp *qp, struct ionic_qdesc *sq,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int max_data, int sq_spec, struct ib_udata *udata)
+ int max_data, int sq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2079,7 +2082,9 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_get_user_q_umem(dev, sq, &qp->sq_umem);
+ rc = ionic_get_user_q_umem(dev, sq, attrs,
+ UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM,
+ &qp->sq_umem);
if (rc)
return rc;
@@ -2294,7 +2299,8 @@ static void ionic_rq_destroy_cmb(struct ionic_ibdev *dev,
static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_rq *rq, struct ionic_qdesc *qdesc,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int rq_spec, struct ib_udata *udata)
+ int rq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2312,7 +2318,9 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_get_user_q_umem(dev, qdesc, &rq->umem);
+ rc = ionic_get_user_q_umem(dev, qdesc, attrs,
+ UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM,
+ &rq->umem);
if (rc)
return rc;
@@ -2410,6 +2418,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
struct ionic_qp *qp = to_ionic_qp(ibqp);
struct ionic_ctx *ctx =
rdma_udata_to_drv_context(udata, struct ionic_ctx, ibctx);
+ const struct uverbs_attr_bundle *attrs = NULL;
struct ionic_qp_resp resp = {};
struct ionic_qp_req req = {};
struct ionic_cq *cq;
@@ -2418,6 +2427,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
int rc;
if (udata) {
+ attrs = rdma_udata_to_uverbs_attr_bundle(udata);
+
rc = ib_copy_validate_udata_in(udata, req, rsvd);
if (rc)
return rc;
@@ -2496,7 +2507,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
rc = ionic_qp_sq_init(dev, ctx, qp, &req.sq, &sq_buf,
attr->cap.max_send_wr, attr->cap.max_send_sge,
- attr->cap.max_inline_data, req.sq_spec, udata);
+ attr->cap.max_inline_data, req.sq_spec, udata,
+ attrs);
if (rc)
goto err_sq;
@@ -2515,7 +2527,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
qp->rq.qid = qp->qpid;
rc = ionic_rq_init(dev, ctx, &qp->rq, &req.rq, &rq_buf,
attr->cap.max_recv_wr, attr->cap.max_recv_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, attrs);
}
if (rc)
goto err_rq;
@@ -3122,7 +3134,7 @@ int ionic_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *attr,
rc = ionic_rq_init(dev, ctx, &srq->rq, &req.rq, &buf,
attr->attr.max_wr, attr->attr.max_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, NULL);
if (rc)
return rc;
--
2.43.0
prev parent reply other threads:[~2026-12-03 11:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as " Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 1/4] RDMA/ionic: Bound user queue depth and stride before shifting Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 2/4] RDMA/ionic: Check user ring alignment on the pinned umem Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes Abhijit Gangurde
2026-12-03 11:08 ` Abhijit Gangurde [this message]
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=20261203110805.2577721-5-abhijit.gangurde@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=nikhil.agarwal@amd.com \
/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
all inboxes | Powered by JetHome®