mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [for-next 1/3] RDMA/ionic: size the MR PTE reservation to max_sg
@ 2026-10-27  9:23 Abhijit Gangurde
  2026-10-27  9:23 ` [for-next 2/3] RDMA/ionic: set the SQ WQE color bit Abhijit Gangurde
  2026-10-27  9:23 ` [for-next 3/3] RDMA/ionic: key recv completions by producer index Abhijit Gangurde
  0 siblings, 2 replies; 3+ messages in thread
From: Abhijit Gangurde @ 2026-10-27  9:23 UTC (permalink / raw)
  To: jgg, leon
  Cc: allen.hubbe, a.k, nikhil.agarwal, linux-rdma, linux-kernel,
	Abhijit Gangurde

From: Amit Kumar <a.k@amd.com>

CREATE_MR with map_count zero makes firmware reserve its default number
of PTEs. A fast-registration memory region (MR) whose max_sg is larger
than that default fails at REG_MR.

Pass max_sg as map_count. The virtual address (VA) and length stay zero
because no buffer is mapped yet.

Fixes: e8521822c733 ("RDMA/ionic: Register device ops for control path")
Signed-off-by: Amit Kumar <a.k@amd.com>
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
 .../infiniband/hw/ionic/ionic_controlpath.c    | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 18ad967812f5..00f9086f3bab 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -1121,21 +1121,25 @@ struct ib_mr *ionic_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type type,
 
 	mr->flags = IONIC_MRF_PHYS_MR;
 
-	rc = ionic_pgtbl_init(dev, &mr->buf, mr->umem, 0, max_sg, PAGE_SIZE);
+	mr->buf.tbl_pages = max_sg;
+	rc = ionic_create_mr_cmd(dev, pd, mr, 0, 0);
+	if (rc)
+		goto err_cmd;
+
+	rc = ionic_pgtbl_init(dev, &mr->buf, NULL, 0, max_sg, 0);
 	if (rc)
 		goto err_pgtbl;
 
+	/* NIC reservation was already posted. tbl_pages means "mapped". */
 	mr->buf.tbl_pages = 0;
 
-	rc = ionic_create_mr_cmd(dev, pd, mr, 0, 0);
-	if (rc)
-		goto err_cmd;
-
 	return &mr->ibmr;
 
-err_cmd:
-	ionic_pgtbl_unbuf(dev, &mr->buf);
 err_pgtbl:
+	/* Keep the id if the NIC still holds the MR. */
+	if (ionic_destroy_mr_cmd(dev, mr->mrid))
+		goto err_mrid;
+err_cmd:
 	ionic_put_mrid(dev, mr->mrid);
 err_mrid:
 	kfree(mr);
-- 
2.43.0


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

* [for-next 2/3] RDMA/ionic: set the SQ WQE color bit
  2026-10-27  9:23 [for-next 1/3] RDMA/ionic: size the MR PTE reservation to max_sg Abhijit Gangurde
@ 2026-10-27  9:23 ` Abhijit Gangurde
  2026-10-27  9:23 ` [for-next 3/3] RDMA/ionic: key recv completions by producer index Abhijit Gangurde
  1 sibling, 0 replies; 3+ messages in thread
From: Abhijit Gangurde @ 2026-10-27  9:23 UTC (permalink / raw)
  To: jgg, leon
  Cc: allen.hubbe, a.k, nikhil.agarwal, linux-rdma, linux-kernel,
	Abhijit Gangurde

From: Amit Kumar <a.k@amd.com>

The NIC uses the WQE color bit to tell one pass of the send queue
from the next. Userspace sets IONIC_V1_FLAG_COLOR and toggles it when
prod wraps. Do the same for kernel send queues, and start again at
the initial color when a QP reset returns prod to zero.

Signed-off-by: Amit Kumar <a.k@amd.com>
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
 drivers/infiniband/hw/ionic/ionic_controlpath.c | 3 +++
 drivers/infiniband/hw/ionic/ionic_datapath.c    | 4 ++++
 drivers/infiniband/hw/ionic/ionic_fw.h          | 1 +
 drivers/infiniband/hw/ionic/ionic_ibdev.h       | 1 +
 4 files changed, 9 insertions(+)

diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 00f9086f3bab..1738635bacf4 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -1949,6 +1949,8 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
 		return rc;
 	}
 
+	qp->sq_color = true;
+
 	rc = -EINVAL;
 
 	if (max_wr < 0 || max_wr > 0xffff)
@@ -2662,6 +2664,7 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp)
 		qp->sq_msn_cons = 0;
 		qp->sq.prod = 0;
 		qp->sq.cons = 0;
+		qp->sq_color = true;
 		spin_unlock(&qp->sq_lock);
 	}
 
diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
index c5726c6bd5cb..422e53e21054 100644
--- a/drivers/infiniband/hw/ionic/ionic_datapath.c
+++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
@@ -820,6 +820,9 @@ static void ionic_prep_base(struct ionic_qp *qp,
 
 	wqe->base.wqe_idx = cpu_to_le64(qp->sq.prod);
 
+	if (qp->sq_color)
+		wqe->base.flags |= cpu_to_be16(IONIC_V1_FLAG_COLOR);
+
 	if (wr->send_flags & IB_SEND_FENCE)
 		wqe->base.flags |= cpu_to_be16(IONIC_V1_FLAG_FENCE);
 
@@ -843,6 +846,7 @@ static void ionic_prep_base(struct ionic_qp *qp,
 	}
 
 	ionic_queue_produce(&qp->sq);
+	qp->sq_color = ionic_color_wrap(qp->sq.prod, qp->sq_color);
 }
 
 static int ionic_prep_common(struct ionic_qp *qp,
diff --git a/drivers/infiniband/hw/ionic/ionic_fw.h b/drivers/infiniband/hw/ionic/ionic_fw.h
index 1db67fcb9a53..b8e996d4b8b9 100644
--- a/drivers/infiniband/hw/ionic/ionic_fw.h
+++ b/drivers/infiniband/hw/ionic/ionic_fw.h
@@ -532,6 +532,7 @@ enum ionic_v1_op {
 	IONIC_V1_FLAG_SOL		= BIT(1),
 	IONIC_V1_FLAG_INL		= BIT(2),
 	IONIC_V1_FLAG_SIG		= BIT(3),
+	IONIC_V1_FLAG_COLOR		= BIT(4),
 
 	/* flags last four bits for sgl spec format */
 	IONIC_V1_FLAG_SPEC32		= (1u << 12),
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index f8d580dd4d95..cf4b85355f26 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -306,6 +306,7 @@ struct ionic_qp {
 	u8			sq_cmb;
 	bool			sq_flush;
 	bool			sq_flush_rcvd;
+	bool			sq_color;
 
 	struct ionic_rq		rq;
 
-- 
2.43.0


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

* [for-next 3/3] RDMA/ionic: key recv completions by producer index
  2026-10-27  9:23 [for-next 1/3] RDMA/ionic: size the MR PTE reservation to max_sg Abhijit Gangurde
  2026-10-27  9:23 ` [for-next 2/3] RDMA/ionic: set the SQ WQE color bit Abhijit Gangurde
@ 2026-10-27  9:23 ` Abhijit Gangurde
  1 sibling, 0 replies; 3+ messages in thread
From: Abhijit Gangurde @ 2026-10-27  9:23 UTC (permalink / raw)
  To: jgg, leon
  Cc: allen.hubbe, a.k, nikhil.agarwal, linux-rdma, linux-kernel,
	Abhijit Gangurde

The recv completion's wqe_idx is the RQ producer index. Store the
wr_id at that slot and write the same index into the posted WQE. A
posted flag on the slot rejects a completion for a recv that is not
outstanding.

Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
 .../infiniband/hw/ionic/ionic_controlpath.c   | 19 ++++-----------
 drivers/infiniband/hw/ionic/ionic_datapath.c  | 24 +++++++++----------
 drivers/infiniband/hw/ionic/ionic_ibdev.h     |  6 +----
 3 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 1738635bacf4..8a0a1575a339 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -2195,8 +2195,8 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
 			 struct ionic_tbl_buf *buf, int max_wr, int max_sge,
 			 int rq_spec, struct ib_udata *udata)
 {
-	int rc = 0, i;
 	u32 wqe_size;
+	int rc = 0;
 
 	rc = -EINVAL;
 
@@ -2258,16 +2258,11 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
 
 		ionic_queue_dbell_init(&rq->q, rq->qid);
 
-		rq->meta = kmalloc_objs(*rq->meta, (u32)rq->q.mask + 1);
+		rq->meta = kzalloc_objs(*rq->meta, (u32)rq->q.mask + 1);
 		if (!rq->meta) {
 			rc = -ENOMEM;
 			goto err_rq_meta;
 		}
-
-		for (i = 0; i < rq->q.mask; ++i)
-			rq->meta[i].next = &rq->meta[i + 1];
-		rq->meta[i].next = IONIC_META_LAST;
-		rq->meta_head = &rq->meta[0];
 	}
 
 	ionic_rq_init_cmb(dev, rq, udata);
@@ -2638,7 +2633,6 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp)
 {
 	unsigned long irqflags;
 	struct ionic_cq *cq;
-	int i;
 
 	local_irq_save(irqflags);
 
@@ -2673,12 +2667,9 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp)
 		qp->rq.flush = false;
 		qp->rq.q.prod = 0;
 		qp->rq.q.cons = 0;
-		if (qp->rq.meta) {
-			for (i = 0; i < qp->rq.q.mask; ++i)
-				qp->rq.meta[i].next = &qp->rq.meta[i + 1];
-			qp->rq.meta[i].next = IONIC_META_LAST;
-		}
-		qp->rq.meta_head = &qp->rq.meta[0];
+		if (qp->rq.meta)
+			memset(qp->rq.meta, 0,
+			       (qp->rq.q.mask + 1) * sizeof(*qp->rq.meta));
 		spin_unlock(&qp->rq.lock);
 	}
 
diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
index 422e53e21054..f1354dae089c 100644
--- a/drivers/infiniband/hw/ionic/ionic_datapath.c
+++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
@@ -53,7 +53,7 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ib_wc *wc)
 
 	/* wqe_idx must indicate a request that is outstanding */
 	meta = &qp->rq.meta[wqe_idx];
-	if (unlikely(meta->next != IONIC_META_POSTED)) {
+	if (unlikely(!meta->posted)) {
 		ibdev_warn(qp->ibqp.device,
 			   "flush qp %u recv index %llu not posted\n",
 			   qp->qpid, (unsigned long long)wqe_idx);
@@ -68,8 +68,7 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ib_wc *wc)
 	wc->wr_id = meta->wrid;
 	wc->qp = &qp->ibqp;
 
-	meta->next = qp->rq.meta_head;
-	qp->rq.meta_head = meta;
+	meta->posted = false;
 
 	return 1;
 }
@@ -172,14 +171,13 @@ static int ionic_poll_recv(struct ionic_ibdev *dev, struct ionic_cq *cq,
 
 	/* wqe_idx must indicate a request that is outstanding */
 	meta = &qp->rq.meta[wqe_idx];
-	if (unlikely(meta->next != IONIC_META_POSTED)) {
+	if (unlikely(!meta->posted)) {
 		ibdev_warn(&dev->ibdev,
 			   "qp %u recv index %u not posted\n", qp->qpid, wqe_idx);
 		return -EIO;
 	}
 
-	meta->next = qp->rq.meta_head;
-	qp->rq.meta_head = meta;
+	meta->posted = false;
 
 	memset(wc, 0, sizeof(*wc));
 
@@ -1199,9 +1197,12 @@ static int ionic_prep_recv(struct ionic_qp *qp,
 	if (wqe->base.flags & cpu_to_be16(IONIC_V1_FLAG_FENCE))
 		return -EAGAIN;
 
-	meta = qp->rq.meta_head;
-	if (unlikely(meta == IONIC_META_LAST) ||
-	    unlikely(meta == IONIC_META_POSTED))
+	/*
+	 * The completion carries this producer index, so the wr_id
+	 * lives in the meta slot at the same index.
+	 */
+	meta = &qp->rq.meta[qp->rq.q.prod];
+	if (unlikely(meta->posted))
 		return -EIO;
 
 	ionic_prep_rq_wqe(qp, wqe);
@@ -1216,7 +1217,7 @@ static int ionic_prep_recv(struct ionic_qp *qp,
 
 	meta->wrid = wr->wr_id;
 
-	wqe->base.wqe_idx = cpu_to_le64(meta - qp->rq.meta);
+	wqe->base.wqe_idx = cpu_to_le64(qp->rq.q.prod);
 	wqe->base.num_sge_key = wr->num_sge;
 
 	/* total length for recv goes in base imm_data_key */
@@ -1224,8 +1225,7 @@ static int ionic_prep_recv(struct ionic_qp *qp,
 
 	ionic_queue_produce(&qp->rq.q);
 
-	qp->rq.meta_head = meta->next;
-	meta->next = IONIC_META_POSTED;
+	meta->posted = true;
 
 	return 0;
 }
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index cf4b85355f26..127b79cdfc45 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -40,9 +40,6 @@
 #define IONIC_MAX_SRQ_LIMIT	0xffff
 #define IONIC_MAX_SRQ_DEPTH	0xffff
 
-#define IONIC_META_LAST		((void *)1ul)
-#define IONIC_META_POSTED	((void *)2ul)
-
 #define IONIC_CQ_GRACE 100
 
 #define IONIC_ROCE_UDP_SPORT	28272
@@ -242,8 +239,8 @@ struct ionic_sq_meta {
 };
 
 struct ionic_rq_meta {
-	struct ionic_rq_meta	*next;
 	u64			wrid;
+	bool			posted;
 };
 
 struct ionic_rq {
@@ -257,7 +254,6 @@ struct ionic_rq {
 	struct rdma_user_mmap_entry	*mmap_cmb;
 
 	struct ionic_rq_meta		*meta;
-	struct ionic_rq_meta		*meta_head;
 	struct ib_umem			*umem;
 
 	int				spec;
-- 
2.43.0


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

end of thread, other threads:[~2026-10-27  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27  9:23 [for-next 1/3] RDMA/ionic: size the MR PTE reservation to max_sg Abhijit Gangurde
2026-10-27  9:23 ` [for-next 2/3] RDMA/ionic: set the SQ WQE color bit Abhijit Gangurde
2026-10-27  9:23 ` [for-next 3/3] RDMA/ionic: key recv completions by producer index Abhijit Gangurde

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®