Commit 8efe991e authored by Jason Gunthorpe's avatar Jason Gunthorpe

IB/uverbs: Tidy uverbs_uobject_add

Maintaining the uobjects list is mandatory, hoist it into the common
rdma_alloc_commit_uobject() function and inline it as there is now
only one caller.
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 1d1ab1ae
...@@ -350,13 +350,6 @@ struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_obj_type *type, ...@@ -350,13 +350,6 @@ struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_obj_type *type,
return type->type_class->alloc_begin(type, ucontext); return type->type_class->alloc_begin(type, ucontext);
} }
static void uverbs_uobject_add(struct ib_uobject *uobject)
{
mutex_lock(&uobject->context->uobjects_lock);
list_add(&uobject->list, &uobject->context->uobjects);
mutex_unlock(&uobject->context->uobjects_lock);
}
static int __must_check remove_commit_idr_uobject(struct ib_uobject *uobj, static int __must_check remove_commit_idr_uobject(struct ib_uobject *uobj,
enum rdma_remove_reason why) enum rdma_remove_reason why)
{ {
...@@ -502,7 +495,6 @@ int rdma_explicit_destroy(struct ib_uobject *uobject) ...@@ -502,7 +495,6 @@ int rdma_explicit_destroy(struct ib_uobject *uobject)
static void alloc_commit_idr_uobject(struct ib_uobject *uobj) static void alloc_commit_idr_uobject(struct ib_uobject *uobj)
{ {
uverbs_uobject_add(uobj);
spin_lock(&uobj->context->ufile->idr_lock); spin_lock(&uobj->context->ufile->idr_lock);
/* /*
* We already allocated this IDR with a NULL object, so * We already allocated this IDR with a NULL object, so
...@@ -518,7 +510,6 @@ static void alloc_commit_fd_uobject(struct ib_uobject *uobj) ...@@ -518,7 +510,6 @@ static void alloc_commit_fd_uobject(struct ib_uobject *uobj)
struct ib_uobject_file *uobj_file = struct ib_uobject_file *uobj_file =
container_of(uobj, struct ib_uobject_file, uobj); container_of(uobj, struct ib_uobject_file, uobj);
uverbs_uobject_add(&uobj_file->uobj);
fd_install(uobj_file->uobj.id, uobj->object); fd_install(uobj_file->uobj.id, uobj->object);
/* This shouldn't be used anymore. Use the file object instead */ /* This shouldn't be used anymore. Use the file object instead */
uobj_file->uobj.id = 0; uobj_file->uobj.id = 0;
...@@ -545,6 +536,10 @@ int rdma_alloc_commit_uobject(struct ib_uobject *uobj) ...@@ -545,6 +536,10 @@ int rdma_alloc_commit_uobject(struct ib_uobject *uobj)
assert_uverbs_usecnt(uobj, true); assert_uverbs_usecnt(uobj, true);
atomic_set(&uobj->usecnt, 0); atomic_set(&uobj->usecnt, 0);
mutex_lock(&uobj->context->uobjects_lock);
list_add(&uobj->list, &uobj->context->uobjects);
mutex_unlock(&uobj->context->uobjects_lock);
uobj->type->type_class->alloc_commit(uobj); uobj->type->type_class->alloc_commit(uobj);
up_read(&uobj->context->cleanup_rwsem); up_read(&uobj->context->cleanup_rwsem);
......
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