[PATCH rdma-next] RDMA/bnxt_re: Limit SRQ depth to the firmware command field

From: Leon Romanovsky

Date: Tue Sep 15 2026 - 09:37:36 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

Firmware can report an SRQ depth above 16 bits, but CREATE_SRQ carries the
allocated depth in a 16-bit field. Requests near the advertised limit can
therefore truncate the command value and make firmware use a different
depth than the allocated queue.

Cap usable work requests so the reserved empty-ring entry still fits in the
command field. Accept the capped maximum and correct the associated
diagnostic.

Fixes: 37cb11acf1f7 ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters")
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++--
drivers/infiniband/hw/bnxt_re/qplib_sp.c | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index ef08d42f377e..43ff3e7a459f 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -2229,8 +2229,8 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
dev_attr = rdev->dev_attr;
srq = container_of(ib_srq, struct bnxt_re_srq, ib_srq);

- if (srq_init_attr->attr.max_wr >= dev_attr->max_srq_wqes) {
- ibdev_err(&rdev->ibdev, "Create CQ failed - max exceeded");
+ if (srq_init_attr->attr.max_wr > dev_attr->max_srq_wqes) {
+ ibdev_err(&rdev->ibdev, "Create SRQ failed - max exceeded");
rc = -EINVAL;
goto exit;
}
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
index ec9eb52a8ebf..63dcbb9d80f4 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
@@ -159,7 +159,8 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw)
attr->max_ah = le32_to_cpu(sb->max_ah);

attr->max_srq = le16_to_cpu(sb->max_srq);
- attr->max_srq_wqes = le32_to_cpu(sb->max_srq_wr) - 1;
+ attr->max_srq_wqes = min_t(u32, le32_to_cpu(sb->max_srq_wr),
+ U16_MAX) - 1;
attr->max_srq_sges = sb->max_srq_sge;
attr->max_pkey = 1;
attr->max_inline_data = attr->max_qp_sges * sizeof(struct sq_sge);

---
base-commit: f7d28791433d373ecdab7b00f60ddb504e858e0a
change-id: 20260915-silent-16-bit-truncation-of-srq-size-a1495f0bf133

Best regards,
--
Leon Romanovsky <leonro@xxxxxxxxxx>