aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/uverbs_cmd.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-01-08 20:05:33 +0200
committerJason Gunthorpe <jgg@mellanox.com>2020-01-16 15:55:45 -0400
commitda57db25677f8566a354b0d0e4973a0fdcabcf84 (patch)
treefb92069dc515e2f813156a3ed8d2a2046c13c95c /drivers/infiniband/core/uverbs_cmd.c
parentRDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC (diff)
downloadlinux-dev-da57db25677f8566a354b0d0e4973a0fdcabcf84.tar.xz
linux-dev-da57db25677f8566a354b0d0e4973a0fdcabcf84.zip
RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
This lock only serializes ucontext creation. Instead of checking the ucontext_lock during destruction hold the existing hw_destroy_rwsem during creation, which is the standard pattern for object creation. The simplification of locking is needed for the next patch. Link: https://lore.kernel.org/r/1578506740-22188-4-git-send-email-yishaih@mellanox.com Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to '')
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 29b1b5ad8836..d71ffe44b8ae 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -218,6 +218,8 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
if (ret)
return ret;
+ if (!down_read_trylock(&file->hw_destroy_rwsem))
+ return -EIO;
mutex_lock(&file->ucontext_lock);
ib_dev = srcu_dereference(file->device->ib_dev,
&file->device->disassociate_srcu);
@@ -284,7 +286,7 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
smp_store_release(&file->ucontext, ucontext);
mutex_unlock(&file->ucontext_lock);
-
+ up_read(&file->hw_destroy_rwsem);
return 0;
err_uobj:
@@ -298,6 +300,7 @@ err_alloc:
err:
mutex_unlock(&file->ucontext_lock);
+ up_read(&file->hw_destroy_rwsem);
return ret;
}