[for-next 1/3] RDMA/ionic: size the MR PTE reservation to max_sg
From: Abhijit Gangurde
Date: Tue Oct 27 2026 - 05:29:38 EST
From: Amit Kumar <a.k@xxxxxxx>
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@xxxxxxx>
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@xxxxxxx>
---
.../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