Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4367a26 authored by Shamir Rabinovitch's avatar Shamir Rabinovitch Committed by Jason Gunthorpe
Browse files

IB: Pass uverbs_attr_bundle down ib_x destroy path



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: default avatarShamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent a6a3797d
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -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,
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)
				 enum ib_poll_context poll_ctx,
				 const char *caller, struct ib_udata *udata)
{
	struct ib_cq_init_attr cq_attr = {
		.cqe		= nr_cqe,
@@ -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;

@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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,
+8 −9
Original line number Diff line number Diff line
@@ -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);
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -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:
@@ -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);
+8 −7
Original line number Diff line number Diff line
@@ -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,
@@ -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;

@@ -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;

@@ -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;

@@ -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;
@@ -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;
}

+1 −1
Original line number Diff line number Diff line
@@ -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;

Loading