aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/uverbs_main.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-01-08 20:05:34 +0200
committerJason Gunthorpe <jgg@mellanox.com>2020-01-16 15:55:45 -0400
commita1123418ba1078037d9fecb72573ff7222dfe201 (patch)
treea4e50f11d441719574089c2d0bd7e0d5c3aefde7 /drivers/infiniband/core/uverbs_main.c
parentRDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path (diff)
downloadlinux-dev-a1123418ba1078037d9fecb72573ff7222dfe201.tar.xz
linux-dev-a1123418ba1078037d9fecb72573ff7222dfe201.zip
RDMA/uverbs: Add ioctl command to get a device context
Allow future extensions of the get context command through the uverbs ioctl kabi. Unlike the uverbs version this does not return an async_fd as well, that has to be done with another command. Link: https://lore.kernel.org/r/1578506740-22188-5-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 'drivers/infiniband/core/uverbs_main.c')
-rw-r--r--drivers/infiniband/core/uverbs_main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index fb9e75257607..2d4083bf4a04 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -150,6 +150,9 @@ void ib_uverbs_release_uevent(struct ib_uevent_object *uobj)
READ_ONCE(uobj->uobject.ufile->async_file);
struct ib_uverbs_event *evt, *tmp;
+ if (!async_file)
+ return;
+
spin_lock_irq(&async_file->ev_queue.lock);
list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
list_del(&evt->list);
@@ -391,6 +394,9 @@ ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
struct ib_uverbs_event *entry;
unsigned long flags;
+ if (!async_file)
+ return;
+
spin_lock_irqsave(&async_file->ev_queue.lock, flags);
if (async_file->ev_queue.is_closed) {
spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
@@ -476,12 +482,13 @@ void ib_uverbs_init_async_event_file(
ib_uverbs_init_event_queue(&async_file->ev_queue);
/* The first async_event_file becomes the default one for the file. */
- lockdep_assert_held(&uverbs_file->ucontext_lock);
+ mutex_lock(&uverbs_file->ucontext_lock);
if (!uverbs_file->async_file) {
/* Pairs with the put in ib_uverbs_release_file */
uverbs_uobject_get(&async_file->uobj);
smp_store_release(&uverbs_file->async_file, async_file);
}
+ mutex_unlock(&uverbs_file->ucontext_lock);
INIT_IB_EVENT_HANDLER(&async_file->event_handler, ib_dev,
ib_uverbs_event_handler);