aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2020-08-18 15:05:24 +0300
committerJason Gunthorpe <jgg@nvidia.com>2020-08-27 08:38:16 -0300
commit310ca1a7dcd1fd430f0d72e774d480cc200b4fdc (patch)
treeb8057e00e25a2adf341140f478ef1c4d0a32582a /drivers/infiniband/core
parentRDMA/ucma: Change backlog into an atomic (diff)
downloadlinux-dev-310ca1a7dcd1fd430f0d72e774d480cc200b4fdc.tar.xz
linux-dev-310ca1a7dcd1fd430f0d72e774d480cc200b4fdc.zip
RDMA/ucma: Narrow file->mut in ucma_event_handler()
Since the backlog is now an atomic the file->mut is now only protecting the event_list and ctx_list. Narrow its scope to make it clear Link: https://lore.kernel.org/r/20200818120526.702120-13-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/ucma.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 8be8ff14ab62..32e82bcffccd 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -283,7 +283,6 @@ static void ucma_set_event_context(struct ucma_context *ctx,
}
}
-/* Called with file->mut locked for the relevant context. */
static void ucma_removal_event_handler(struct rdma_cm_id *cm_id)
{
struct ucma_context *ctx = cm_id->context;
@@ -307,6 +306,7 @@ static void ucma_removal_event_handler(struct rdma_cm_id *cm_id)
return;
}
+ mutex_lock(&ctx->file->mut);
list_for_each_entry(con_req_eve, &ctx->file->event_list, list) {
if (con_req_eve->cm_id == cm_id &&
con_req_eve->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST) {
@@ -317,6 +317,7 @@ static void ucma_removal_event_handler(struct rdma_cm_id *cm_id)
break;
}
}
+ mutex_unlock(&ctx->file->mut);
if (!event_found)
pr_err("ucma_removal_event_handler: warning: connect request event wasn't found\n");
}
@@ -326,13 +327,11 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
{
struct ucma_event *uevent;
struct ucma_context *ctx = cm_id->context;
- int ret = 0;
uevent = kzalloc(sizeof(*uevent), GFP_KERNEL);
if (!uevent)
return event->event == RDMA_CM_EVENT_CONNECT_REQUEST;
- mutex_lock(&ctx->file->mut);
uevent->cm_id = cm_id;
ucma_set_event_context(ctx, event, uevent);
uevent->resp.event = event->event;
@@ -349,9 +348,8 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST) {
if (!atomic_add_unless(&ctx->backlog, -1, 0)) {
- ret = -ENOMEM;
kfree(uevent);
- goto out;
+ return -ENOMEM;
}
} else if (!ctx->uid || ctx->cm_id != cm_id) {
/*
@@ -366,16 +364,16 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
ucma_removal_event_handler(cm_id);
kfree(uevent);
- goto out;
+ return 0;
}
+ mutex_lock(&ctx->file->mut);
list_add_tail(&uevent->list, &ctx->file->event_list);
+ mutex_unlock(&ctx->file->mut);
wake_up_interruptible(&ctx->file->poll_wait);
if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
ucma_removal_event_handler(cm_id);
-out:
- mutex_unlock(&ctx->file->mut);
- return ret;
+ return 0;
}
static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf,