Commit a6a3797d authored by Shamir Rabinovitch's avatar Shamir Rabinovitch Committed by Jason Gunthorpe

IB: Pass uverbs_attr_bundle down uobject destroy path

Pass uverbs_attr_bundle down the uobject destroy path. The next patch will
use this to eliminate the dependecy of the drivers in ib_x->uobject
pointers.
Signed-off-by: default avatarShamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 70f06b26
...@@ -125,7 +125,8 @@ static void assert_uverbs_usecnt(struct ib_uobject *uobj, ...@@ -125,7 +125,8 @@ static void assert_uverbs_usecnt(struct ib_uobject *uobj,
* and consumes the kref on the uobj. * and consumes the kref on the uobj.
*/ */
static int uverbs_destroy_uobject(struct ib_uobject *uobj, static int uverbs_destroy_uobject(struct ib_uobject *uobj,
enum rdma_remove_reason reason) enum rdma_remove_reason reason,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_uverbs_file *ufile = uobj->ufile; struct ib_uverbs_file *ufile = uobj->ufile;
unsigned long flags; unsigned long flags;
...@@ -135,7 +136,8 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj, ...@@ -135,7 +136,8 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj,
assert_uverbs_usecnt(uobj, UVERBS_LOOKUP_WRITE); assert_uverbs_usecnt(uobj, UVERBS_LOOKUP_WRITE);
if (uobj->object) { if (uobj->object) {
ret = uobj->uapi_object->type_class->destroy_hw(uobj, reason); ret = uobj->uapi_object->type_class->destroy_hw(uobj, reason,
attrs);
if (ret) { if (ret) {
if (ib_is_destroy_retryable(ret, reason, uobj)) if (ib_is_destroy_retryable(ret, reason, uobj))
return ret; return ret;
...@@ -196,7 +198,7 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj, ...@@ -196,7 +198,7 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj,
* version requires the caller to have already obtained an * version requires the caller to have already obtained an
* LOOKUP_DESTROY uobject kref. * LOOKUP_DESTROY uobject kref.
*/ */
int uobj_destroy(struct ib_uobject *uobj) int uobj_destroy(struct ib_uobject *uobj, struct uverbs_attr_bundle *attrs)
{ {
struct ib_uverbs_file *ufile = uobj->ufile; struct ib_uverbs_file *ufile = uobj->ufile;
int ret; int ret;
...@@ -207,7 +209,7 @@ int uobj_destroy(struct ib_uobject *uobj) ...@@ -207,7 +209,7 @@ int uobj_destroy(struct ib_uobject *uobj)
if (ret) if (ret)
goto out_unlock; goto out_unlock;
ret = uverbs_destroy_uobject(uobj, RDMA_REMOVE_DESTROY); ret = uverbs_destroy_uobject(uobj, RDMA_REMOVE_DESTROY, attrs);
if (ret) { if (ret) {
atomic_set(&uobj->usecnt, 0); atomic_set(&uobj->usecnt, 0);
goto out_unlock; goto out_unlock;
...@@ -234,7 +236,7 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj, ...@@ -234,7 +236,7 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return uobj; return uobj;
ret = uobj_destroy(uobj); ret = uobj_destroy(uobj, attrs);
if (ret) { if (ret) {
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_DESTROY); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_DESTROY);
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -533,12 +535,13 @@ static void alloc_abort_idr_uobject(struct ib_uobject *uobj) ...@@ -533,12 +535,13 @@ static void alloc_abort_idr_uobject(struct ib_uobject *uobj)
} }
static int __must_check destroy_hw_idr_uobject(struct ib_uobject *uobj, static int __must_check destroy_hw_idr_uobject(struct ib_uobject *uobj,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
const struct uverbs_obj_idr_type *idr_type = const struct uverbs_obj_idr_type *idr_type =
container_of(uobj->uapi_object->type_attrs, container_of(uobj->uapi_object->type_attrs,
struct uverbs_obj_idr_type, type); struct uverbs_obj_idr_type, type);
int ret = idr_type->destroy_object(uobj, why); int ret = idr_type->destroy_object(uobj, why, attrs);
/* /*
* We can only fail gracefully if the user requested to destroy the * We can only fail gracefully if the user requested to destroy the
...@@ -572,7 +575,8 @@ static void alloc_abort_fd_uobject(struct ib_uobject *uobj) ...@@ -572,7 +575,8 @@ static void alloc_abort_fd_uobject(struct ib_uobject *uobj)
} }
static int __must_check destroy_hw_fd_uobject(struct ib_uobject *uobj, static int __must_check destroy_hw_fd_uobject(struct ib_uobject *uobj,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
const struct uverbs_obj_fd_type *fd_type = container_of( const struct uverbs_obj_fd_type *fd_type = container_of(
uobj->uapi_object->type_attrs, struct uverbs_obj_fd_type, type); uobj->uapi_object->type_attrs, struct uverbs_obj_fd_type, type);
...@@ -648,7 +652,8 @@ static int alloc_commit_fd_uobject(struct ib_uobject *uobj) ...@@ -648,7 +652,8 @@ static int alloc_commit_fd_uobject(struct ib_uobject *uobj)
* caller can no longer assume uobj is valid. If this function fails it * caller can no longer assume uobj is valid. If this function fails it
* destroys the uboject, including the attached HW object. * destroys the uboject, including the attached HW object.
*/ */
int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj) int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_uverbs_file *ufile = uobj->ufile; struct ib_uverbs_file *ufile = uobj->ufile;
int ret; int ret;
...@@ -656,7 +661,7 @@ int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj) ...@@ -656,7 +661,7 @@ int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj)
/* alloc_commit consumes the uobj kref */ /* alloc_commit consumes the uobj kref */
ret = uobj->uapi_object->type_class->alloc_commit(uobj); ret = uobj->uapi_object->type_class->alloc_commit(uobj);
if (ret) { if (ret) {
uverbs_destroy_uobject(uobj, RDMA_REMOVE_ABORT); uverbs_destroy_uobject(uobj, RDMA_REMOVE_ABORT, attrs);
up_read(&ufile->hw_destroy_rwsem); up_read(&ufile->hw_destroy_rwsem);
return ret; return ret;
} }
...@@ -680,12 +685,13 @@ int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj) ...@@ -680,12 +685,13 @@ int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj)
* This consumes the kref for uobj. It is up to the caller to unwind the HW * This consumes the kref for uobj. It is up to the caller to unwind the HW
* object and anything else connected to uobj before calling this. * object and anything else connected to uobj before calling this.
*/ */
void rdma_alloc_abort_uobject(struct ib_uobject *uobj) void rdma_alloc_abort_uobject(struct ib_uobject *uobj,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_uverbs_file *ufile = uobj->ufile; struct ib_uverbs_file *ufile = uobj->ufile;
uobj->object = NULL; uobj->object = NULL;
uverbs_destroy_uobject(uobj, RDMA_REMOVE_ABORT); uverbs_destroy_uobject(uobj, RDMA_REMOVE_ABORT, attrs);
/* Matches the down_read in rdma_alloc_begin_uobject */ /* Matches the down_read in rdma_alloc_begin_uobject */
up_read(&ufile->hw_destroy_rwsem); up_read(&ufile->hw_destroy_rwsem);
...@@ -787,6 +793,10 @@ void uverbs_close_fd(struct file *f) ...@@ -787,6 +793,10 @@ void uverbs_close_fd(struct file *f)
{ {
struct ib_uobject *uobj = f->private_data; struct ib_uobject *uobj = f->private_data;
struct ib_uverbs_file *ufile = uobj->ufile; struct ib_uverbs_file *ufile = uobj->ufile;
struct uverbs_attr_bundle attrs = {
.context = uobj->context,
.ufile = ufile,
};
if (down_read_trylock(&ufile->hw_destroy_rwsem)) { if (down_read_trylock(&ufile->hw_destroy_rwsem)) {
/* /*
...@@ -796,7 +806,7 @@ void uverbs_close_fd(struct file *f) ...@@ -796,7 +806,7 @@ void uverbs_close_fd(struct file *f)
* write lock here, or we have a kernel bug. * write lock here, or we have a kernel bug.
*/ */
WARN_ON(uverbs_try_lock_object(uobj, UVERBS_LOOKUP_WRITE)); WARN_ON(uverbs_try_lock_object(uobj, UVERBS_LOOKUP_WRITE));
uverbs_destroy_uobject(uobj, RDMA_REMOVE_CLOSE); uverbs_destroy_uobject(uobj, RDMA_REMOVE_CLOSE, &attrs);
up_read(&ufile->hw_destroy_rwsem); up_read(&ufile->hw_destroy_rwsem);
} }
...@@ -845,6 +855,7 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile, ...@@ -845,6 +855,7 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
{ {
struct ib_uobject *obj, *next_obj; struct ib_uobject *obj, *next_obj;
int ret = -EINVAL; int ret = -EINVAL;
struct uverbs_attr_bundle attrs = { .ufile = ufile };
/* /*
* This shouldn't run while executing other commands on this * This shouldn't run while executing other commands on this
...@@ -856,12 +867,13 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile, ...@@ -856,12 +867,13 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
* other threads (which might still use the FDs) chance to run. * other threads (which might still use the FDs) chance to run.
*/ */
list_for_each_entry_safe(obj, next_obj, &ufile->uobjects, list) { list_for_each_entry_safe(obj, next_obj, &ufile->uobjects, list) {
attrs.context = obj->context;
/* /*
* if we hit this WARN_ON, that means we are * if we hit this WARN_ON, that means we are
* racing with a lookup_get. * racing with a lookup_get.
*/ */
WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE)); WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE));
if (!uverbs_destroy_uobject(obj, reason)) if (!uverbs_destroy_uobject(obj, reason, &attrs))
ret = 0; ret = 0;
else else
atomic_set(&obj->usecnt, 0); atomic_set(&obj->usecnt, 0);
...@@ -966,8 +978,8 @@ uverbs_get_uobject_from_file(u16 object_id, enum uverbs_obj_access access, ...@@ -966,8 +978,8 @@ uverbs_get_uobject_from_file(u16 object_id, enum uverbs_obj_access access,
} }
int uverbs_finalize_object(struct ib_uobject *uobj, int uverbs_finalize_object(struct ib_uobject *uobj,
enum uverbs_obj_access access, enum uverbs_obj_access access, bool commit,
bool commit) struct uverbs_attr_bundle *attrs)
{ {
int ret = 0; int ret = 0;
...@@ -990,9 +1002,9 @@ int uverbs_finalize_object(struct ib_uobject *uobj, ...@@ -990,9 +1002,9 @@ int uverbs_finalize_object(struct ib_uobject *uobj,
break; break;
case UVERBS_ACCESS_NEW: case UVERBS_ACCESS_NEW:
if (commit) if (commit)
ret = rdma_alloc_commit_uobject(uobj); ret = rdma_alloc_commit_uobject(uobj, attrs);
else else
rdma_alloc_abort_uobject(uobj); rdma_alloc_abort_uobject(uobj, attrs);
break; break;
default: default:
WARN_ON(true); WARN_ON(true);
......
...@@ -48,7 +48,7 @@ struct ib_uverbs_device; ...@@ -48,7 +48,7 @@ struct ib_uverbs_device;
void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile, void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
enum rdma_remove_reason reason); enum rdma_remove_reason reason);
int uobj_destroy(struct ib_uobject *uobj); int uobj_destroy(struct ib_uobject *uobj, struct uverbs_attr_bundle *attrs);
/* /*
* uverbs_uobject_get is called in order to increase the reference count on * uverbs_uobject_get is called in order to increase the reference count on
...@@ -102,8 +102,8 @@ uverbs_get_uobject_from_file(u16 object_id, enum uverbs_obj_access access, ...@@ -102,8 +102,8 @@ uverbs_get_uobject_from_file(u16 object_id, enum uverbs_obj_access access,
* object. * object.
*/ */
int uverbs_finalize_object(struct ib_uobject *uobj, int uverbs_finalize_object(struct ib_uobject *uobj,
enum uverbs_obj_access access, enum uverbs_obj_access access, bool commit,
bool commit); struct uverbs_attr_bundle *attrs);
int uverbs_output_written(const struct uverbs_attr_bundle *bundle, size_t idx); int uverbs_output_written(const struct uverbs_attr_bundle *bundle, size_t idx);
......
...@@ -436,7 +436,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) ...@@ -436,7 +436,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs)
if (ret) if (ret)
goto err_copy; goto err_copy;
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
ib_dealloc_pd(pd); ib_dealloc_pd(pd);
...@@ -444,7 +444,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) ...@@ -444,7 +444,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs)
err_alloc: err_alloc:
kfree(pd); kfree(pd);
err: err:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
return ret; return ret;
} }
...@@ -633,7 +633,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) ...@@ -633,7 +633,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs)
mutex_unlock(&ibudev->xrcd_tree_mutex); mutex_unlock(&ibudev->xrcd_tree_mutex);
return uobj_alloc_commit(&obj->uobject); return uobj_alloc_commit(&obj->uobject, attrs);
err_copy: err_copy:
if (inode) { if (inode) {
...@@ -646,7 +646,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) ...@@ -646,7 +646,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs)
ib_dealloc_xrcd(xrcd); ib_dealloc_xrcd(xrcd);
err: err:
uobj_alloc_abort(&obj->uobject); uobj_alloc_abort(&obj->uobject, attrs);
err_tree_mutex_unlock: err_tree_mutex_unlock:
if (f.file) if (f.file)
...@@ -763,7 +763,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) ...@@ -763,7 +763,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
ib_dereg_mr(mr); ib_dereg_mr(mr);
...@@ -772,7 +772,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) ...@@ -772,7 +772,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
err_free: err_free:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
return ret; return ret;
} }
...@@ -917,14 +917,14 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs) ...@@ -917,14 +917,14 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs)
goto err_copy; goto err_copy;
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
uverbs_dealloc_mw(mw); uverbs_dealloc_mw(mw);
err_put: err_put:
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
err_free: err_free:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
return ret; return ret;
} }
...@@ -965,11 +965,11 @@ static int ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs) ...@@ -965,11 +965,11 @@ static int ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs)
ret = uverbs_response(attrs, &resp, sizeof(resp)); ret = uverbs_response(attrs, &resp, sizeof(resp));
if (ret) { if (ret) {
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
return ret; return ret;
} }
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
} }
static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
...@@ -1036,7 +1036,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1036,7 +1036,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
if (ret) if (ret)
goto err_cb; goto err_cb;
ret = uobj_alloc_commit(&obj->uobject); ret = uobj_alloc_commit(&obj->uobject, attrs);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
return obj; return obj;
...@@ -1049,7 +1049,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1049,7 +1049,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
ib_uverbs_release_ucq(attrs->ufile, ev_file, obj); ib_uverbs_release_ucq(attrs->ufile, ev_file, obj);
err: err:
uobj_alloc_abort(&obj->uobject); uobj_alloc_abort(&obj->uobject, attrs);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -1477,7 +1477,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1477,7 +1477,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
if (ind_tbl) if (ind_tbl)
uobj_put_obj_read(ind_tbl); uobj_put_obj_read(ind_tbl);
return uobj_alloc_commit(&obj->uevent.uobject); return uobj_alloc_commit(&obj->uevent.uobject, attrs);
err_cb: err_cb:
ib_destroy_qp(qp); ib_destroy_qp(qp);
...@@ -1495,7 +1495,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1495,7 +1495,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
if (ind_tbl) if (ind_tbl)
uobj_put_obj_read(ind_tbl); uobj_put_obj_read(ind_tbl);
uobj_alloc_abort(&obj->uevent.uobject); uobj_alloc_abort(&obj->uevent.uobject, attrs);
return ret; return ret;
} }
...@@ -1609,14 +1609,14 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) ...@@ -1609,14 +1609,14 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs)
qp->uobject = &obj->uevent.uobject; qp->uobject = &obj->uevent.uobject;
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
return uobj_alloc_commit(&obj->uevent.uobject); return uobj_alloc_commit(&obj->uevent.uobject, attrs);
err_destroy: err_destroy:
ib_destroy_qp(qp); ib_destroy_qp(qp);
err_xrcd: err_xrcd:
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
err_put: err_put:
uobj_alloc_abort(&obj->uevent.uobject); uobj_alloc_abort(&obj->uevent.uobject, attrs);
return ret; return ret;
} }
...@@ -2451,7 +2451,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) ...@@ -2451,7 +2451,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs)
goto err_copy; goto err_copy;
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE); rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE);
...@@ -2460,7 +2460,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) ...@@ -2460,7 +2460,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
err: err:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
return ret; return ret;
} }
...@@ -2962,7 +2962,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) ...@@ -2962,7 +2962,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
uobj_put_obj_read(cq); uobj_put_obj_read(cq);
return uobj_alloc_commit(&obj->uevent.uobject); return uobj_alloc_commit(&obj->uevent.uobject, attrs);
err_copy: err_copy:
ib_destroy_wq(wq); ib_destroy_wq(wq);
...@@ -2971,7 +2971,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) ...@@ -2971,7 +2971,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
err_put_pd: err_put_pd:
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
err_uobj: err_uobj:
uobj_alloc_abort(&obj->uevent.uobject); uobj_alloc_abort(&obj->uevent.uobject, attrs);
return err; return err;
} }
...@@ -3136,12 +3136,12 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs) ...@@ -3136,12 +3136,12 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs)
for (j = 0; j < num_read_wqs; j++) for (j = 0; j < num_read_wqs; j++)
uobj_put_obj_read(wqs[j]); uobj_put_obj_read(wqs[j]);
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
ib_destroy_rwq_ind_table(rwq_ind_tbl); ib_destroy_rwq_ind_table(rwq_ind_tbl);
err_uobj: err_uobj:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
put_wqs: put_wqs:
for (j = 0; j < num_read_wqs; j++) for (j = 0; j < num_read_wqs; j++)
uobj_put_obj_read(wqs[j]); uobj_put_obj_read(wqs[j]);
...@@ -3314,7 +3314,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) ...@@ -3314,7 +3314,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)
kfree(flow_attr); kfree(flow_attr);
if (cmd.flow_attr.num_of_specs) if (cmd.flow_attr.num_of_specs)
kfree(kern_flow_attr); kfree(kern_flow_attr);
return uobj_alloc_commit(uobj); return uobj_alloc_commit(uobj, attrs);
err_copy: err_copy:
if (!qp->device->ops.destroy_flow(flow_id)) if (!qp->device->ops.destroy_flow(flow_id))
atomic_dec(&qp->usecnt); atomic_dec(&qp->usecnt);
...@@ -3325,7 +3325,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) ...@@ -3325,7 +3325,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)
err_put: err_put:
uobj_put_obj_read(qp); uobj_put_obj_read(qp);
err_uobj: err_uobj:
uobj_alloc_abort(uobj); uobj_alloc_abort(uobj, attrs);
err_free_attr: err_free_attr:
if (cmd.flow_attr.num_of_specs) if (cmd.flow_attr.num_of_specs)
kfree(kern_flow_attr); kfree(kern_flow_attr);
...@@ -3458,7 +3458,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3458,7 +3458,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(attr.ext.cq); uobj_put_obj_read(attr.ext.cq);
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(&obj->uevent.uobject); return uobj_alloc_commit(&obj->uevent.uobject, attrs);
err_copy: err_copy:
ib_destroy_srq(srq); ib_destroy_srq(srq);
...@@ -3477,7 +3477,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3477,7 +3477,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
} }
err: err:
uobj_alloc_abort(&obj->uevent.uobject); uobj_alloc_abort(&obj->uevent.uobject, attrs);
return ret; return ret;
} }
......
...@@ -222,7 +222,7 @@ static int uverbs_process_idrs_array(struct bundle_priv *pbundle, ...@@ -222,7 +222,7 @@ static int uverbs_process_idrs_array(struct bundle_priv *pbundle,
static int uverbs_free_idrs_array(const struct uverbs_api_attr *attr_uapi, static int uverbs_free_idrs_array(const struct uverbs_api_attr *attr_uapi,
struct uverbs_objs_arr_attr *attr, struct uverbs_objs_arr_attr *attr,
bool commit) bool commit, struct uverbs_attr_bundle *attrs)
{ {
const struct uverbs_attr_spec *spec = &attr_uapi->spec; const struct uverbs_attr_spec *spec = &attr_uapi->spec;
int current_ret; int current_ret;
...@@ -230,8 +230,9 @@ static int uverbs_free_idrs_array(const struct uverbs_api_attr *attr_uapi, ...@@ -230,8 +230,9 @@ static int uverbs_free_idrs_array(const struct uverbs_api_attr *attr_uapi,
size_t i; size_t i;
for (i = 0; i != attr->len; i++) { for (i = 0; i != attr->len; i++) {
current_ret = uverbs_finalize_object( current_ret = uverbs_finalize_object(attr->uobjects[i],
attr->uobjects[i], spec->u2.objs_arr.access, commit); spec->u2.objs_arr.access,
commit, attrs);
if (!ret) if (!ret)
ret = current_ret; ret = current_ret;
} }
...@@ -457,7 +458,7 @@ static int ib_uverbs_run_method(struct bundle_priv *pbundle, ...@@ -457,7 +458,7 @@ static int ib_uverbs_run_method(struct bundle_priv *pbundle,
struct uverbs_obj_attr *destroy_attr = struct uverbs_obj_attr *destroy_attr =
&pbundle->bundle.attrs[destroy_bkey].obj_attr; &pbundle->bundle.attrs[destroy_bkey].obj_attr;
ret = uobj_destroy(destroy_attr->uobject); ret = uobj_destroy(destroy_attr->uobject, &pbundle->bundle);
if (ret) if (ret)
return ret; return ret;
__clear_bit(destroy_bkey, pbundle->uobj_finalize); __clear_bit(destroy_bkey, pbundle->uobj_finalize);
...@@ -508,7 +509,8 @@ static int bundle_destroy(struct bundle_priv *pbundle, bool commit) ...@@ -508,7 +509,8 @@ static int bundle_destroy(struct bundle_priv *pbundle, bool commit)
current_ret = uverbs_finalize_object( current_ret = uverbs_finalize_object(
attr->obj_attr.uobject, attr->obj_attr.uobject,
attr->obj_attr.attr_elm->spec.u.obj.access, commit); attr->obj_attr.attr_elm->spec.u.obj.access, commit,
&pbundle->bundle);
if (!ret) if (!ret)
ret = current_ret; ret = current_ret;
} }
...@@ -531,7 +533,8 @@ static int bundle_destroy(struct bundle_priv *pbundle, bool commit) ...@@ -531,7 +533,8 @@ static int bundle_destroy(struct bundle_priv *pbundle, bool commit)
if (attr_uapi->spec.type == UVERBS_ATTR_TYPE_IDRS_ARRAY) { if (attr_uapi->spec.type == UVERBS_ATTR_TYPE_IDRS_ARRAY) {
current_ret = uverbs_free_idrs_array( current_ret = uverbs_free_idrs_array(
attr_uapi, &attr->objs_arr_attr, commit); attr_uapi, &attr->objs_arr_attr, commit,
&pbundle->bundle);
if (!ret) if (!ret)
ret = current_ret; ret = current_ret;
} }
......
...@@ -40,14 +40,16 @@ ...@@ -40,14 +40,16 @@
#include "uverbs.h" #include "uverbs.h"
static int uverbs_free_ah(struct ib_uobject *uobject, static int uverbs_free_ah(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
return rdma_destroy_ah((struct ib_ah *)uobject->object, return rdma_destroy_ah((struct ib_ah *)uobject->object,
RDMA_DESTROY_AH_SLEEPABLE); RDMA_DESTROY_AH_SLEEPABLE);
} }
static int uverbs_free_flow(struct ib_uobject *uobject, static int uverbs_free_flow(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_flow *flow = (struct ib_flow *)uobject->object; struct ib_flow *flow = (struct ib_flow *)uobject->object;
struct ib_uflow_object *uflow = struct ib_uflow_object *uflow =
...@@ -66,13 +68,15 @@ static int uverbs_free_flow(struct ib_uobject *uobject, ...@@ -66,13 +68,15 @@ static int uverbs_free_flow(struct ib_uobject *uobject,
} }
static int uverbs_free_mw(struct ib_uobject *uobject, static int uverbs_free_mw(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
return uverbs_dealloc_mw((struct ib_mw *)uobject->object); return uverbs_dealloc_mw((struct ib_mw *)uobject->object);
} }
static int uverbs_free_qp(struct ib_uobject *uobject, static int uverbs_free_qp(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_qp *qp = uobject->object; struct ib_qp *qp = uobject->object;
struct ib_uqp_object *uqp = struct ib_uqp_object *uqp =
...@@ -105,7 +109,8 @@ static int uverbs_free_qp(struct ib_uobject *uobject, ...@@ -105,7 +109,8 @@ static int uverbs_free_qp(struct ib_uobject *uobject,
} }
static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject, static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_rwq_ind_table *rwq_ind_tbl = uobject->object; struct ib_rwq_ind_table *rwq_ind_tbl = uobject->object;
struct ib_wq **ind_tbl = rwq_ind_tbl->ind_tbl; struct ib_wq **ind_tbl = rwq_ind_tbl->ind_tbl;
...@@ -120,7 +125,8 @@ static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject, ...@@ -120,7 +125,8 @@ static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject,
} }
static int uverbs_free_wq(struct ib_uobject *uobject, static int uverbs_free_wq(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_wq *wq = uobject->object; struct ib_wq *wq = uobject->object;
struct ib_uwq_object *uwq = struct ib_uwq_object *uwq =
...@@ -136,7 +142,8 @@ static int uverbs_free_wq(struct ib_uobject *uobject, ...@@ -136,7 +142,8 @@ static int uverbs_free_wq(struct ib_uobject *uobject,
} }
static int uverbs_free_srq(struct ib_uobject *uobject, static int uverbs_free_srq(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_srq *srq = uobject->object; struct ib_srq *srq = uobject->object;
struct ib_uevent_object *uevent = struct ib_uevent_object *uevent =
...@@ -160,7 +167,8 @@ static int uverbs_free_srq(struct ib_uobject *uobject, ...@@ -160,7 +167,8 @@ static int uverbs_free_srq(struct ib_uobject *uobject,
} }
static int uverbs_free_xrcd(struct ib_uobject *uobject, static int uverbs_free_xrcd(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_xrcd *xrcd = uobject->object; struct ib_xrcd *xrcd = uobject->object;
struct ib_uxrcd_object *uxrcd = struct ib_uxrcd_object *uxrcd =
...@@ -179,7 +187,8 @@ static int uverbs_free_xrcd(struct ib_uobject *uobject, ...@@ -179,7 +187,8 @@ static int uverbs_free_xrcd(struct ib_uobject *uobject,
} }
static int uverbs_free_pd(struct ib_uobject *uobject, static int uverbs_free_pd(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_pd *pd = uobject->object; struct ib_pd *pd = uobject->object;
int ret; int ret;
......
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
#include <rdma/uverbs_std_types.h> #include <rdma/uverbs_std_types.h>
static int uverbs_free_counters(struct ib_uobject *uobject, static int uverbs_free_counters(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_counters *counters = uobject->object; struct ib_counters *counters = uobject->object;
int ret; int ret;
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#include "uverbs.h" #include "uverbs.h"
static int uverbs_free_cq(struct ib_uobject *uobject, static int uverbs_free_cq(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_cq *cq = uobject->object; struct ib_cq *cq = uobject->object;
struct ib_uverbs_event_queue *ev_queue = cq->cq_context; struct ib_uverbs_event_queue *ev_queue = cq->cq_context;
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#include <rdma/uverbs_std_types.h> #include <rdma/uverbs_std_types.h>
static int uverbs_free_dm(struct ib_uobject *uobject, static int uverbs_free_dm(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_dm *dm = uobject->object; struct ib_dm *dm = uobject->object;
int ret; int ret;
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#include <rdma/uverbs_std_types.h> #include <rdma/uverbs_std_types.h>
static int uverbs_free_flow_action(struct ib_uobject *uobject, static int uverbs_free_flow_action(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct ib_flow_action *action = uobject->object; struct ib_flow_action *action = uobject->object;
int ret; int ret;
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#include <rdma/uverbs_std_types.h> #include <rdma/uverbs_std_types.h>
static int uverbs_free_mr(struct ib_uobject *uobject, static int uverbs_free_mr(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
return ib_dereg_mr((struct ib_mr *)uobject->object); return ib_dereg_mr((struct ib_mr *)uobject->object);
} }
......
...@@ -1117,7 +1117,8 @@ static void devx_cleanup_mkey(struct devx_obj *obj) ...@@ -1117,7 +1117,8 @@ static void devx_cleanup_mkey(struct devx_obj *obj)
} }
static int devx_obj_cleanup(struct ib_uobject *uobject, static int devx_obj_cleanup(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)];
struct devx_obj *obj = uobject->object; struct devx_obj *obj = uobject->object;
...@@ -1599,7 +1600,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)( ...@@ -1599,7 +1600,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)(
} }
static int devx_umem_cleanup(struct ib_uobject *uobject, static int devx_umem_cleanup(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct devx_umem *obj = uobject->object; struct devx_umem *obj = uobject->object;
u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)];
......
...@@ -189,7 +189,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( ...@@ -189,7 +189,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
} }
static int flow_matcher_cleanup(struct ib_uobject *uobject, static int flow_matcher_cleanup(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs)
{ {
struct mlx5_ib_flow_matcher *obj = uobject->object; struct mlx5_ib_flow_matcher *obj = uobject->object;
int ret; int ret;
......
...@@ -104,18 +104,20 @@ static inline void uobj_put_write(struct ib_uobject *uobj) ...@@ -104,18 +104,20 @@ static inline void uobj_put_write(struct ib_uobject *uobj)
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE);
} }
static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj) static inline int __must_check
uobj_alloc_commit(struct ib_uobject *uobj, struct uverbs_attr_bundle *attrs)
{ {
int ret = rdma_alloc_commit_uobject(uobj); int ret = rdma_alloc_commit_uobject(uobj, attrs);
if (ret) if (ret)
return ret; return ret;
return 0; return 0;
} }
static inline void uobj_alloc_abort(struct ib_uobject *uobj) static inline void uobj_alloc_abort(struct ib_uobject *uobj,
struct uverbs_attr_bundle *attrs)
{ {
rdma_alloc_abort_uobject(uobj); rdma_alloc_abort_uobject(uobj, attrs);
} }
static inline struct ib_uobject * static inline struct ib_uobject *
......
...@@ -95,7 +95,8 @@ struct uverbs_obj_type_class { ...@@ -95,7 +95,8 @@ struct uverbs_obj_type_class {
void (*lookup_put)(struct ib_uobject *uobj, enum rdma_lookup_mode mode); void (*lookup_put)(struct ib_uobject *uobj, enum rdma_lookup_mode mode);
/* This does not consume the kref on uobj */ /* This does not consume the kref on uobj */
int __must_check (*destroy_hw)(struct ib_uobject *uobj, int __must_check (*destroy_hw)(struct ib_uobject *uobj,
enum rdma_remove_reason why); enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs);
void (*remove_handle)(struct ib_uobject *uobj); void (*remove_handle)(struct ib_uobject *uobj);
u8 needs_kfree_rcu; u8 needs_kfree_rcu;
}; };
...@@ -126,7 +127,8 @@ struct uverbs_obj_idr_type { ...@@ -126,7 +127,8 @@ struct uverbs_obj_idr_type {
* completely unchanged. * completely unchanged.
*/ */
int __must_check (*destroy_object)(struct ib_uobject *uobj, int __must_check (*destroy_object)(struct ib_uobject *uobj,
enum rdma_remove_reason why); enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs);
}; };
struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_api_object *obj, struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_api_object *obj,
...@@ -138,8 +140,10 @@ void rdma_lookup_put_uobject(struct ib_uobject *uobj, ...@@ -138,8 +140,10 @@ void rdma_lookup_put_uobject(struct ib_uobject *uobj,
struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_api_object *obj, struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_api_object *obj,
struct ib_uverbs_file *ufile, struct ib_uverbs_file *ufile,
struct uverbs_attr_bundle *attrs); struct uverbs_attr_bundle *attrs);
void rdma_alloc_abort_uobject(struct ib_uobject *uobj); void rdma_alloc_abort_uobject(struct ib_uobject *uobj,
int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj); struct uverbs_attr_bundle *attrs);
int __must_check rdma_alloc_commit_uobject(struct ib_uobject *uobj,
struct uverbs_attr_bundle *attrs);
struct uverbs_obj_fd_type { struct uverbs_obj_fd_type {
/* /*
......
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