Commit b3b2c7c5 authored by Devesh Sharma's avatar Devesh Sharma Committed by Doug Ledford

RDMA/bnxt_re: Free doorbell page index (DPI) during dealloc ucontext

The driver must free the DPI during the dealloc_ucontext
instead of freeing it during dealloc_pd. However, the DPI
allocation scheme remains unchanged.
Signed-off-by: default avatarDevesh Sharma <devesh.sharma@broadcom.com>
Signed-off-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 396551eb
...@@ -612,30 +612,13 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd) ...@@ -612,30 +612,13 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd)
int rc; int rc;
bnxt_re_destroy_fence_mr(pd); bnxt_re_destroy_fence_mr(pd);
if (ib_pd->uobject && pd->dpi.dbr) {
struct ib_ucontext *ib_uctx = ib_pd->uobject->context;
struct bnxt_re_ucontext *ucntx;
/* Free DPI only if this is the first PD allocated by the if (pd->qplib_pd.id) {
* application and mark the context dpi as NULL rc = bnxt_qplib_dealloc_pd(&rdev->qplib_res,
*/ &rdev->qplib_res.pd_tbl,
ucntx = container_of(ib_uctx, struct bnxt_re_ucontext, ib_uctx); &pd->qplib_pd);
rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
&rdev->qplib_res.dpi_tbl,
&pd->dpi);
if (rc) if (rc)
dev_err(rdev_to_dev(rdev), "Failed to deallocate HW DPI"); dev_err(rdev_to_dev(rdev), "Failed to deallocate HW PD");
/* Don't fail, continue*/
ucntx->dpi = NULL;
}
rc = bnxt_qplib_dealloc_pd(&rdev->qplib_res,
&rdev->qplib_res.pd_tbl,
&pd->qplib_pd);
if (rc) {
dev_err(rdev_to_dev(rdev), "Failed to deallocate HW PD");
return rc;
} }
kfree(pd); kfree(pd);
...@@ -667,23 +650,22 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev, ...@@ -667,23 +650,22 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev,
if (udata) { if (udata) {
struct bnxt_re_pd_resp resp; struct bnxt_re_pd_resp resp;
if (!ucntx->dpi) { if (!ucntx->dpi.dbr) {
/* Allocate DPI in alloc_pd to avoid failing of /* Allocate DPI in alloc_pd to avoid failing of
* ibv_devinfo and family of application when DPIs * ibv_devinfo and family of application when DPIs
* are depleted. * are depleted.
*/ */
if (bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl, if (bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl,
&pd->dpi, ucntx)) { &ucntx->dpi, ucntx)) {
rc = -ENOMEM; rc = -ENOMEM;
goto dbfail; goto dbfail;
} }
ucntx->dpi = &pd->dpi;
} }
resp.pdid = pd->qplib_pd.id; resp.pdid = pd->qplib_pd.id;
/* Still allow mapping this DBR to the new user PD. */ /* Still allow mapping this DBR to the new user PD. */
resp.dpi = ucntx->dpi->dpi; resp.dpi = ucntx->dpi.dpi;
resp.dbr = (u64)ucntx->dpi->umdbr; resp.dbr = (u64)ucntx->dpi.umdbr;
rc = ib_copy_to_udata(udata, &resp, sizeof(resp)); rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
if (rc) { if (rc) {
...@@ -960,7 +942,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, ...@@ -960,7 +942,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
qplib_qp->rq.nmap = umem->nmap; qplib_qp->rq.nmap = umem->nmap;
} }
qplib_qp->dpi = cntx->dpi; qplib_qp->dpi = &cntx->dpi;
return 0; return 0;
rqfail: rqfail:
ib_umem_release(qp->sumem); ib_umem_release(qp->sumem);
...@@ -2403,7 +2385,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, ...@@ -2403,7 +2385,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
} }
cq->qplib_cq.sghead = cq->umem->sg_head.sgl; cq->qplib_cq.sghead = cq->umem->sg_head.sgl;
cq->qplib_cq.nmap = cq->umem->nmap; cq->qplib_cq.nmap = cq->umem->nmap;
cq->qplib_cq.dpi = uctx->dpi; cq->qplib_cq.dpi = &uctx->dpi;
} else { } else {
cq->max_cql = min_t(u32, entries, MAX_CQL_PER_POLL); cq->max_cql = min_t(u32, entries, MAX_CQL_PER_POLL);
cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe), cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe),
...@@ -3388,8 +3370,26 @@ int bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx) ...@@ -3388,8 +3370,26 @@ int bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx)
struct bnxt_re_ucontext *uctx = container_of(ib_uctx, struct bnxt_re_ucontext *uctx = container_of(ib_uctx,
struct bnxt_re_ucontext, struct bnxt_re_ucontext,
ib_uctx); ib_uctx);
struct bnxt_re_dev *rdev = uctx->rdev;
int rc = 0;
if (uctx->shpg) if (uctx->shpg)
free_page((unsigned long)uctx->shpg); free_page((unsigned long)uctx->shpg);
if (uctx->dpi.dbr) {
/* Free DPI only if this is the first PD allocated by the
* application and mark the context dpi as NULL
*/
rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
&rdev->qplib_res.dpi_tbl,
&uctx->dpi);
if (rc)
dev_err(rdev_to_dev(rdev), "Deallocte HW DPI failed!");
/* Don't fail, continue*/
uctx->dpi.dbr = NULL;
}
kfree(uctx); kfree(uctx);
return 0; return 0;
} }
......
...@@ -59,7 +59,6 @@ struct bnxt_re_pd { ...@@ -59,7 +59,6 @@ struct bnxt_re_pd {
struct bnxt_re_dev *rdev; struct bnxt_re_dev *rdev;
struct ib_pd ib_pd; struct ib_pd ib_pd;
struct bnxt_qplib_pd qplib_pd; struct bnxt_qplib_pd qplib_pd;
struct bnxt_qplib_dpi dpi;
struct bnxt_re_fence_data fence; struct bnxt_re_fence_data fence;
}; };
...@@ -127,7 +126,7 @@ struct bnxt_re_mw { ...@@ -127,7 +126,7 @@ struct bnxt_re_mw {
struct bnxt_re_ucontext { struct bnxt_re_ucontext {
struct bnxt_re_dev *rdev; struct bnxt_re_dev *rdev;
struct ib_ucontext ib_uctx; struct ib_ucontext ib_uctx;
struct bnxt_qplib_dpi *dpi; struct bnxt_qplib_dpi dpi;
void *shpg; void *shpg;
spinlock_t sh_lock; /* protect shpg */ spinlock_t sh_lock; /* protect shpg */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment