Skip to content

Commit

Permalink
IB: Pass uverbs_attr_bundle down ib_x destroy path
Browse files Browse the repository at this point in the history
The uverbs_attr_bundle with the ucontext is sent down to the drivers ib_x
destroy path as ib_udata. The next patch will use the ib_udata to free the
drivers destroy path from the dependency in 'uobject->context' as we
already did for the create path.

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
srabinov authored and jgunthorpe committed Apr 1, 2019
1 parent a6a3797 commit c4367a2
Show file tree
Hide file tree
Showing 73 changed files with 513 additions and 343 deletions.
19 changes: 11 additions & 8 deletions drivers/infiniband/core/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
* @comp_vector: HCA completion vectors for this CQ
* @poll_ctx: context to poll the CQ from.
* @caller: module owner name.
* @udata: Valid user data or NULL for kernel object
*
* This is the proper interface to allocate a CQ for in-kernel users. A
* CQ allocated with this interface will automatically be polled from the
* specified context. The ULP must use wr->wr_cqe instead of wr->wr_id
* to use this CQ abstraction.
*/
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private,
int nr_cqe, int comp_vector,
enum ib_poll_context poll_ctx, const char *caller)
struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
int nr_cqe, int comp_vector,
enum ib_poll_context poll_ctx,
const char *caller, struct ib_udata *udata)
{
struct ib_cq_init_attr cq_attr = {
.cqe = nr_cqe,
Expand Down Expand Up @@ -193,16 +195,17 @@ struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private,
kfree(cq->wc);
rdma_restrack_del(&cq->res);
out_destroy_cq:
cq->device->ops.destroy_cq(cq);
cq->device->ops.destroy_cq(cq, udata);
return ERR_PTR(ret);
}
EXPORT_SYMBOL(__ib_alloc_cq);
EXPORT_SYMBOL(__ib_alloc_cq_user);

/**
* ib_free_cq - free a completion queue
* @cq: completion queue to free.
* @udata: User data or NULL for kernel object
*/
void ib_free_cq(struct ib_cq *cq)
void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)
{
int ret;

Expand All @@ -225,7 +228,7 @@ void ib_free_cq(struct ib_cq *cq)

kfree(cq->wc);
rdma_restrack_del(&cq->res);
ret = cq->device->ops.destroy_cq(cq);
ret = cq->device->ops.destroy_cq(cq, udata);
WARN_ON_ONCE(ret);
}
EXPORT_SYMBOL(ib_free_cq);
EXPORT_SYMBOL(ib_free_cq_user);
2 changes: 1 addition & 1 deletion drivers/infiniband/core/uverbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_event_handler(struct ib_event_handler *handler,
struct ib_event *event);
int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
enum rdma_remove_reason why);
enum rdma_remove_reason why, struct ib_udata *udata);

int uverbs_dealloc_mw(struct ib_mw *mw);
void ib_uverbs_detach_umcast(struct ib_qp *qp,
Expand Down
17 changes: 8 additions & 9 deletions drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs)
return uobj_alloc_commit(uobj, attrs);

err_copy:
ib_dealloc_pd(pd);
ib_dealloc_pd_user(pd, &attrs->driver_udata);
pd = NULL;
err_alloc:
kfree(pd);
Expand Down Expand Up @@ -643,7 +643,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs)
}

err_dealloc_xrcd:
ib_dealloc_xrcd(xrcd);
ib_dealloc_xrcd(xrcd, &attrs->driver_udata);

err:
uobj_alloc_abort(&obj->uobject, attrs);
Expand All @@ -669,9 +669,8 @@ static int ib_uverbs_close_xrcd(struct uverbs_attr_bundle *attrs)
return uobj_perform_destroy(UVERBS_OBJECT_XRCD, cmd.xrcd_handle, attrs);
}

int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject,
struct ib_xrcd *xrcd,
enum rdma_remove_reason why)
int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
enum rdma_remove_reason why, struct ib_udata *udata)
{
struct inode *inode;
int ret;
Expand All @@ -681,7 +680,7 @@ int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject,
if (inode && !atomic_dec_and_test(&xrcd->usecnt))
return 0;

ret = ib_dealloc_xrcd(xrcd);
ret = ib_dealloc_xrcd(xrcd, udata);

if (ib_is_destroy_retryable(ret, why, uobject)) {
atomic_inc(&xrcd->usecnt);
Expand Down Expand Up @@ -766,7 +765,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
return uobj_alloc_commit(uobj, attrs);

err_copy:
ib_dereg_mr(mr);
ib_dereg_mr_user(mr, &attrs->driver_udata);

err_put:
uobj_put_obj_read(pd);
Expand Down Expand Up @@ -2965,7 +2964,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
return uobj_alloc_commit(&obj->uevent.uobject, attrs);

err_copy:
ib_destroy_wq(wq);
ib_destroy_wq(wq, &attrs->driver_udata);
err_put_cq:
uobj_put_obj_read(cq);
err_put_pd:
Expand Down Expand Up @@ -3461,7 +3460,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
return uobj_alloc_commit(&obj->uevent.uobject, attrs);

err_copy:
ib_destroy_srq(srq);
ib_destroy_srq_user(srq, &attrs->driver_udata);

err_put:
uobj_put_obj_read(pd);
Expand Down
15 changes: 8 additions & 7 deletions drivers/infiniband/core/uverbs_std_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ static int uverbs_free_ah(struct ib_uobject *uobject,
enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{
return rdma_destroy_ah((struct ib_ah *)uobject->object,
RDMA_DESTROY_AH_SLEEPABLE);
return rdma_destroy_ah_user((struct ib_ah *)uobject->object,
RDMA_DESTROY_AH_SLEEPABLE,
&attrs->driver_udata);
}

static int uverbs_free_flow(struct ib_uobject *uobject,
Expand Down Expand Up @@ -97,7 +98,7 @@ static int uverbs_free_qp(struct ib_uobject *uobject,
ib_uverbs_detach_umcast(qp, uqp);
}

ret = ib_destroy_qp(qp);
ret = ib_destroy_qp_user(qp, &attrs->driver_udata);
if (ib_is_destroy_retryable(ret, why, uobject))
return ret;

Expand Down Expand Up @@ -133,7 +134,7 @@ static int uverbs_free_wq(struct ib_uobject *uobject,
container_of(uobject, struct ib_uwq_object, uevent.uobject);
int ret;

ret = ib_destroy_wq(wq);
ret = ib_destroy_wq(wq, &attrs->driver_udata);
if (ib_is_destroy_retryable(ret, why, uobject))
return ret;

Expand All @@ -151,7 +152,7 @@ static int uverbs_free_srq(struct ib_uobject *uobject,
enum ib_srq_type srq_type = srq->srq_type;
int ret;

ret = ib_destroy_srq(srq);
ret = ib_destroy_srq_user(srq, &attrs->driver_udata);
if (ib_is_destroy_retryable(ret, why, uobject))
return ret;

Expand Down Expand Up @@ -180,7 +181,7 @@ static int uverbs_free_xrcd(struct ib_uobject *uobject,
return ret;

mutex_lock(&uobject->context->ufile->device->xrcd_tree_mutex);
ret = ib_uverbs_dealloc_xrcd(uobject, xrcd, why);
ret = ib_uverbs_dealloc_xrcd(uobject, xrcd, why, &attrs->driver_udata);
mutex_unlock(&uobject->context->ufile->device->xrcd_tree_mutex);

return ret;
Expand All @@ -197,7 +198,7 @@ static int uverbs_free_pd(struct ib_uobject *uobject,
if (ret)
return ret;

ib_dealloc_pd(pd);
ib_dealloc_pd_user(pd, &attrs->driver_udata);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/uverbs_std_types_cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static int uverbs_free_cq(struct ib_uobject *uobject,
container_of(uobject, struct ib_ucq_object, uobject);
int ret;

ret = ib_destroy_cq(cq);
ret = ib_destroy_cq_user(cq, &attrs->driver_udata);
if (ib_is_destroy_retryable(ret, why, uobject))
return ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/uverbs_std_types_dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static int uverbs_free_dm(struct ib_uobject *uobject,
if (ret)
return ret;

return dm->device->ops.dealloc_dm(dm);
return dm->device->ops.dealloc_dm(dm, attrs);
}

static int UVERBS_HANDLER(UVERBS_METHOD_DM_ALLOC)(
Expand Down
5 changes: 3 additions & 2 deletions drivers/infiniband/core/uverbs_std_types_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ static int uverbs_free_mr(struct ib_uobject *uobject,
enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{
return ib_dereg_mr((struct ib_mr *)uobject->object);
return ib_dereg_mr_user((struct ib_mr *)uobject->object,
&attrs->driver_udata);
}

static int UVERBS_HANDLER(UVERBS_METHOD_ADVISE_MR)(
Expand Down Expand Up @@ -147,7 +148,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
return 0;

err_dereg:
ib_dereg_mr(mr);
ib_dereg_mr_user(mr, &attrs->driver_udata);

return ret;
}
Expand Down
Loading

0 comments on commit c4367a2

Please sign in to comment.