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, metze@samba.org,
	 Jacob Moroni <jmoroni@google.com>
Subject: [PATCH] RDMA/irdma: Fix PBLE_LEVEL_2 FRWR generation
Date: Fri, 16 Oct 2026 18:09:01 +0000	[thread overview]
Message-ID: <20261016180901.3292775-1-jmoroni@google.com> (raw)

When an FRWR is posted with only 1 page mapped, it uses a
direct mapping, with the page-aligned DMA address provided
in the WQE (reg_addr_pa). This address is obtained by reading
it from the PBLE that was previously populated during ib_map_mr_sg(),
but it did not account for whether the original allocation was
PBLE_LEVEL_1 or PBLE_LEVEL_2 and just assumed it was always level 1.

As a result, it would program incorrect addresses if the MR was
originally allocated as PBLE_LEVEL_2.

Additionally, multi-page PBLE_LEVEL_2 FRWRs were also broken
because it was using the wrong chunk_size.

Fix these issues by correctly populating the stag_info fields
depending on whether it's a PBLE_LEVEL_1 or PBLE_LEVEL_2 MR and
whether more than 1 page has been mapped or not.

Tested with NFS over RDMA running various fio scenarios, with
and without a modified kernel to force it to take the PBLE_LEVEL_2
path.

Fixes: 137d264c6f63 ("RDMA/irdma: Add 2 level PBLE support for FMR")
Suggested-by: Stefan Metzmacher <metze@samba.org>
Link: https://lore.kernel.org/linux-rdma/20261012161135.494544-1-metze@samba.org/
Signed-off-by: Jacob Moroni <jmoroni@google.com>
---
 drivers/infiniband/hw/irdma/verbs.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 71d7ae7baa47..2178fb344e4d 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -4286,11 +4286,23 @@ static int irdma_post_send(struct ib_qp *ibqp,
 			stag_info.wr_id = ib_wr->wr_id;
 			stag_info.va = iwmr->ibmr.iova;
 			stag_info.total_len = iwmr->ibmr.length;
-			stag_info.reg_addr_pa = *palloc->level1.addr;
-			stag_info.first_pm_pbl_index = palloc->level1.idx;
 			stag_info.local_fence = true;
-			if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR)
-				stag_info.chunk_size = 1;
+			if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR) {
+				if (palloc->level == PBLE_LEVEL_1) {
+					stag_info.first_pm_pbl_index =
+						palloc->level1.idx;
+					stag_info.chunk_size = 1;
+				} else {
+					stag_info.first_pm_pbl_index =
+						palloc->level2.root.idx;
+					stag_info.chunk_size = 3;
+				}
+			} else {
+				stag_info.reg_addr_pa =
+					(palloc->level == PBLE_LEVEL_1) ?
+					*palloc->level1.addr :
+					*palloc->level2.leaf->addr;
+			}
 			err = irdma_sc_mr_fast_register(&iwqp->sc_qp,
 							&stag_info);
 			break;
-- 
2.56.0.176.g3575e65682-goog


             reply	other threads:[~2026-10-16 18:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 18:09 Jacob Moroni [this message]
2026-10-16 18:17 ` [PATCH] RDMA/irdma: Fix PBLE_LEVEL_2 FRWR generation 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=20261016180901.3292775-1-jmoroni@google.com \
    --to=jmoroni@google.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=metze@samba.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