On Tuesday, February 02/12/19, 2019 at 08:09:39 -0600, Steve Wise wrote: > > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > > > Ucontext allocation and release aren't async events and don't need > > kref accounting. The common layer of RDMA subsystem ensures that > > dealloc ucontext will be called after all other objects are released. > > > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > Reviewed-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> > > Please add my Tested-by tag. Tested-by: Raju Rangoju <rajur@xxxxxxxxxxx> > > --- > > drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 13 ------------- > > drivers/infiniband/hw/cxgb4/provider.c | 16 +++------------- > > drivers/infiniband/hw/cxgb4/qp.c | 3 --- > > 3 files changed, 3 insertions(+), 29 deletions(-) > > > > diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h > > b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h > > index 3a0923f7c60e..5a5da41faef6 100644 > > --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h > > +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h > > @@ -589,7 +589,6 @@ struct c4iw_ucontext { > > u32 key; > > spinlock_t mmap_lock; > > struct list_head mmaps; > > - struct kref kref; > > bool is_32b_cqe; > > }; > > > > @@ -598,18 +597,6 @@ static inline struct c4iw_ucontext > > *to_c4iw_ucontext(struct ib_ucontext *c) > > return container_of(c, struct c4iw_ucontext, ibucontext); > > } > > > > -void _c4iw_free_ucontext(struct kref *kref); > > - > > -static inline void c4iw_put_ucontext(struct c4iw_ucontext *ucontext) > > -{ > > - kref_put(&ucontext->kref, _c4iw_free_ucontext); > > -} > > - > > -static inline void c4iw_get_ucontext(struct c4iw_ucontext *ucontext) > > -{ > > - kref_get(&ucontext->kref); > > -} > > - > > struct c4iw_mm_entry { > > struct list_head entry; > > u64 addr; > > diff --git a/drivers/infiniband/hw/cxgb4/provider.c > > b/drivers/infiniband/hw/cxgb4/provider.c > > index 680b5e98491d..81fcffb597ab 100644 > > --- a/drivers/infiniband/hw/cxgb4/provider.c > > +++ b/drivers/infiniband/hw/cxgb4/provider.c > > @@ -58,28 +58,19 @@ static int fastreg_support = 1; > > module_param(fastreg_support, int, 0644); > > MODULE_PARM_DESC(fastreg_support, "Advertise fastreg support > > (default=1)"); > > > > -void _c4iw_free_ucontext(struct kref *kref) > > +static int c4iw_dealloc_ucontext(struct ib_ucontext *context) > > { > > - struct c4iw_ucontext *ucontext; > > + struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context); > > struct c4iw_dev *rhp; > > struct c4iw_mm_entry *mm, *tmp; > > > > - ucontext = container_of(kref, struct c4iw_ucontext, kref); > > + pr_debug("context %p\n", context); > > rhp = to_c4iw_dev(ucontext->ibucontext.device); > > > > - pr_debug("ucontext %p\n", ucontext); > > list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry) > > kfree(mm); > > c4iw_release_dev_ucontext(&rhp->rdev, &ucontext->uctx); > > kfree(ucontext); > > -} > > - > > -static int c4iw_dealloc_ucontext(struct ib_ucontext *context) > > -{ > > - struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context); > > - > > - pr_debug("context %p\n", context); > > - c4iw_put_ucontext(ucontext); > > return 0; > > } > > > > @@ -102,7 +93,6 @@ static struct ib_ucontext *c4iw_alloc_ucontext(struct > > ib_device *ibdev, > > c4iw_init_dev_ucontext(&rhp->rdev, &context->uctx); > > INIT_LIST_HEAD(&context->mmaps); > > spin_lock_init(&context->mmap_lock); > > - kref_init(&context->kref); > > > > if (udata->outlen < sizeof(uresp) - sizeof(uresp.reserved)) { > > pr_err_once("Warning - downlevel libcxgb4 (non-fatal), > > device status page disabled\n"); > > diff --git a/drivers/infiniband/hw/cxgb4/qp.c > > b/drivers/infiniband/hw/cxgb4/qp.c > > index 0fe87b9c1e10..4a438c12406d 100644 > > --- a/drivers/infiniband/hw/cxgb4/qp.c > > +++ b/drivers/infiniband/hw/cxgb4/qp.c > > @@ -903,8 +903,6 @@ static void free_qp_work(struct work_struct *work) > > destroy_qp(&rhp->rdev, &qhp->wq, > > ucontext ? &ucontext->uctx : &rhp->rdev.uctx, !qhp->srq); > > > > - if (ucontext) > > - c4iw_put_ucontext(ucontext); > > c4iw_put_wr_wait(qhp->wr_waitp); > > kfree(qhp); > > } > > @@ -2338,7 +2336,6 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, > > struct ib_qp_init_attr *attrs, > > insert_mmap(ucontext, ma_sync_key_mm); > > } > > > > - c4iw_get_ucontext(ucontext); > > qhp->ucontext = ucontext; > > } > > if (!attrs->srq) { > > -- > > 2.19.1 >