diff options
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/ucm.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 0136aee0faa7..67caf36504ee 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -64,7 +64,7 @@ struct ib_ucm_device { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | struct ib_ucm_file { | 66 | struct ib_ucm_file { |
67 | struct semaphore mutex; | 67 | struct mutex file_mutex; |
68 | struct file *filp; | 68 | struct file *filp; |
69 | struct ib_ucm_device *device; | 69 | struct ib_ucm_device *device; |
70 | 70 | ||
@@ -153,7 +153,7 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx) | |||
153 | { | 153 | { |
154 | struct ib_ucm_event *uevent; | 154 | struct ib_ucm_event *uevent; |
155 | 155 | ||
156 | down(&ctx->file->mutex); | 156 | mutex_lock(&ctx->file->file_mutex); |
157 | list_del(&ctx->file_list); | 157 | list_del(&ctx->file_list); |
158 | while (!list_empty(&ctx->events)) { | 158 | while (!list_empty(&ctx->events)) { |
159 | 159 | ||
@@ -168,7 +168,7 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx) | |||
168 | 168 | ||
169 | kfree(uevent); | 169 | kfree(uevent); |
170 | } | 170 | } |
171 | up(&ctx->file->mutex); | 171 | mutex_unlock(&ctx->file->file_mutex); |
172 | } | 172 | } |
173 | 173 | ||
174 | static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) | 174 | static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) |
@@ -375,11 +375,11 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id, | |||
375 | if (result) | 375 | if (result) |
376 | goto err2; | 376 | goto err2; |
377 | 377 | ||
378 | down(&ctx->file->mutex); | 378 | mutex_lock(&ctx->file->file_mutex); |
379 | list_add_tail(&uevent->file_list, &ctx->file->events); | 379 | list_add_tail(&uevent->file_list, &ctx->file->events); |
380 | list_add_tail(&uevent->ctx_list, &ctx->events); | 380 | list_add_tail(&uevent->ctx_list, &ctx->events); |
381 | wake_up_interruptible(&ctx->file->poll_wait); | 381 | wake_up_interruptible(&ctx->file->poll_wait); |
382 | up(&ctx->file->mutex); | 382 | mutex_unlock(&ctx->file->file_mutex); |
383 | return 0; | 383 | return 0; |
384 | 384 | ||
385 | err2: | 385 | err2: |
@@ -405,7 +405,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, | |||
405 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) | 405 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) |
406 | return -EFAULT; | 406 | return -EFAULT; |
407 | 407 | ||
408 | down(&file->mutex); | 408 | mutex_lock(&file->file_mutex); |
409 | while (list_empty(&file->events)) { | 409 | while (list_empty(&file->events)) { |
410 | 410 | ||
411 | if (file->filp->f_flags & O_NONBLOCK) { | 411 | if (file->filp->f_flags & O_NONBLOCK) { |
@@ -420,9 +420,9 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, | |||
420 | 420 | ||
421 | prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE); | 421 | prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE); |
422 | 422 | ||
423 | up(&file->mutex); | 423 | mutex_unlock(&file->file_mutex); |
424 | schedule(); | 424 | schedule(); |
425 | down(&file->mutex); | 425 | mutex_lock(&file->file_mutex); |
426 | 426 | ||
427 | finish_wait(&file->poll_wait, &wait); | 427 | finish_wait(&file->poll_wait, &wait); |
428 | } | 428 | } |
@@ -482,7 +482,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, | |||
482 | kfree(uevent->info); | 482 | kfree(uevent->info); |
483 | kfree(uevent); | 483 | kfree(uevent); |
484 | done: | 484 | done: |
485 | up(&file->mutex); | 485 | mutex_unlock(&file->file_mutex); |
486 | return result; | 486 | return result; |
487 | } | 487 | } |
488 | 488 | ||
@@ -501,9 +501,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, | |||
501 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) | 501 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) |
502 | return -EFAULT; | 502 | return -EFAULT; |
503 | 503 | ||
504 | down(&file->mutex); | 504 | mutex_lock(&file->file_mutex); |
505 | ctx = ib_ucm_ctx_alloc(file); | 505 | ctx = ib_ucm_ctx_alloc(file); |
506 | up(&file->mutex); | 506 | mutex_unlock(&file->file_mutex); |
507 | if (!ctx) | 507 | if (!ctx) |
508 | return -ENOMEM; | 508 | return -ENOMEM; |
509 | 509 | ||
@@ -1177,7 +1177,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) | |||
1177 | INIT_LIST_HEAD(&file->ctxs); | 1177 | INIT_LIST_HEAD(&file->ctxs); |
1178 | init_waitqueue_head(&file->poll_wait); | 1178 | init_waitqueue_head(&file->poll_wait); |
1179 | 1179 | ||
1180 | init_MUTEX(&file->mutex); | 1180 | mutex_init(&file->file_mutex); |
1181 | 1181 | ||
1182 | filp->private_data = file; | 1182 | filp->private_data = file; |
1183 | file->filp = filp; | 1183 | file->filp = filp; |
@@ -1191,11 +1191,11 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) | |||
1191 | struct ib_ucm_file *file = filp->private_data; | 1191 | struct ib_ucm_file *file = filp->private_data; |
1192 | struct ib_ucm_context *ctx; | 1192 | struct ib_ucm_context *ctx; |
1193 | 1193 | ||
1194 | down(&file->mutex); | 1194 | mutex_lock(&file->file_mutex); |
1195 | while (!list_empty(&file->ctxs)) { | 1195 | while (!list_empty(&file->ctxs)) { |
1196 | ctx = list_entry(file->ctxs.next, | 1196 | ctx = list_entry(file->ctxs.next, |
1197 | struct ib_ucm_context, file_list); | 1197 | struct ib_ucm_context, file_list); |
1198 | up(&file->mutex); | 1198 | mutex_unlock(&file->file_mutex); |
1199 | 1199 | ||
1200 | mutex_lock(&ctx_id_mutex); | 1200 | mutex_lock(&ctx_id_mutex); |
1201 | idr_remove(&ctx_id_table, ctx->id); | 1201 | idr_remove(&ctx_id_table, ctx->id); |
@@ -1205,9 +1205,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) | |||
1205 | ib_ucm_cleanup_events(ctx); | 1205 | ib_ucm_cleanup_events(ctx); |
1206 | kfree(ctx); | 1206 | kfree(ctx); |
1207 | 1207 | ||
1208 | down(&file->mutex); | 1208 | mutex_lock(&file->file_mutex); |
1209 | } | 1209 | } |
1210 | up(&file->mutex); | 1210 | mutex_unlock(&file->file_mutex); |
1211 | kfree(file); | 1211 | kfree(file); |
1212 | return 0; | 1212 | return 0; |
1213 | } | 1213 | } |