]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/bnxt_re: Fix allocation of QP table
authorKashyap Desai <kashyap.desai@broadcom.com>
Mon, 3 Mar 2025 16:59:36 +0000 (08:59 -0800)
committerLeon Romanovsky <leon@kernel.org>
Mon, 3 Mar 2025 19:18:04 +0000 (14:18 -0500)
Driver is creating QP table too early while probing before
querying firmware capabilities. Driver currently is using
a hard coded values of 64K as size while creating QP table.
This resulted in a crash when firmwre supported QP count is
more than 64K.

To fix the issue, move the QP tabel creation after the firmware
capabilities are queried. Use the firmware returned maximum value
of QPs while creating the QP table.

Fixes: b1b66ae094cd ("bnxt_en: Use FW defined resource limits for RoCE")
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Link: https://patch.msgid.link/1741021178-2569-2-git-send-email-selvin.xavier@broadcom.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/bnxt_re.h
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h
drivers/infiniband/hw/bnxt_re/qplib_res.c
drivers/infiniband/hw/bnxt_re/qplib_res.h

index 3721446c6ba4b0bdfaf705d56db8e9c12ef71dec..502a79136d4dfbe34d2753ca48d7b6c6f97d2f59 100644 (file)
 #define BNXT_RE_MAX_MR_SIZE_HIGH       BIT_ULL(39)
 #define BNXT_RE_MAX_MR_SIZE            BNXT_RE_MAX_MR_SIZE_HIGH
 
-#define BNXT_RE_MAX_QPC_COUNT          (64 * 1024)
-#define BNXT_RE_MAX_MRW_COUNT          (64 * 1024)
-#define BNXT_RE_MAX_SRQC_COUNT         (64 * 1024)
-#define BNXT_RE_MAX_CQ_COUNT           (64 * 1024)
-#define BNXT_RE_MAX_MRW_COUNT_64K      (64 * 1024)
-#define BNXT_RE_MAX_MRW_COUNT_256K     (256 * 1024)
 
 /* Number of MRs to reserve for PF, leaving remainder for VFs */
 #define BNXT_RE_RESVD_MR_FOR_PF         (32 * 1024)
index a94c8c5387d9e3f081da6e8b04a0ba0f4fb823c8..4659a2f7336444c73c2da5c13fc59fea7960deda 100644 (file)
@@ -2130,8 +2130,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
         * memory for the function and all child VFs
         */
        rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res, &rdev->rcfw,
-                                          &rdev->qplib_ctx,
-                                          BNXT_RE_MAX_QPC_COUNT);
+                                          &rdev->qplib_ctx);
        if (rc) {
                ibdev_err(&rdev->ibdev,
                          "Failed to allocate RCFW Channel: %#x\n", rc);
index 17e62f22683b14a3571188e25fe0df3cbf1d8360..d23074383428244db88fe4160499775111d985fe 100644 (file)
@@ -915,7 +915,6 @@ skip_ctx_setup:
 
 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
 {
-       kfree(rcfw->qp_tbl);
        kfree(rcfw->crsqe_tbl);
        bnxt_qplib_free_hwq(rcfw->res, &rcfw->cmdq.hwq);
        bnxt_qplib_free_hwq(rcfw->res, &rcfw->creq.hwq);
@@ -924,8 +923,7 @@ void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
 
 int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
                                  struct bnxt_qplib_rcfw *rcfw,
-                                 struct bnxt_qplib_ctx *ctx,
-                                 int qp_tbl_sz)
+                                 struct bnxt_qplib_ctx *ctx)
 {
        struct bnxt_qplib_hwq_attr hwq_attr = {};
        struct bnxt_qplib_sg_info sginfo = {};
@@ -969,12 +967,6 @@ int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
        if (!rcfw->crsqe_tbl)
                goto fail;
 
-       /* Allocate one extra to hold the QP1 entries */
-       rcfw->qp_tbl_size = qp_tbl_sz + 1;
-       rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
-                              GFP_KERNEL);
-       if (!rcfw->qp_tbl)
-               goto fail;
        spin_lock_init(&rcfw->tbl_lock);
 
        rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout;
index 88814cb3aa7413cd0ca2594de051f5fa9cf4a734..30e5e1871f642e9b4ae1fd2eed3f7e51456198e5 100644 (file)
@@ -262,8 +262,7 @@ static inline void bnxt_qplib_fill_cmdqmsg(struct bnxt_qplib_cmdqmsg *msg,
 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw);
 int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
                                  struct bnxt_qplib_rcfw *rcfw,
-                                 struct bnxt_qplib_ctx *ctx,
-                                 int qp_tbl_sz);
+                                 struct bnxt_qplib_ctx *ctx);
 void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill);
 void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw);
 int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
index 02922a0987ad7ac890d5364dbf92e8d8ff4716a3..6cd05207ffeddf56f63f94cf9776605aa99ad9e6 100644 (file)
@@ -871,6 +871,7 @@ int bnxt_qplib_init_res(struct bnxt_qplib_res *res)
 
 void bnxt_qplib_free_res(struct bnxt_qplib_res *res)
 {
+       kfree(res->rcfw->qp_tbl);
        bnxt_qplib_free_sgid_tbl(res, &res->sgid_tbl);
        bnxt_qplib_free_pd_tbl(&res->pd_tbl);
        bnxt_qplib_free_dpi_tbl(res, &res->dpi_tbl);
@@ -878,12 +879,20 @@ void bnxt_qplib_free_res(struct bnxt_qplib_res *res)
 
 int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct net_device *netdev)
 {
+       struct bnxt_qplib_rcfw *rcfw = res->rcfw;
        struct bnxt_qplib_dev_attr *dev_attr;
        int rc;
 
        res->netdev = netdev;
        dev_attr = res->dattr;
 
+       /* Allocate one extra to hold the QP1 entries */
+       rcfw->qp_tbl_size = max_t(u32, BNXT_RE_MAX_QPC_COUNT + 1, dev_attr->max_qp);
+       rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
+                              GFP_KERNEL);
+       if (!rcfw->qp_tbl)
+               return -ENOMEM;
+
        rc = bnxt_qplib_alloc_sgid_tbl(res, &res->sgid_tbl, dev_attr->max_sgid);
        if (rc)
                goto fail;
index 711990232de1c91a2bcaf87912c85c363757b2b3..2fb540f0e72717268806461809720075672f378f 100644 (file)
@@ -49,6 +49,13 @@ extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;
 #define CHIP_NUM_58818          0xd818
 #define CHIP_NUM_57608          0x1760
 
+#define BNXT_RE_MAX_QPC_COUNT          (64 * 1024)
+#define BNXT_RE_MAX_MRW_COUNT          (64 * 1024)
+#define BNXT_RE_MAX_SRQC_COUNT         (64 * 1024)
+#define BNXT_RE_MAX_CQ_COUNT           (64 * 1024)
+#define BNXT_RE_MAX_MRW_COUNT_64K      (64 * 1024)
+#define BNXT_RE_MAX_MRW_COUNT_256K     (256 * 1024)
+
 #define BNXT_QPLIB_DBR_VALID           (0x1UL << 26)
 #define BNXT_QPLIB_DBR_EPOCH_SHIFT     24
 #define BNXT_QPLIB_DBR_TOGGLE_SHIFT    25