Skip to contentSkip to conversation

RDMA/irdma: Fix PBLE_LEVEL_2 FRWR generation

PATCH Applied Jacob Moroni 3 participants 3 messages Oct 16 – Oct 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/irdma: Fix PBLE_LEVEL_2 FRWR generation

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")
---
 drivers/infiniband/hw/irdma/verbs.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +16 -4
index 71d7ae7baa47..2178fb344e4d 100644
@@ -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;
Signature · 1 line
2.56.0.176.g3575e65682-goog
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines

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.

Quoted 8 lines

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")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Jacob Moroni
Quoted 8 lines · Jacob Moroni

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.

[...]

Applied, thanks!

[1/1] RDMA/irdma: Fix PBLE_LEVEL_2 FRWR generation

      https://git.kernel.org/rdma/rdma/c/9ffd2aa8b53b04

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>