RDMA/bnxt_re: Fix QP table fixes
Subsystems (2)
Selvin Xavier
maintainercover RDMA/bnxt_re: Fix QP table fixes
This series fixes couple issues with the QP table
allocation/teardown.
Please review and apply
Thanks,
Selvin Xavier
Abhishek Mohapatra (1):
RDMA/bnxt_re: Use kvzalloc for QP table allocation
Selvin Xavier (1):
RDMA/bnxt_re: Unpublish QP table before freeing it
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 4 ++++ drivers/infiniband/hw/bnxt_re/qplib_res.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.3
Selvin Xavier
maintainerPATCH 1/2 RDMA/bnxt_re: Use kvzalloc for QP table allocation
From: Abhishek Mohapatra <[email protected]>
The QP table size depends on the firmware reported max_qp, so it can be large and a physically contiguous kzalloc may fail. Use kvzalloc_objs() and free it with kvfree().
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +3 -3
@@ -909,7 +909,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); +kvfree (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);
@@ -926,8 +926,8 @@ int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct net_device *netdev)/* 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 = kzalloc_objs(struct bnxt_qplib_qp_node, - rcfw->qp_tbl_size); + rcfw->qp_tbl = kvzalloc_objs(struct bnxt_qplib_qp_node, + rcfw->qp_tbl_size);if (!rcfw->qp_tbl)return -ENOMEM ;
Signature · 1 line
2.39.3
[email protected]
AI reviewRe: [PATCH for-rc 1/2] RDMA/bnxt_re: Use kvzalloc for QP table allocation
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
From: Abhishek Mohapatra <[email protected]>
The QP table size depends on the firmware reported
max_qp, so it can be large and a physically contiguous kzalloc may fail. Usekvzalloc_objs()and free it withkvfree().Fixes 82f1f575aa13 ("RDMA/bnxt_re: Fix allocation of QP table")Signed-off-by Abhishek Mohapatra <[email protected]>Signed-off-by Selvin Xavier <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Selvin Xavier
maintainerPATCH 2/2 RDMA/bnxt_re: Unpublish QP table before freeing it
In reply to Selvin Xavierbnxt_re_dev_uninit() frees the QP table before the RCFW channel is disabled, so the CREQ tasklet can still look up rcfw->qp_tbl while it is being freed.
Clear rcfw->qp_tbl under tbl_lock before freeing it, and have the QP error notification handler bail out if the table is gone.
--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 4 ++++ drivers/infiniband/hw/bnxt_re/qplib_res.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +4 -0
@@ -638,6 +638,10 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, err_event = (struct creq_qp_error_notification *)qp_event; qp_id =le32_to_cpu (err_event->xid);spin_lock (&rcfw->tbl_lock); +if (!rcfw->qp_tbl) { +spin_unlock (&rcfw->tbl_lock); +break ; + } tbl_indx =map_qp_id_to_tbl_indx (qp_id, rcfw); qp = rcfw->qp_tbl[tbl_indx].qp_handle;if (!qp) {
drivers/infiniband/hw/bnxt_re/qplib_res.c +9 -1
@@ -909,7 +909,15 @@ int bnxt_qplib_init_res(struct bnxt_qplib_res *res)void bnxt_qplib_free_res (struct bnxt_qplib_res *res) { -kvfree (res->rcfw->qp_tbl); +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct bnxt_qplib_qp_node *qp_tbl; + +/* The CREQ tasklet may still be running; unpublish the table first */ +spin_lock_bh (&rcfw->tbl_lock); + qp_tbl = rcfw->qp_tbl; + rcfw->qp_tbl =NULL ; +spin_unlock_bh (&rcfw->tbl_lock); +kvfree (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);
Signature · 1 line
2.39.3
[email protected]
AI reviewRe: [PATCH for-rc 2/2] RDMA/bnxt_re: Unpublish QP table before freeing it
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
bnxt_re_dev_uninit()frees the QP table before the RCFW channel is disabled, so the CREQ tasklet can still look uprcfw->qp_tblwhile it is being freed.Clear
rcfw->qp_tblundertbl_lockbefore freeing it, and have the QP error notification handler bail out if the table is gone.Fixes 82f1f575aa13 ("RDMA/bnxt_re: Fix allocation of QP table")Signed-off-by Selvin Xavier <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Leon Romanovsky
AppliedQuoted 9 lines · Selvin Xavier
This series fixes couple issues with the QP table
allocation/teardown.Please review and apply
Thanks,
Selvin Xavier[...]
Applied, thanks!
[1/2] RDMA/bnxt_re: Use kvzalloc for QP table allocation
https://git.kernel.org/rdma/rdma/c/724a39b36af947 [2/2] RDMA/bnxt_re: Unpublish QP table before freeing it https://git.kernel.org/rdma/rdma/c/978361dd2ccff3
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>