RDMA/bnxt_re: Initialize mutex dbq_lock
Subsystems (2)
Selvin Xavier
maintainerPATCH 1/2 RDMA/bnxt_re: Initialize mutex dbq_lock
From: Kashyap Desai <[email protected]>
Fix the missing dbq_lock mutex initialization
--- drivers/infiniband/hw/bnxt_re/main.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/bnxt_re/main.c +1 -0
@@ -920,6 +920,7 @@ static struct bnxt_re_dev *bnxt_re_dev_add(struct bnxt_aux_priv *aux_priv, rdev->id = rdev->en_dev->pdev->devfn;INIT_LIST_HEAD (&rdev->qp_list);mutex_init (&rdev->qp_lock); +mutex_init (&rdev->pacing.dbq_lock);atomic_set (&rdev->stats.res.qp_count,0 );atomic_set (&rdev->stats.res.cq_count,0 );atomic_set (&rdev->stats.res.srq_count,0 );
Signature · 1 line
2.5.5
Selvin Xavier
maintainerPATCH 2/2 RDMA/bnxt_re: Protect the PD table bitmap
Syncrhonization is required to avoid simultaneous allocation of the PD. Add a new mutex lock to handle allocation from the PD table.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 26 ++++++++++++++++++++------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +1 -1
@@ -619,7 +619,7 @@ int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)int rc =0 ; pd->rdev = rdev; -if (bnxt_qplib_alloc_pd (&rdev->qplib_res.pd_tbl, &pd->qplib_pd)) { +if (bnxt_qplib_alloc_pd (&rdev->qplib_res, &pd->qplib_pd)) {ibdev_err (&rdev->ibdev,"Failed to allocate HW PD" ); rc = -ENOMEM ; goto fail;
drivers/infiniband/hw/bnxt_re/qplib_res.c +20 -6
@@ -642,31 +642,44 @@ static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl, }/* PDs */ -int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) +int bnxt_qplib_alloc_pd (struct bnxt_qplib_res *res,struct bnxt_qplib_pd *pd) { +struct bnxt_qplib_pd_tbl *pdt = &res->pd_tbl;u32 bit_num; +int rc =0 ; +mutex_lock (&res->pd_tbl_lock); bit_num =find_first_bit (pdt->tbl, pdt->max); -if (bit_num == pdt->max) -return -ENOMEM ; +if (bit_num == pdt->max) { + rc = -ENOMEM ; + goto exit; + }/* Found unused PD */ clear_bit (bit_num, pdt->tbl); pd->id = bit_num; -return 0 ; +exit: +mutex_unlock (&res->pd_tbl_lock); +return rc; }int bnxt_qplib_dealloc_pd (struct bnxt_qplib_res *res,struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) { +int rc =0 ; + +mutex_lock (&res->pd_tbl_lock);if (test_and_set_bit (pd->id, pdt->tbl)) {dev_warn (&res->pdev->dev,"Freeing an unused PD? pdn = %d\n" , pd->id); -return -EINVAL ; + rc = -EINVAL ; + goto exit; } pd->id =0 ; -return 0 ; +exit: +mutex_unlock (&res->pd_tbl_lock); +return rc; }static void bnxt_qplib_free_pd_tbl (struct bnxt_qplib_pd_tbl *pdt)
@@ -691,6 +704,7 @@ static int bnxt_qplib_alloc_pd_tbl(struct bnxt_qplib_res *res, pdt->max = max;memset ((u8 *)pdt->tbl,0xFF , bytes); +mutex_init (&res->pd_tbl_lock);return 0 ; }
drivers/infiniband/hw/bnxt_re/qplib_res.h +3 -1
@@ -277,6 +277,8 @@ struct bnxt_qplib_res {struct net_device *netdev;struct bnxt_qplib_rcfw *rcfw;struct bnxt_qplib_pd_tbl pd_tbl; +/* To protect the pd table bit map */ +struct mutex pd_tbl_lock;struct bnxt_qplib_sgid_tbl sgid_tbl;struct bnxt_qplib_dpi_tbl dpi_tbl;/* To protect the dpi table bit map */
@@ -368,7 +370,7 @@ void bnxt_qplib_free_hwq(struct bnxt_qplib_res *res, struct bnxt_qplib_hwq *hwq);int bnxt_qplib_alloc_init_hwq (struct bnxt_qplib_hwq *hwq,struct bnxt_qplib_hwq_attr *hwq_attr); -int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pd_tbl, +int bnxt_qplib_alloc_pd (struct bnxt_qplib_res *res,struct bnxt_qplib_pd *pd); int bnxt_qplib_dealloc_pd(struct bnxt_qplib_res *res, struct bnxt_qplib_pd_tbl *pd_tbl,
Signature · 1 line
2.5.5
Jason Gunthorpe
maintainerRe: [PATCH for-next 2/2] RDMA/bnxt_re: Protect the PD table bitmap
Quoted 11 lines · Selvin Xavier
Syncrhonization is required to avoid simultaneous allocation of the PD. Add a new mutex lock to handle allocation from the PD table.
Signed-off-by Kashyap Desai <[email protected]>Signed-off-by Selvin Xavier <[email protected]>--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 26 ++++++++++++++++++++------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-)
This needs a fixes line, it seems like a serious bug??
Quoted 7 lines
drivers/infiniband/hw/bnxt_re/qplib_res.c +0
-0@@ -642,31 +642,44 @@ static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl, }
drivers/infiniband/hw/bnxt_re/qplib_res.c static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl, · line 652
Quoted 10 lines
drivers/infiniband/hw/bnxt_re/qplib_res.c +4
-1/* PDs */ -int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) +int bnxt_qplib_alloc_pd (struct bnxt_qplib_res *res,struct bnxt_qplib_pd *pd) { +struct bnxt_qplib_pd_tbl *pdt = &res->pd_tbl;u32 bit_num; +int rc =0 ; +mutex_lock (&res->pd_tbl_lock); bit_num =find_first_bit (pdt->tbl, pdt->max);
Please make a followup patch to change this into an IDA unless the pd max is really small. Don't opencode IDAs in drivers..
Jason
Selvin Xavier
maintainerRe: [PATCH for-next 2/2] RDMA/bnxt_re: Protect the PD table bitmap
Quoted 14 lines · Jason Gunthorpe
Quoted 11 lines · Selvin Xavier
Syncrhonization is required to avoid simultaneous allocation of the PD. Add a new mutex lock to handle allocation from the PD table.
Signed-off-by Kashyap Desai <[email protected]>Signed-off-by Selvin Xavier <[email protected]>--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 26 ++++++++++++++++++++------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-)
Quoted 1 line
This needs a fixes line, it seems like a serious bug??
Yes. It is a critical fix. Will add fixes line and post a v2.
Quoted 16 lines
Quoted 16 lines
drivers/infiniband/hw/bnxt_re/qplib_res.c +3
-1@@ -642,31 +642,44 @@ static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl, }/* PDs */ -int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) +int bnxt_qplib_alloc_pd (struct bnxt_qplib_res *res,struct bnxt_qplib_pd *pd) { +struct bnxt_qplib_pd_tbl *pdt = &res->pd_tbl;u32 bit_num; +int rc =0 ;
Quoted 5 lines
drivers/infiniband/hw/bnxt_re/qplib_res.c static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl, · line 652
Quoted 2 lines
drivers/infiniband/hw/bnxt_re/qplib_res.c +1
-0+mutex_lock (&res->pd_tbl_lock); bit_num =find_first_bit (pdt->tbl, pdt->max);Please make a followup patch to change this into an IDA unless the pd max is really small. Don't opencode IDAs in drivers..
pd max is 64k. We will create a followup patch . Thanks.
Quoted 2 lines
Jason
Re: [PATCH for-next 2/2] RDMA/bnxt_re: Protect the PD table bitmap
Quoted 15 lines · Selvin Xavier
Quoted 14 lines · Jason Gunthorpe
Quoted 11 lines · Selvin Xavier
Syncrhonization is required to avoid simultaneous allocation of the PD. Add a new mutex lock to handle allocation from the PD table.
Signed-off-by Kashyap Desai <[email protected]>Signed-off-by Selvin Xavier <[email protected]>--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 26 ++++++++++++++++++++------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-)
Quoted 2 lines
Quoted 1 line
This needs a fixes line, it seems like a serious bug??
Yes. It is a critical fix. Will add fixes line and post a v2.
We already applied v1 and tagged for-next with it. Unless Jason wants to rebase that branch, it is too late for v2.
Thanks
Selvin Xavier
maintainerRe: [PATCH for-next 2/2] RDMA/bnxt_re: Protect the PD table bitmap
Quoted 17 lines · Leon Romanovsky
Quoted 15 lines · Selvin Xavier
Quoted 14 lines · Jason Gunthorpe
Quoted 11 lines · Selvin Xavier
Syncrhonization is required to avoid simultaneous allocation of the PD. Add a new mutex lock to handle allocation from the PD table.
Signed-off-by Kashyap Desai <[email protected]>Signed-off-by Selvin Xavier <[email protected]>--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 26 ++++++++++++++++++++------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-)
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
This needs a fixes line, it seems like a serious bug??
Yes. It is a critical fix. Will add fixes line and post a v2.
We already applied v1 and tagged for-next with it. Unless Jason wants to rebase that branch, it is too late for v2.
ok. I added only the fixes tag as per Jason's comment in v2.
Quoted 2 lines
Thanks