* [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes
@ 2026-12-03 11:08 Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 1/4] RDMA/ionic: Bound user queue depth and stride before shifting Abhijit Gangurde
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Abhijit Gangurde @ 2026-12-03 11:08 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
Let userspace hand ionic queue rings to create_cq and create_qp as
struct ib_uverbs_buffer_desc, instead of only as a raw address in the
driver request. A ring may be a virtual address or a page-aligned
slice of a dma-buf, so several rings can share one dma-buf.
The get_context bit IONIC_CTX_CMASK_CQ_QP_BUF_UMEM tells userspace it
may send the descriptors. ionic_cq_req and ionic_qp_req are unchanged,
so a provider that does not send them still uses the existing write
path and ib_umem_get_va.
Userspace: https://github.com/linux-rdma/rdma-core/pull/1862
v4:
- New patch 2 moves the alignment check for all user rings
- Discarded lookup inside the buffer descriptor
v3:
- Move IONIC_CTX_CMASK_CQ_QP_BUF_UMEM from bit 1 to bit 3.
- Rebased on for-next.
- https://lore.kernel.org/linux-rdma/20261127040832.16908-1-abhijit.gangurde@amd.com/
v2:
- Fix sashiko reported comments
- New patch 1: bound depth/stride shift counts
- Reject non-zero qdesc addr for dma-buf
- QP: pin validated descriptor copy
- https://lore.kernel.org/linux-rdma/20261126044811.3458258-1-abhijit.gangurde@amd.com/
v1:
- https://lore.kernel.org/linux-rdma/20261118152313.113714-1-abhijit.gangurde@amd.com/
Abhijit Gangurde (4):
RDMA/ionic: Bound user queue depth and stride before shifting
RDMA/ionic: Check user ring alignment on the pinned umem
RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
MAINTAINERS | 1 +
drivers/infiniband/hw/ionic/ionic_admin.c | 2 +-
.../infiniband/hw/ionic/ionic_controlpath.c | 148 ++++++++++++++----
drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +
include/uapi/rdma/ionic-abi.h | 3 +
include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 ++
7 files changed, 153 insertions(+), 35 deletions(-)
create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [for-next v4 1/4] RDMA/ionic: Bound user queue depth and stride before shifting
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
@ 2026-12-03 11:08 ` Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 2/4] RDMA/ionic: Check user ring alignment on the pinned umem Abhijit Gangurde
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Abhijit Gangurde @ 2026-12-03 11:08 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
ionic_validate_qdesc() uses depth_log2 and stride_log2 from the user
request as shift counts without an upper bound. Both are u8, so
BIT(depth_log2) and BIT_ULL(depth_log2 + stride_log2) can shift by the
width of the type or more, which is undefined behaviour.
Where the shift count wraps, as on x86-64, the size check can be
bypassed. With depth_log2 = 4, mask = 15 and stride_log2 = 60, the
required size BIT_ULL(64) evaluates to 1, so a one page ring passes
validation with a depth and stride it cannot hold.
Reject a depth_log2 above order_base_2(IONIC_MAX_DEPTH), and a
depth_log2 + stride_log2 of BITS_PER_LONG_LONG or more, before either
shift.
Fixes: f3bdbd42702c ("RDMA/ionic: Create device queues to support admin operations")
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
drivers/infiniband/hw/ionic/ionic_controlpath.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index bf012f886fbc..717ab78b603c 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -23,6 +23,13 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q)
if (q->addr & (PAGE_SIZE - 1))
return -EINVAL;
+ /* Keep the shift counts below within the width of their types */
+ if (q->depth_log2 > order_base_2(IONIC_MAX_DEPTH))
+ return -EINVAL;
+
+ if (q->depth_log2 + q->stride_log2 >= BITS_PER_LONG_LONG)
+ return -EINVAL;
+
if (q->mask != BIT(q->depth_log2) - 1)
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [for-next v4 2/4] RDMA/ionic: Check user ring alignment on the pinned umem
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes 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 ` Abhijit Gangurde
2026-12-03 11:08 ` [for-next v4 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes Abhijit Gangurde
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Abhijit Gangurde @ 2026-12-03 11:08 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
ionic_validate_qdesc() rejects a user CQ, SQ or RQ ring when the
address in the request is zero or not page aligned. That only works
while the request address is the one place a ring can come from.
Check the pinned umem instead. Add ionic_cq_get_user_umem() and
ionic_get_user_q_umem(), which validate the queue geometry, pin the
ring and reject it with -EINVAL when ib_umem_offset() is not zero.
ionic_validate_qdesc() no longer looks at the address.
A ring that is not page aligned is still rejected with -EINVAL. A
zero address is no longer special-cased. Like any other unmapped
address, it fails with -EFAULT when the ring is pinned.
This prepares for rings passed as ioctl umem attributes, where the
buffer is described by the attribute and not by the request address.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
.../infiniband/hw/ionic/ionic_controlpath.c | 79 +++++++++++++------
1 file changed, 54 insertions(+), 25 deletions(-)
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 717ab78b603c..3abb8c01daf6 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -14,13 +14,9 @@
#define ionic_set_ecn(tos) (((tos) | 2u) & ~1u)
#define ionic_clear_ecn(tos) ((tos) & ~3u)
-static int ionic_validate_qdesc(struct ionic_qdesc *q)
+static int ionic_validate_qdesc(const struct ionic_qdesc *q)
{
- if (!q->addr || !q->size || !q->mask ||
- !q->depth_log2 || !q->stride_log2)
- return -EINVAL;
-
- if (q->addr & (PAGE_SIZE - 1))
+ if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2)
return -EINVAL;
/* Keep the shift counts below within the width of their types */
@@ -80,6 +76,31 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid)
ionic_resid_put(&dev->inuse_cqid, bitid);
}
+static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq,
+ const struct ionic_qdesc *req_cq)
+{
+ struct ib_umem *umem;
+ int rc;
+
+ rc = ionic_validate_qdesc(req_cq);
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr,
+ req_cq->size, IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+
+ /* The ring is given to the device as whole pages */
+ if (ib_umem_offset(umem)) {
+ ib_umem_release(umem);
+ return -EINVAL;
+ }
+
+ cq->umem = umem;
+ return 0;
+}
+
int ionic_create_cq_common(struct ionic_vcq *vcq,
struct ionic_tbl_buf *buf,
const struct ib_cq_init_attr *attr,
@@ -113,18 +134,10 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
INIT_LIST_HEAD(&cq->flush_rq);
if (udata) {
- rc = ionic_validate_qdesc(req_cq);
+ rc = ionic_cq_get_user_umem(dev, cq, req_cq);
if (rc)
goto err_qdesc;
- cq->umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
- req_cq->addr, req_cq->size,
- IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(cq->umem)) {
- rc = PTR_ERR(cq->umem);
- goto err_qdesc;
- }
-
cq->q.ptr = NULL;
cq->q.size = req_cq->size;
cq->q.mask = req_cq->mask;
@@ -1963,6 +1976,30 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order);
}
+static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
+ struct ib_umem **umem_out)
+{
+ struct ib_umem *umem;
+ int rc;
+
+ rc = ionic_validate_qdesc(q);
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_va(&dev->ibdev, 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)) {
+ ib_umem_release(umem);
+ return -EINVAL;
+ }
+
+ *umem_out = umem;
+ return 0;
+}
+
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,
@@ -2010,7 +2047,7 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(sq);
+ rc = ionic_get_user_q_umem(dev, sq, &qp->sq_umem);
if (rc)
return rc;
@@ -2024,10 +2061,6 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
qp->sq_meta = NULL;
qp->sq_msn_idx = NULL;
-
- qp->sq_umem = ib_umem_get_va(&dev->ibdev, sq->addr, sq->size, 0);
- if (IS_ERR(qp->sq_umem))
- return PTR_ERR(qp->sq_umem);
} else {
qp->sq_umem = NULL;
@@ -2247,7 +2280,7 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(qdesc);
+ rc = ionic_get_user_q_umem(dev, qdesc, &rq->umem);
if (rc)
return rc;
@@ -2260,10 +2293,6 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
rq->q.stride_log2 = qdesc->stride_log2;
rq->meta = NULL;
-
- rq->umem = ib_umem_get_va(&dev->ibdev, qdesc->addr, qdesc->size, 0);
- if (IS_ERR(rq->umem))
- return PTR_ERR(rq->umem);
} else {
rq->umem = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [for-next v4 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes 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 ` Abhijit Gangurde
2026-12-03 11:31 ` sashiko-bot
2026-12-03 11:08 ` [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
2026-12-03 11:32 ` [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as " sashiko-bot
4 siblings, 1 reply; 8+ messages in thread
From: Abhijit Gangurde @ 2026-12-03 11:08 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
Userspace can now pass each enabled CQ ring to create_cq as a
struct ib_uverbs_buffer_desc in a per-UDMA driver attribute, instead
of only as a raw address in ionic_cq_req.
Advertise support with IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in the get_context
response. Register two optional UVERBS_ATTR_UMEM attributes,
IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 and _1, on UVERBS_METHOD_CQ_CREATE
through ibdev->driver_def.
For each UDMA index in udma_mask, ionic_cq_get_user_umem() pins the
ring with ib_umem_get_attr() on the attribute for that index. 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. req_cq->addr is not
used when the attribute is present. Without the attribute the ring is
pinned from req_cq->addr with DMA_FROM_DEVICE, as before.
A ring passed in the attribute must be exactly req_cq->size bytes, so
the page table given to the device covers the ring and nothing else.
Any other length is rejected with -EINVAL.
A ring passed as a virtual address descriptor is mapped
DMA_BIDIRECTIONAL, because ib_umem_get_attr() derives the direction
from the access flags. The core CQ helpers that map DMA_FROM_DEVICE
only take UVERBS_ATTR_CREATE_CQ_BUF_UMEM, not a driver attribute.
An attribute for a UDMA index that is not in udma_mask is rejected
with -EINVAL. The kernel admin CQ path passes no attribute bundle and
is unchanged.
ionic_cq_req and ionic_cq_resp are not changed, so older providers
continue to use the write command path.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
MAINTAINERS | 1 +
drivers/infiniband/hw/ionic/ionic_admin.c | 2 +-
.../infiniband/hw/ionic/ionic_controlpath.c | 56 +++++++++++++++----
drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++++++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +
include/uapi/rdma/ionic-abi.h | 3 +
include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 +++++
7 files changed, 83 insertions(+), 13 deletions(-)
create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 222b7fc2c3aa..9d79cea2ab84 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1293,6 +1293,7 @@ S: Maintained
F: Documentation/networking/device_drivers/ethernet/pensando/ionic_rdma.rst
F: drivers/infiniband/hw/ionic/
F: include/uapi/rdma/ionic-abi.h
+F: include/uapi/rdma/ionic_user_ioctl_cmds.h
AMD PMC DRIVER
M: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c
index 859893568538..ae2a67daa9e8 100644
--- a/drivers/infiniband/hw/ionic/ionic_admin.c
+++ b/drivers/infiniband/hw/ionic/ionic_admin.c
@@ -575,7 +575,7 @@ static struct ionic_vcq *ionic_create_rdma_admincq(struct ionic_ibdev *dev,
vcq->udma_mask = 1;
cq = &vcq->cq[0];
- rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL,
+ rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL, NULL,
NULL, 0);
if (rc)
goto err_init;
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 3abb8c01daf6..c3a47aa108e4 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -76,23 +76,42 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid)
ionic_resid_put(&dev->inuse_cqid, bitid);
}
+static const u16 ionic_cq_buf_attrs[] = {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq,
- const struct ionic_qdesc *req_cq)
+ const struct ionic_qdesc *req_cq,
+ const struct uverbs_attr_bundle *attrs,
+ int udma_idx)
{
struct ib_umem *umem;
int rc;
+ if (udma_idx < 0 || udma_idx >= ARRAY_SIZE(ionic_cq_buf_attrs))
+ return -EINVAL;
+
rc = ionic_validate_qdesc(req_cq);
if (rc)
return rc;
- umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr,
- req_cq->size, IB_ACCESS_LOCAL_WRITE);
+ umem = ib_umem_get_attr(&dev->ibdev, attrs,
+ ionic_cq_buf_attrs[udma_idx], req_cq->size,
+ IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(umem))
return PTR_ERR(umem);
- /* The ring is given to the device as whole pages */
- if (ib_umem_offset(umem)) {
+ if (!umem) {
+ umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
+ req_cq->addr, req_cq->size,
+ IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+ }
+
+ /* The device is given whole pages, and only those of the ring */
+ if (umem->length != req_cq->size || ib_umem_offset(umem)) {
ib_umem_release(umem);
return -EINVAL;
}
@@ -106,6 +125,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx)
{
@@ -134,7 +154,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
INIT_LIST_HEAD(&cq->flush_rq);
if (udata) {
- rc = ionic_cq_get_user_umem(dev, cq, req_cq);
+ rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
if (rc)
goto err_qdesc;
@@ -448,7 +468,8 @@ int ionic_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
resp.udma_count = dev->lif_cfg.udma_count;
resp.expdb_mask = dev->lif_cfg.expdb_mask;
resp.rcq_sign_bit = dev->lif_cfg.rcq_sign_bit;
- resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS;
+ resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS |
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM;
if (dev->lif_cfg.sq_expdb)
resp.expdb_qtypes |= IONIC_EXPDB_SQ;
@@ -1393,7 +1414,7 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ionic_vcq *vcq = to_ionic_vcq(ibcq);
struct ionic_tbl_buf buf = {};
struct ionic_cq_resp resp = {};
- struct ionic_cq_req req;
+ struct ionic_cq_req req = {};
int udma_idx = 0, rc;
if (udata) {
@@ -1412,13 +1433,24 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
goto err_init;
}
- for (; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
+ for (udma_idx = 0; udma_idx < ARRAY_SIZE(ionic_cq_buf_attrs);
+ udma_idx++) {
+ if (vcq->udma_mask & BIT(udma_idx))
+ continue;
+
+ if (uverbs_attr_is_valid(attrs, ionic_cq_buf_attrs[udma_idx])) {
+ rc = -EINVAL;
+ udma_idx = 0;
+ goto err_init;
+ }
+ }
+
+ for (udma_idx = 0; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
if (!(vcq->udma_mask & BIT(udma_idx)))
continue;
- rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata,
- &req.cq[udma_idx],
- udma_idx);
+ rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata, attrs,
+ &req.cq[udma_idx], udma_idx);
if (rc)
goto err_init;
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c
index b4d4544bb7ac..e64c8e891f30 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.c
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c
@@ -11,6 +11,9 @@
#include "ionic_ibdev.h"
+#define UVERBS_MODULE_NAME ionic_rdma
+#include <rdma/uverbs_named_ioctl.h>
+
#define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver"
#define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA"
@@ -217,6 +220,18 @@ static void ionic_disassociate_ucontext(struct ib_ucontext *ibcontext)
*/
}
+ADD_UVERBS_ATTRIBUTES_SIMPLE(
+ ionic_cq_create,
+ UVERBS_OBJECT_CQ,
+ UVERBS_METHOD_CQ_CREATE,
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0, UA_OPTIONAL),
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, UA_OPTIONAL));
+
+static const struct uapi_definition ionic_uapi_defs[] = {
+ UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_CQ, &ionic_cq_create),
+ {},
+};
+
static const struct ib_device_ops ionic_dev_ops = {
.owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_IONIC,
@@ -376,6 +391,8 @@ static struct ionic_ibdev *ionic_create_ibdev(struct ionic_aux_dev *ionic_adev)
ionic_stats_init(dev);
+ ibdev->driver_def = ionic_uapi_defs;
+
rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent);
if (rc)
goto err_register;
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index 8e7e52c9f492..6cf8bad98672 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -10,6 +10,7 @@
#include <rdma/uverbs_ioctl.h>
#include <rdma/ionic-abi.h>
+#include <rdma/ionic_user_ioctl_cmds.h>
#include <ionic_api.h>
#include <ionic_regs.h>
@@ -490,6 +491,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx);
int ionic_post_create_cq_cmd(struct ionic_cq *cq,
diff --git a/include/uapi/rdma/ionic-abi.h b/include/uapi/rdma/ionic-abi.h
index ac48fcd19a4f..f499f083059c 100644
--- a/include/uapi/rdma/ionic-abi.h
+++ b/include/uapi/rdma/ionic-abi.h
@@ -24,6 +24,9 @@
enum ionic_ctx_resp_comp_mask {
IONIC_CTX_CMASK_IONIC_FLAGS = 1 << 0,
+ IONIC_CTX_CMASK_UDP_SPORT = 1 << 1,
+ IONIC_CTX_CMASK_CQ_NOTIFY_IOCTL = 1 << 2,
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM = 1 << 3,
};
struct ionic_ctx_req {
diff --git a/include/uapi/rdma/ionic_user_ioctl_cmds.h b/include/uapi/rdma/ionic_user_ioctl_cmds.h
new file mode 100644
index 000000000000..98bb8d7238e6
--- /dev/null
+++ b/include/uapi/rdma/ionic_user_ioctl_cmds.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* Copyright (C) 2026, Advanced Micro Devices, Inc */
+
+#ifndef IONIC_USER_IOCTL_CMDS_H
+#define IONIC_USER_IOCTL_CMDS_H
+
+#include <linux/types.h>
+#include <rdma/ib_user_ioctl_cmds.h>
+
+enum ionic_ib_create_cq_attrs {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 = UVERBS_ID_DRIVER_NS_WITH_UHW,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
+#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
` (2 preceding siblings ...)
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
2026-12-03 11:32 ` sashiko-bot
2026-12-03 11:32 ` [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as " sashiko-bot
4 siblings, 1 reply; 8+ messages in thread
From: Abhijit Gangurde @ 2026-12-03 11:08 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [for-next v4 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
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:31 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-12-03 11:31 UTC (permalink / raw)
To: Abhijit Gangurde; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] RDMA/ionic: missing dma-buf SG alignment check in
ionic_cq_get_user_umem()
- [Low] RDMA/ionic: unimplemented UAPI comp_mask bits added in
ionic-abi.h
- [Low] RDMA/ionic: ionic_alloc_ucontext() sets CQ/QP umem flag before
QP support
- [Low] RDMA/ionic: add unused, undocumented UAPI comp_mask flags in
ionic-abi.h
--
commit e6e85a53b2db04807e567070469fd5988b9bfc26
Author: Abhijit Gangurde <abhijit.gangurde@amd.com>
RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
This commit allows userspace to pass per-UDMA CQ ring buffers as ioctl umem
attributes via ib_umem_get_attr() and advertises support with
IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in the ucontext response.
> diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> index 3abb8c01daf6b..c3a47aa108e44 100644
> --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
> +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> @@ -76,23 +76,42 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid)
[ ... ]
> - umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr,
> - req_cq->size, IB_ACCESS_LOCAL_WRITE);
> + umem = ib_umem_get_attr(&dev->ibdev, attrs,
> + ionic_cq_buf_attrs[udma_idx], req_cq->size,
> + IB_ACCESS_LOCAL_WRITE);
> if (IS_ERR(umem))
> return PTR_ERR(umem);
>
> - /* The ring is given to the device as whole pages */
> - if (ib_umem_offset(umem)) {
> + if (!umem) {
> + umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
> + req_cq->addr, req_cq->size,
> + IB_ACCESS_LOCAL_WRITE);
> + if (IS_ERR(umem))
> + return PTR_ERR(umem);
> + }
> +
> + /* The device is given whole pages, and only those of the ring */
> + if (umem->length != req_cq->size || ib_umem_offset(umem)) {
> ib_umem_release(umem);
> return -EINVAL;
> }
[Severity: High]
Does this validate scatterlist DMA alignment and contiguity for dma-buf CQ
rings?
ib_umem_get_attr() can return a dma-buf umem, where ib_umem_offset() only
checks the logical byte offset in the dma-buf rather than the scatterlist
DMA addresses or interior segment boundaries. When a dma-buf exporter
produces scatterlist entries not aligned to host PAGE_SIZE (for example,
4KB-aligned GPU VRAM on a 16KB or 64KB PAGE_SIZE host),
ionic_create_cq_common() passes cq->umem straight to
ionic_pgtbl_init(..., PAGE_SIZE).
In ionic_pgtbl_umem(), rdma_umem_for_each_dma_block() masks unaligned DMA
addresses down to PAGE_SIZE and collapses discontinuous sub-PAGE_SIZE
segments into one entry, causing the NIC to DMA-write CQEs outside the
exported dma-buf. Validating the umem with ib_umem_find_best_pgsz(), as
ionic_reg_user_mr_dmabuf() does, would reject unaligned or discontinuous
scatterlists.
[ ... ]
> @@ -448,7 +468,8 @@ int ionic_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
> resp.udma_count = dev->lif_cfg.udma_count;
> resp.expdb_mask = dev->lif_cfg.expdb_mask;
> resp.rcq_sign_bit = dev->lif_cfg.rcq_sign_bit;
> - resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS;
> + resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS |
> + IONIC_CTX_CMASK_CQ_QP_BUF_UMEM;
>
> if (dev->lif_cfg.sq_expdb)
> resp.expdb_qtypes |= IONIC_EXPDB_SQ;
[Severity: Low]
Should IONIC_CTX_CMASK_CQ_QP_BUF_UMEM wait until QP ring umem attributes
are handled?
At this commit, UVERBS_METHOD_QP_CREATE in the RDMA core already accepts
optional UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and
UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM attributes, so a userspace provider that
trusts IONIC_CTX_CMASK_CQ_QP_BUF_UMEM will reach ionic_create_qp(). Since
ionic_get_user_q_umem() still ignores those attributes and pins q->addr via
ib_umem_get_va(), QP creation fails with -EFAULT when q->addr is zero.
QP SQ and RQ umem attribute handling is added in the following patch,
commit "RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes", so
deferring this flag to that commit would keep the series bisectable.
[ ... ]
> diff --git a/include/uapi/rdma/ionic-abi.h b/include/uapi/rdma/ionic-abi.h
> index ac48fcd19a4f7..f499f083059c6 100644
> --- a/include/uapi/rdma/ionic-abi.h
> +++ b/include/uapi/rdma/ionic-abi.h
> @@ -24,6 +24,9 @@
>
> enum ionic_ctx_resp_comp_mask {
> IONIC_CTX_CMASK_IONIC_FLAGS = 1 << 0,
> + IONIC_CTX_CMASK_UDP_SPORT = 1 << 1,
> + IONIC_CTX_CMASK_CQ_NOTIFY_IOCTL = 1 << 2,
> + IONIC_CTX_CMASK_CQ_QP_BUF_UMEM = 1 << 3,
> };
>
> struct ionic_ctx_req {
[Severity: Low]
Are IONIC_CTX_CMASK_UDP_SPORT and IONIC_CTX_CMASK_CQ_NOTIFY_IOCTL meant to
be added here?
Neither flag is set or referenced anywhere in drivers/infiniband/hw/ionic/
through the end of the series, and the commit message does not mention
them. Since UAPI enum names become permanent ABI once merged,
unimplemented enumerators should be omitted; if bits 1 and 2 must remain
skipped for userspace ABI compatibility, noting that in the commit message
without exposing unimplemented names would avoid dead UAPI symbols.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203110805.2577721-1-abhijit.gangurde@amd.com?part=3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
2026-12-03 11:08 ` [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
@ 2026-12-03 11:32 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-12-03 11:32 UTC (permalink / raw)
To: Abhijit Gangurde; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] RDMA/ionic: IONIC_CTX_CMASK_CQ_QP_BUF_UMEM advertised before
QP UMEM support
--
commit 4841c6bccd16b459b89d301915faa2eb394b51fd
Author: Abhijit Gangurde <abhijit.gangurde@amd.com>
RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
This commit updates ionic_get_user_q_umem() to pin QP SQ and RQ rings
from the UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and
UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM ioctl attributes when present, falling
back to the qdesc virtual address otherwise.
> 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.
[Severity: Medium]
Should enabling IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in ionic_alloc_ucontext()
be moved from commit "RDMA/ionic: Accept CQ ring buffers as ioctl umem
attributes" into this commit?
The preceding commit already sets IONIC_CTX_CMASK_CQ_QP_BUF_UMEM while
ionic_get_user_q_umem() still pins q->addr with ib_umem_get_va(). On
that commit, userspace passing QP rings via ioctl attributes with zero
qdesc addresses fails QP creation with -EFAULT, breaking bisectability.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203110805.2577721-1-abhijit.gangurde@amd.com?part=4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
` (3 preceding siblings ...)
2026-12-03 11:08 ` [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
@ 2026-12-03 11:32 ` sashiko-bot
4 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-12-03 11:32 UTC (permalink / raw)
To: Abhijit Gangurde; +Cc: linux-rdma
Sashiko has finished reviewing this 4-patch series:
- Patches 1 and 2: no issues found.
- Patch 3 ("RDMA/ionic: Accept CQ ring buffers as ioctl umem att..."): 4
potential issues (1 High, 3 Low)
- Patch 4 ("RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem..."): 1
potential issue (1 Medium)
Detailed reviews have been sent as separate replies to patches 3 and 4.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203110805.2577721-1-abhijit.gangurde@amd.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-03 11:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 11:08 [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes 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:31 ` sashiko-bot
2026-12-03 11:08 ` [for-next v4 4/4] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
2026-12-03 11:32 ` sashiko-bot
2026-12-03 11:32 ` [for-next v4 0/4] RDMA/ionic: Accept CQ, SQ, and RQ rings as " sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox