Skip to content

Commit 82f1f57

Browse files
kadesai16rleon
authored andcommitted
RDMA/bnxt_re: Fix allocation of QP table
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: b1b66ae ("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>
1 parent 8ce2eb9 commit 82f1f57

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

drivers/infiniband/hw/bnxt_re/bnxt_re.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@
5353
#define BNXT_RE_MAX_MR_SIZE_HIGH BIT_ULL(39)
5454
#define BNXT_RE_MAX_MR_SIZE BNXT_RE_MAX_MR_SIZE_HIGH
5555

56-
#define BNXT_RE_MAX_QPC_COUNT (64 * 1024)
57-
#define BNXT_RE_MAX_MRW_COUNT (64 * 1024)
58-
#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
59-
#define BNXT_RE_MAX_CQ_COUNT (64 * 1024)
60-
#define BNXT_RE_MAX_MRW_COUNT_64K (64 * 1024)
61-
#define BNXT_RE_MAX_MRW_COUNT_256K (256 * 1024)
6256

6357
/* Number of MRs to reserve for PF, leaving remainder for VFs */
6458
#define BNXT_RE_RESVD_MR_FOR_PF (32 * 1024)

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,8 +2130,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
21302130
* memory for the function and all child VFs
21312131
*/
21322132
rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res, &rdev->rcfw,
2133-
&rdev->qplib_ctx,
2134-
BNXT_RE_MAX_QPC_COUNT);
2133+
&rdev->qplib_ctx);
21352134
if (rc) {
21362135
ibdev_err(&rdev->ibdev,
21372136
"Failed to allocate RCFW Channel: %#x\n", rc);

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,6 @@ int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw,
915915

916916
void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
917917
{
918-
kfree(rcfw->qp_tbl);
919918
kfree(rcfw->crsqe_tbl);
920919
bnxt_qplib_free_hwq(rcfw->res, &rcfw->cmdq.hwq);
921920
bnxt_qplib_free_hwq(rcfw->res, &rcfw->creq.hwq);
@@ -924,8 +923,7 @@ void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
924923

925924
int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
926925
struct bnxt_qplib_rcfw *rcfw,
927-
struct bnxt_qplib_ctx *ctx,
928-
int qp_tbl_sz)
926+
struct bnxt_qplib_ctx *ctx)
929927
{
930928
struct bnxt_qplib_hwq_attr hwq_attr = {};
931929
struct bnxt_qplib_sg_info sginfo = {};
@@ -969,12 +967,6 @@ int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
969967
if (!rcfw->crsqe_tbl)
970968
goto fail;
971969

972-
/* Allocate one extra to hold the QP1 entries */
973-
rcfw->qp_tbl_size = qp_tbl_sz + 1;
974-
rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
975-
GFP_KERNEL);
976-
if (!rcfw->qp_tbl)
977-
goto fail;
978970
spin_lock_init(&rcfw->tbl_lock);
979971

980972
rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout;

drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ static inline void bnxt_qplib_fill_cmdqmsg(struct bnxt_qplib_cmdqmsg *msg,
262262
void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw);
263263
int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
264264
struct bnxt_qplib_rcfw *rcfw,
265-
struct bnxt_qplib_ctx *ctx,
266-
int qp_tbl_sz);
265+
struct bnxt_qplib_ctx *ctx);
267266
void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill);
268267
void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw);
269268
int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,

drivers/infiniband/hw/bnxt_re/qplib_res.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,19 +871,28 @@ int bnxt_qplib_init_res(struct bnxt_qplib_res *res)
871871

872872
void bnxt_qplib_free_res(struct bnxt_qplib_res *res)
873873
{
874+
kfree(res->rcfw->qp_tbl);
874875
bnxt_qplib_free_sgid_tbl(res, &res->sgid_tbl);
875876
bnxt_qplib_free_pd_tbl(&res->pd_tbl);
876877
bnxt_qplib_free_dpi_tbl(res, &res->dpi_tbl);
877878
}
878879

879880
int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct net_device *netdev)
880881
{
882+
struct bnxt_qplib_rcfw *rcfw = res->rcfw;
881883
struct bnxt_qplib_dev_attr *dev_attr;
882884
int rc;
883885

884886
res->netdev = netdev;
885887
dev_attr = res->dattr;
886888

889+
/* Allocate one extra to hold the QP1 entries */
890+
rcfw->qp_tbl_size = max_t(u32, BNXT_RE_MAX_QPC_COUNT + 1, dev_attr->max_qp);
891+
rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
892+
GFP_KERNEL);
893+
if (!rcfw->qp_tbl)
894+
return -ENOMEM;
895+
887896
rc = bnxt_qplib_alloc_sgid_tbl(res, &res->sgid_tbl, dev_attr->max_sgid);
888897
if (rc)
889898
goto fail;

drivers/infiniband/hw/bnxt_re/qplib_res.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;
4949
#define CHIP_NUM_58818 0xd818
5050
#define CHIP_NUM_57608 0x1760
5151

52+
#define BNXT_RE_MAX_QPC_COUNT (64 * 1024)
53+
#define BNXT_RE_MAX_MRW_COUNT (64 * 1024)
54+
#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
55+
#define BNXT_RE_MAX_CQ_COUNT (64 * 1024)
56+
#define BNXT_RE_MAX_MRW_COUNT_64K (64 * 1024)
57+
#define BNXT_RE_MAX_MRW_COUNT_256K (256 * 1024)
58+
5259
#define BNXT_QPLIB_DBR_VALID (0x1UL << 26)
5360
#define BNXT_QPLIB_DBR_EPOCH_SHIFT 24
5461
#define BNXT_QPLIB_DBR_TOGGLE_SHIFT 25

0 commit comments

Comments
 (0)