Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jacob Moroni <jmoroni@google.com>
To: tatyana.e.nikolova@intel.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, Jacob Moroni <jmoroni@google.com>
Subject: [PATCH rdma-next 3/4] RDMA/irdma: Fix CQ scrub for SRQ associated QPs
Date: Fri,  6 Nov 2026 22:11:59 +0000	[thread overview]
Message-ID: <20261106221201.2266301-4-jmoroni@google.com> (raw)
In-Reply-To: <20261106221201.2266301-1-jmoroni@google.com>

When a QP is destroyed, any pending completions for it are
scrubbed by setting the QP handle to NULL so that the CQE
is skipped during poll. However, completions for SRQ WQEs
use a different offset (40 rather than 8) for the QP handle
but the driver did not account for this.

Fix this by checking whether the CQE being scrubbed is for
an SRQ WQE and if so, clearing the correct offset.

Fixes: 563e1feb5f6e ("RDMA/irdma: Add SRQ support")
Signed-off-by: Jacob Moroni <jmoroni@google.com>
---
 drivers/infiniband/hw/irdma/uk.c   | 16 +++++++++++-----
 drivers/infiniband/hw/irdma/user.h |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/uk.c b/drivers/infiniband/hw/irdma/uk.c
index 800b51003e18..05f512b01525 100644
--- a/drivers/infiniband/hw/irdma/uk.c
+++ b/drivers/infiniband/hw/irdma/uk.c
@@ -1764,10 +1764,10 @@ void irdma_uk_cq_init(struct irdma_cq_uk *cq,
 
 /**
  * irdma_uk_clean_cq - clean cq entries
- * @q: completion context
+ * @qp: QP
  * @cq: cq to clean
  */
-void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq)
+void irdma_uk_clean_cq(struct irdma_qp_uk *qp, struct irdma_cq_uk *cq)
 {
 	__le64 *cqe;
 	u64 qword3, comp_ctx;
@@ -1790,9 +1790,15 @@ void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq)
 		/* Ensure CQE contents are read after valid bit is checked */
 		dma_rmb();
 
-		get_64bit_val(cqe, 8, &comp_ctx);
-		if ((void *)(unsigned long)comp_ctx == q)
-			set_64bit_val(cqe, 8, 0);
+		if (cq->avoid_mem_cflct && FIELD_GET(IRDMA_CQ_SRQ, qword3)) {
+			get_64bit_val(cqe, 40, &comp_ctx);
+			if ((struct irdma_qp_uk *)(unsigned long)comp_ctx == qp)
+				set_64bit_val(cqe, 40, 0);
+		} else {
+			get_64bit_val(cqe, 8, &comp_ctx);
+			if ((struct irdma_qp_uk *)(unsigned long)comp_ctx == qp)
+				set_64bit_val(cqe, 8, 0);
+		}
 
 		cq_head = (cq_head + 1) % cq->cq_ring.size;
 		if (!cq_head)
diff --git a/drivers/infiniband/hw/irdma/user.h b/drivers/infiniband/hw/irdma/user.h
index 4dd3776a4cdd..c7f115b28498 100644
--- a/drivers/infiniband/hw/irdma/user.h
+++ b/drivers/infiniband/hw/irdma/user.h
@@ -581,7 +581,7 @@ __le64 *irdma_qp_get_next_send_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx,
 				   struct irdma_post_sq_info *info);
 __le64 *irdma_srq_get_next_recv_wqe(struct irdma_srq_uk *srq, u32 *wqe_idx);
 __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx);
-void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq);
+void irdma_uk_clean_cq(struct irdma_qp_uk *qp, struct irdma_cq_uk *cq);
 int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq);
 int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta);
 int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size);
-- 
2.56.0.455.g6c5a503b38-goog


  parent reply	other threads:[~2026-11-06 22:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 22:11 [PATCH rdma-next 0/4] RDMA/irdma: Fix SRQ completion handling Jacob Moroni
2026-11-06 22:11 ` [PATCH rdma-next 1/4] RDMA/irdma: Fix QP handle assignment for SRQ completions Jacob Moroni
2026-11-06 22:21   ` sashiko-bot
2026-11-10 21:24   ` David Hu
2026-11-10 23:08     ` Jacob Moroni
2026-11-11 17:35       ` David Hu
2026-11-06 22:11 ` [PATCH rdma-next 2/4] RDMA/irdma: Check QP handle before decoding CQE errors Jacob Moroni
2026-11-06 22:22   ` sashiko-bot
2026-11-06 22:11 ` Jacob Moroni [this message]
2026-11-06 22:35   ` [PATCH rdma-next 3/4] RDMA/irdma: Fix CQ scrub for SRQ associated QPs sashiko-bot
2026-11-06 22:12 ` [PATCH rdma-next 4/4] RDMA/irdma: Release SRQ slots during CQ scrub Jacob Moroni
2026-11-06 22:30   ` sashiko-bot

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=20261106221201.2266301-4-jmoroni@google.com \
    --to=jmoroni@google.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=tatyana.e.nikolova@intel.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