diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-01-13 17:51:39 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-01-13 17:51:39 -0500 |
commit | 95ed644fd12f53c6fc778f3f246974e5fe3a9468 (patch) | |
tree | edf9f57192ad95f9165b3be5dbf1e8e745249ed1 /drivers/infiniband/core | |
parent | 9eacee2ac624bfa9740d49355dbe6ee88d0cba0a (diff) |
IB: convert from semaphores to mutexes
semaphore to mutex conversion by Ingo and Arjan's script.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
[ Sanity-checked on real IB hardware ]
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r-- | drivers/infiniband/core/device.c | 23 | ||||
-rw-r--r-- | drivers/infiniband/core/ucm.c | 23 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 5 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 150 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 8 |
5 files changed, 105 insertions, 104 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index e169e798354b..b2f3cb91d9bc 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -38,8 +38,7 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | 41 | #include <linux/mutex.h> | |
42 | #include <asm/semaphore.h> | ||
43 | 42 | ||
44 | #include "core_priv.h" | 43 | #include "core_priv.h" |
45 | 44 | ||
@@ -57,13 +56,13 @@ static LIST_HEAD(device_list); | |||
57 | static LIST_HEAD(client_list); | 56 | static LIST_HEAD(client_list); |
58 | 57 | ||
59 | /* | 58 | /* |
60 | * device_sem protects access to both device_list and client_list. | 59 | * device_mutex protects access to both device_list and client_list. |
61 | * There's no real point to using multiple locks or something fancier | 60 | * There's no real point to using multiple locks or something fancier |
62 | * like an rwsem: we always access both lists, and we're always | 61 | * like an rwsem: we always access both lists, and we're always |
63 | * modifying one list or the other list. In any case this is not a | 62 | * modifying one list or the other list. In any case this is not a |
64 | * hot path so there's no point in trying to optimize. | 63 | * hot path so there's no point in trying to optimize. |
65 | */ | 64 | */ |
66 | static DECLARE_MUTEX(device_sem); | 65 | static DEFINE_MUTEX(device_mutex); |
67 | 66 | ||
68 | static int ib_device_check_mandatory(struct ib_device *device) | 67 | static int ib_device_check_mandatory(struct ib_device *device) |
69 | { | 68 | { |
@@ -221,7 +220,7 @@ int ib_register_device(struct ib_device *device) | |||
221 | { | 220 | { |
222 | int ret; | 221 | int ret; |
223 | 222 | ||
224 | down(&device_sem); | 223 | mutex_lock(&device_mutex); |
225 | 224 | ||
226 | if (strchr(device->name, '%')) { | 225 | if (strchr(device->name, '%')) { |
227 | ret = alloc_name(device->name); | 226 | ret = alloc_name(device->name); |
@@ -259,7 +258,7 @@ int ib_register_device(struct ib_device *device) | |||
259 | } | 258 | } |
260 | 259 | ||
261 | out: | 260 | out: |
262 | up(&device_sem); | 261 | mutex_unlock(&device_mutex); |
263 | return ret; | 262 | return ret; |
264 | } | 263 | } |
265 | EXPORT_SYMBOL(ib_register_device); | 264 | EXPORT_SYMBOL(ib_register_device); |
@@ -276,7 +275,7 @@ void ib_unregister_device(struct ib_device *device) | |||
276 | struct ib_client_data *context, *tmp; | 275 | struct ib_client_data *context, *tmp; |
277 | unsigned long flags; | 276 | unsigned long flags; |
278 | 277 | ||
279 | down(&device_sem); | 278 | mutex_lock(&device_mutex); |
280 | 279 | ||
281 | list_for_each_entry_reverse(client, &client_list, list) | 280 | list_for_each_entry_reverse(client, &client_list, list) |
282 | if (client->remove) | 281 | if (client->remove) |
@@ -284,7 +283,7 @@ void ib_unregister_device(struct ib_device *device) | |||
284 | 283 | ||
285 | list_del(&device->core_list); | 284 | list_del(&device->core_list); |
286 | 285 | ||
287 | up(&device_sem); | 286 | mutex_unlock(&device_mutex); |
288 | 287 | ||
289 | spin_lock_irqsave(&device->client_data_lock, flags); | 288 | spin_lock_irqsave(&device->client_data_lock, flags); |
290 | list_for_each_entry_safe(context, tmp, &device->client_data_list, list) | 289 | list_for_each_entry_safe(context, tmp, &device->client_data_list, list) |
@@ -312,14 +311,14 @@ int ib_register_client(struct ib_client *client) | |||
312 | { | 311 | { |
313 | struct ib_device *device; | 312 | struct ib_device *device; |
314 | 313 | ||
315 | down(&device_sem); | 314 | mutex_lock(&device_mutex); |
316 | 315 | ||
317 | list_add_tail(&client->list, &client_list); | 316 | list_add_tail(&client->list, &client_list); |
318 | list_for_each_entry(device, &device_list, core_list) | 317 | list_for_each_entry(device, &device_list, core_list) |
319 | if (client->add && !add_client_context(device, client)) | 318 | if (client->add && !add_client_context(device, client)) |
320 | client->add(device); | 319 | client->add(device); |
321 | 320 | ||
322 | up(&device_sem); | 321 | mutex_unlock(&device_mutex); |
323 | 322 | ||
324 | return 0; | 323 | return 0; |
325 | } | 324 | } |
@@ -339,7 +338,7 @@ void ib_unregister_client(struct ib_client *client) | |||
339 | struct ib_device *device; | 338 | struct ib_device *device; |
340 | unsigned long flags; | 339 | unsigned long flags; |
341 | 340 | ||
342 | down(&device_sem); | 341 | mutex_lock(&device_mutex); |
343 | 342 | ||
344 | list_for_each_entry(device, &device_list, core_list) { | 343 | list_for_each_entry(device, &device_list, core_list) { |
345 | if (client->remove) | 344 | if (client->remove) |
@@ -355,7 +354,7 @@ void ib_unregister_client(struct ib_client *client) | |||
355 | } | 354 | } |
356 | list_del(&client->list); | 355 | list_del(&client->list); |
357 | 356 | ||
358 | up(&device_sem); | 357 | mutex_unlock(&device_mutex); |
359 | } | 358 | } |
360 | EXPORT_SYMBOL(ib_unregister_client); | 359 | EXPORT_SYMBOL(ib_unregister_client); |
361 | 360 | ||
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 6e15787d1de1..e95c4293a496 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/mount.h> | 42 | #include <linux/mount.h> |
43 | #include <linux/cdev.h> | 43 | #include <linux/cdev.h> |
44 | #include <linux/idr.h> | 44 | #include <linux/idr.h> |
45 | #include <linux/mutex.h> | ||
45 | 46 | ||
46 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
47 | 48 | ||
@@ -113,7 +114,7 @@ static struct ib_client ucm_client = { | |||
113 | .remove = ib_ucm_remove_one | 114 | .remove = ib_ucm_remove_one |
114 | }; | 115 | }; |
115 | 116 | ||
116 | static DECLARE_MUTEX(ctx_id_mutex); | 117 | static DEFINE_MUTEX(ctx_id_mutex); |
117 | static DEFINE_IDR(ctx_id_table); | 118 | static DEFINE_IDR(ctx_id_table); |
118 | static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES); | 119 | static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES); |
119 | 120 | ||
@@ -121,7 +122,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) | |||
121 | { | 122 | { |
122 | struct ib_ucm_context *ctx; | 123 | struct ib_ucm_context *ctx; |
123 | 124 | ||
124 | down(&ctx_id_mutex); | 125 | mutex_lock(&ctx_id_mutex); |
125 | ctx = idr_find(&ctx_id_table, id); | 126 | ctx = idr_find(&ctx_id_table, id); |
126 | if (!ctx) | 127 | if (!ctx) |
127 | ctx = ERR_PTR(-ENOENT); | 128 | ctx = ERR_PTR(-ENOENT); |
@@ -129,7 +130,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) | |||
129 | ctx = ERR_PTR(-EINVAL); | 130 | ctx = ERR_PTR(-EINVAL); |
130 | else | 131 | else |
131 | atomic_inc(&ctx->ref); | 132 | atomic_inc(&ctx->ref); |
132 | up(&ctx_id_mutex); | 133 | mutex_unlock(&ctx_id_mutex); |
133 | 134 | ||
134 | return ctx; | 135 | return ctx; |
135 | } | 136 | } |
@@ -186,9 +187,9 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) | |||
186 | if (!result) | 187 | if (!result) |
187 | goto error; | 188 | goto error; |
188 | 189 | ||
189 | down(&ctx_id_mutex); | 190 | mutex_lock(&ctx_id_mutex); |
190 | result = idr_get_new(&ctx_id_table, ctx, &ctx->id); | 191 | result = idr_get_new(&ctx_id_table, ctx, &ctx->id); |
191 | up(&ctx_id_mutex); | 192 | mutex_unlock(&ctx_id_mutex); |
192 | } while (result == -EAGAIN); | 193 | } while (result == -EAGAIN); |
193 | 194 | ||
194 | if (result) | 195 | if (result) |
@@ -550,9 +551,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, | |||
550 | err2: | 551 | err2: |
551 | ib_destroy_cm_id(ctx->cm_id); | 552 | ib_destroy_cm_id(ctx->cm_id); |
552 | err1: | 553 | err1: |
553 | down(&ctx_id_mutex); | 554 | mutex_lock(&ctx_id_mutex); |
554 | idr_remove(&ctx_id_table, ctx->id); | 555 | idr_remove(&ctx_id_table, ctx->id); |
555 | up(&ctx_id_mutex); | 556 | mutex_unlock(&ctx_id_mutex); |
556 | kfree(ctx); | 557 | kfree(ctx); |
557 | return result; | 558 | return result; |
558 | } | 559 | } |
@@ -572,7 +573,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, | |||
572 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) | 573 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) |
573 | return -EFAULT; | 574 | return -EFAULT; |
574 | 575 | ||
575 | down(&ctx_id_mutex); | 576 | mutex_lock(&ctx_id_mutex); |
576 | ctx = idr_find(&ctx_id_table, cmd.id); | 577 | ctx = idr_find(&ctx_id_table, cmd.id); |
577 | if (!ctx) | 578 | if (!ctx) |
578 | ctx = ERR_PTR(-ENOENT); | 579 | ctx = ERR_PTR(-ENOENT); |
@@ -580,7 +581,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, | |||
580 | ctx = ERR_PTR(-EINVAL); | 581 | ctx = ERR_PTR(-EINVAL); |
581 | else | 582 | else |
582 | idr_remove(&ctx_id_table, ctx->id); | 583 | idr_remove(&ctx_id_table, ctx->id); |
583 | up(&ctx_id_mutex); | 584 | mutex_unlock(&ctx_id_mutex); |
584 | 585 | ||
585 | if (IS_ERR(ctx)) | 586 | if (IS_ERR(ctx)) |
586 | return PTR_ERR(ctx); | 587 | return PTR_ERR(ctx); |
@@ -1280,9 +1281,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) | |||
1280 | struct ib_ucm_context, file_list); | 1281 | struct ib_ucm_context, file_list); |
1281 | up(&file->mutex); | 1282 | up(&file->mutex); |
1282 | 1283 | ||
1283 | down(&ctx_id_mutex); | 1284 | mutex_lock(&ctx_id_mutex); |
1284 | idr_remove(&ctx_id_table, ctx->id); | 1285 | idr_remove(&ctx_id_table, ctx->id); |
1285 | up(&ctx_id_mutex); | 1286 | mutex_unlock(&ctx_id_mutex); |
1286 | 1287 | ||
1287 | ib_destroy_cm_id(ctx->cm_id); | 1288 | ib_destroy_cm_id(ctx->cm_id); |
1288 | ib_ucm_cleanup_events(ctx); | 1289 | ib_ucm_cleanup_events(ctx); |
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 7114e3fbab00..f7eecbc6af6c 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | #include <linux/kref.h> | 42 | #include <linux/kref.h> |
43 | #include <linux/idr.h> | 43 | #include <linux/idr.h> |
44 | #include <linux/mutex.h> | ||
44 | 45 | ||
45 | #include <rdma/ib_verbs.h> | 46 | #include <rdma/ib_verbs.h> |
46 | #include <rdma/ib_user_verbs.h> | 47 | #include <rdma/ib_user_verbs.h> |
@@ -88,7 +89,7 @@ struct ib_uverbs_event_file { | |||
88 | 89 | ||
89 | struct ib_uverbs_file { | 90 | struct ib_uverbs_file { |
90 | struct kref ref; | 91 | struct kref ref; |
91 | struct semaphore mutex; | 92 | struct mutex mutex; |
92 | struct ib_uverbs_device *device; | 93 | struct ib_uverbs_device *device; |
93 | struct ib_ucontext *ucontext; | 94 | struct ib_ucontext *ucontext; |
94 | struct ib_event_handler event_handler; | 95 | struct ib_event_handler event_handler; |
@@ -131,7 +132,7 @@ struct ib_ucq_object { | |||
131 | u32 async_events_reported; | 132 | u32 async_events_reported; |
132 | }; | 133 | }; |
133 | 134 | ||
134 | extern struct semaphore ib_uverbs_idr_mutex; | 135 | extern struct mutex ib_uverbs_idr_mutex; |
135 | extern struct idr ib_uverbs_pd_idr; | 136 | extern struct idr ib_uverbs_pd_idr; |
136 | extern struct idr ib_uverbs_mr_idr; | 137 | extern struct idr ib_uverbs_mr_idr; |
137 | extern struct idr ib_uverbs_mw_idr; | 138 | extern struct idr ib_uverbs_mw_idr; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 554c2057b7c1..407b6284d7d5 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -67,7 +67,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
67 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 67 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
68 | return -EFAULT; | 68 | return -EFAULT; |
69 | 69 | ||
70 | down(&file->mutex); | 70 | mutex_lock(&file->mutex); |
71 | 71 | ||
72 | if (file->ucontext) { | 72 | if (file->ucontext) { |
73 | ret = -EINVAL; | 73 | ret = -EINVAL; |
@@ -119,7 +119,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
119 | 119 | ||
120 | fd_install(resp.async_fd, filp); | 120 | fd_install(resp.async_fd, filp); |
121 | 121 | ||
122 | up(&file->mutex); | 122 | mutex_unlock(&file->mutex); |
123 | 123 | ||
124 | return in_len; | 124 | return in_len; |
125 | 125 | ||
@@ -131,7 +131,7 @@ err_free: | |||
131 | ibdev->dealloc_ucontext(ucontext); | 131 | ibdev->dealloc_ucontext(ucontext); |
132 | 132 | ||
133 | err: | 133 | err: |
134 | up(&file->mutex); | 134 | mutex_unlock(&file->mutex); |
135 | return ret; | 135 | return ret; |
136 | } | 136 | } |
137 | 137 | ||
@@ -290,7 +290,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, | |||
290 | pd->uobject = uobj; | 290 | pd->uobject = uobj; |
291 | atomic_set(&pd->usecnt, 0); | 291 | atomic_set(&pd->usecnt, 0); |
292 | 292 | ||
293 | down(&ib_uverbs_idr_mutex); | 293 | mutex_lock(&ib_uverbs_idr_mutex); |
294 | 294 | ||
295 | retry: | 295 | retry: |
296 | if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) { | 296 | if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) { |
@@ -314,11 +314,11 @@ retry: | |||
314 | goto err_idr; | 314 | goto err_idr; |
315 | } | 315 | } |
316 | 316 | ||
317 | down(&file->mutex); | 317 | mutex_lock(&file->mutex); |
318 | list_add_tail(&uobj->list, &file->ucontext->pd_list); | 318 | list_add_tail(&uobj->list, &file->ucontext->pd_list); |
319 | up(&file->mutex); | 319 | mutex_unlock(&file->mutex); |
320 | 320 | ||
321 | up(&ib_uverbs_idr_mutex); | 321 | mutex_unlock(&ib_uverbs_idr_mutex); |
322 | 322 | ||
323 | return in_len; | 323 | return in_len; |
324 | 324 | ||
@@ -326,7 +326,7 @@ err_idr: | |||
326 | idr_remove(&ib_uverbs_pd_idr, uobj->id); | 326 | idr_remove(&ib_uverbs_pd_idr, uobj->id); |
327 | 327 | ||
328 | err_up: | 328 | err_up: |
329 | up(&ib_uverbs_idr_mutex); | 329 | mutex_unlock(&ib_uverbs_idr_mutex); |
330 | ib_dealloc_pd(pd); | 330 | ib_dealloc_pd(pd); |
331 | 331 | ||
332 | err: | 332 | err: |
@@ -346,7 +346,7 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, | |||
346 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 346 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
347 | return -EFAULT; | 347 | return -EFAULT; |
348 | 348 | ||
349 | down(&ib_uverbs_idr_mutex); | 349 | mutex_lock(&ib_uverbs_idr_mutex); |
350 | 350 | ||
351 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 351 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
352 | if (!pd || pd->uobject->context != file->ucontext) | 352 | if (!pd || pd->uobject->context != file->ucontext) |
@@ -360,14 +360,14 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, | |||
360 | 360 | ||
361 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); | 361 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); |
362 | 362 | ||
363 | down(&file->mutex); | 363 | mutex_lock(&file->mutex); |
364 | list_del(&uobj->list); | 364 | list_del(&uobj->list); |
365 | up(&file->mutex); | 365 | mutex_unlock(&file->mutex); |
366 | 366 | ||
367 | kfree(uobj); | 367 | kfree(uobj); |
368 | 368 | ||
369 | out: | 369 | out: |
370 | up(&ib_uverbs_idr_mutex); | 370 | mutex_unlock(&ib_uverbs_idr_mutex); |
371 | 371 | ||
372 | return ret ? ret : in_len; | 372 | return ret ? ret : in_len; |
373 | } | 373 | } |
@@ -426,7 +426,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, | |||
426 | 426 | ||
427 | obj->umem.virt_base = cmd.hca_va; | 427 | obj->umem.virt_base = cmd.hca_va; |
428 | 428 | ||
429 | down(&ib_uverbs_idr_mutex); | 429 | mutex_lock(&ib_uverbs_idr_mutex); |
430 | 430 | ||
431 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 431 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
432 | if (!pd || pd->uobject->context != file->ucontext) { | 432 | if (!pd || pd->uobject->context != file->ucontext) { |
@@ -476,11 +476,11 @@ retry: | |||
476 | goto err_idr; | 476 | goto err_idr; |
477 | } | 477 | } |
478 | 478 | ||
479 | down(&file->mutex); | 479 | mutex_lock(&file->mutex); |
480 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); | 480 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); |
481 | up(&file->mutex); | 481 | mutex_unlock(&file->mutex); |
482 | 482 | ||
483 | up(&ib_uverbs_idr_mutex); | 483 | mutex_unlock(&ib_uverbs_idr_mutex); |
484 | 484 | ||
485 | return in_len; | 485 | return in_len; |
486 | 486 | ||
@@ -492,7 +492,7 @@ err_unreg: | |||
492 | atomic_dec(&pd->usecnt); | 492 | atomic_dec(&pd->usecnt); |
493 | 493 | ||
494 | err_up: | 494 | err_up: |
495 | up(&ib_uverbs_idr_mutex); | 495 | mutex_unlock(&ib_uverbs_idr_mutex); |
496 | 496 | ||
497 | ib_umem_release(file->device->ib_dev, &obj->umem); | 497 | ib_umem_release(file->device->ib_dev, &obj->umem); |
498 | 498 | ||
@@ -513,7 +513,7 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, | |||
513 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 513 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
514 | return -EFAULT; | 514 | return -EFAULT; |
515 | 515 | ||
516 | down(&ib_uverbs_idr_mutex); | 516 | mutex_lock(&ib_uverbs_idr_mutex); |
517 | 517 | ||
518 | mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle); | 518 | mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle); |
519 | if (!mr || mr->uobject->context != file->ucontext) | 519 | if (!mr || mr->uobject->context != file->ucontext) |
@@ -527,15 +527,15 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, | |||
527 | 527 | ||
528 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); | 528 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); |
529 | 529 | ||
530 | down(&file->mutex); | 530 | mutex_lock(&file->mutex); |
531 | list_del(&memobj->uobject.list); | 531 | list_del(&memobj->uobject.list); |
532 | up(&file->mutex); | 532 | mutex_unlock(&file->mutex); |
533 | 533 | ||
534 | ib_umem_release(file->device->ib_dev, &memobj->umem); | 534 | ib_umem_release(file->device->ib_dev, &memobj->umem); |
535 | kfree(memobj); | 535 | kfree(memobj); |
536 | 536 | ||
537 | out: | 537 | out: |
538 | up(&ib_uverbs_idr_mutex); | 538 | mutex_unlock(&ib_uverbs_idr_mutex); |
539 | 539 | ||
540 | return ret ? ret : in_len; | 540 | return ret ? ret : in_len; |
541 | } | 541 | } |
@@ -628,7 +628,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, | |||
628 | cq->cq_context = ev_file; | 628 | cq->cq_context = ev_file; |
629 | atomic_set(&cq->usecnt, 0); | 629 | atomic_set(&cq->usecnt, 0); |
630 | 630 | ||
631 | down(&ib_uverbs_idr_mutex); | 631 | mutex_lock(&ib_uverbs_idr_mutex); |
632 | 632 | ||
633 | retry: | 633 | retry: |
634 | if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) { | 634 | if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) { |
@@ -653,11 +653,11 @@ retry: | |||
653 | goto err_idr; | 653 | goto err_idr; |
654 | } | 654 | } |
655 | 655 | ||
656 | down(&file->mutex); | 656 | mutex_lock(&file->mutex); |
657 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); | 657 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); |
658 | up(&file->mutex); | 658 | mutex_unlock(&file->mutex); |
659 | 659 | ||
660 | up(&ib_uverbs_idr_mutex); | 660 | mutex_unlock(&ib_uverbs_idr_mutex); |
661 | 661 | ||
662 | return in_len; | 662 | return in_len; |
663 | 663 | ||
@@ -665,7 +665,7 @@ err_idr: | |||
665 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); | 665 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); |
666 | 666 | ||
667 | err_up: | 667 | err_up: |
668 | up(&ib_uverbs_idr_mutex); | 668 | mutex_unlock(&ib_uverbs_idr_mutex); |
669 | ib_destroy_cq(cq); | 669 | ib_destroy_cq(cq); |
670 | 670 | ||
671 | err: | 671 | err: |
@@ -701,7 +701,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, | |||
701 | goto out_wc; | 701 | goto out_wc; |
702 | } | 702 | } |
703 | 703 | ||
704 | down(&ib_uverbs_idr_mutex); | 704 | mutex_lock(&ib_uverbs_idr_mutex); |
705 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 705 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
706 | if (!cq || cq->uobject->context != file->ucontext) { | 706 | if (!cq || cq->uobject->context != file->ucontext) { |
707 | ret = -EINVAL; | 707 | ret = -EINVAL; |
@@ -731,7 +731,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, | |||
731 | ret = -EFAULT; | 731 | ret = -EFAULT; |
732 | 732 | ||
733 | out: | 733 | out: |
734 | up(&ib_uverbs_idr_mutex); | 734 | mutex_unlock(&ib_uverbs_idr_mutex); |
735 | kfree(resp); | 735 | kfree(resp); |
736 | 736 | ||
737 | out_wc: | 737 | out_wc: |
@@ -750,14 +750,14 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file, | |||
750 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 750 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
751 | return -EFAULT; | 751 | return -EFAULT; |
752 | 752 | ||
753 | down(&ib_uverbs_idr_mutex); | 753 | mutex_lock(&ib_uverbs_idr_mutex); |
754 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 754 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
755 | if (cq && cq->uobject->context == file->ucontext) { | 755 | if (cq && cq->uobject->context == file->ucontext) { |
756 | ib_req_notify_cq(cq, cmd.solicited_only ? | 756 | ib_req_notify_cq(cq, cmd.solicited_only ? |
757 | IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); | 757 | IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); |
758 | ret = in_len; | 758 | ret = in_len; |
759 | } | 759 | } |
760 | up(&ib_uverbs_idr_mutex); | 760 | mutex_unlock(&ib_uverbs_idr_mutex); |
761 | 761 | ||
762 | return ret; | 762 | return ret; |
763 | } | 763 | } |
@@ -779,7 +779,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
779 | 779 | ||
780 | memset(&resp, 0, sizeof resp); | 780 | memset(&resp, 0, sizeof resp); |
781 | 781 | ||
782 | down(&ib_uverbs_idr_mutex); | 782 | mutex_lock(&ib_uverbs_idr_mutex); |
783 | 783 | ||
784 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 784 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
785 | if (!cq || cq->uobject->context != file->ucontext) | 785 | if (!cq || cq->uobject->context != file->ucontext) |
@@ -795,9 +795,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
795 | 795 | ||
796 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); | 796 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); |
797 | 797 | ||
798 | down(&file->mutex); | 798 | mutex_lock(&file->mutex); |
799 | list_del(&uobj->uobject.list); | 799 | list_del(&uobj->uobject.list); |
800 | up(&file->mutex); | 800 | mutex_unlock(&file->mutex); |
801 | 801 | ||
802 | ib_uverbs_release_ucq(file, ev_file, uobj); | 802 | ib_uverbs_release_ucq(file, ev_file, uobj); |
803 | 803 | ||
@@ -811,7 +811,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
811 | ret = -EFAULT; | 811 | ret = -EFAULT; |
812 | 812 | ||
813 | out: | 813 | out: |
814 | up(&ib_uverbs_idr_mutex); | 814 | mutex_unlock(&ib_uverbs_idr_mutex); |
815 | 815 | ||
816 | return ret ? ret : in_len; | 816 | return ret ? ret : in_len; |
817 | } | 817 | } |
@@ -845,7 +845,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, | |||
845 | if (!uobj) | 845 | if (!uobj) |
846 | return -ENOMEM; | 846 | return -ENOMEM; |
847 | 847 | ||
848 | down(&ib_uverbs_idr_mutex); | 848 | mutex_lock(&ib_uverbs_idr_mutex); |
849 | 849 | ||
850 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 850 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
851 | scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); | 851 | scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); |
@@ -930,11 +930,11 @@ retry: | |||
930 | goto err_idr; | 930 | goto err_idr; |
931 | } | 931 | } |
932 | 932 | ||
933 | down(&file->mutex); | 933 | mutex_lock(&file->mutex); |
934 | list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list); | 934 | list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list); |
935 | up(&file->mutex); | 935 | mutex_unlock(&file->mutex); |
936 | 936 | ||
937 | up(&ib_uverbs_idr_mutex); | 937 | mutex_unlock(&ib_uverbs_idr_mutex); |
938 | 938 | ||
939 | return in_len; | 939 | return in_len; |
940 | 940 | ||
@@ -950,7 +950,7 @@ err_destroy: | |||
950 | atomic_dec(&attr.srq->usecnt); | 950 | atomic_dec(&attr.srq->usecnt); |
951 | 951 | ||
952 | err_up: | 952 | err_up: |
953 | up(&ib_uverbs_idr_mutex); | 953 | mutex_unlock(&ib_uverbs_idr_mutex); |
954 | 954 | ||
955 | kfree(uobj); | 955 | kfree(uobj); |
956 | return ret; | 956 | return ret; |
@@ -972,7 +972,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, | |||
972 | if (!attr) | 972 | if (!attr) |
973 | return -ENOMEM; | 973 | return -ENOMEM; |
974 | 974 | ||
975 | down(&ib_uverbs_idr_mutex); | 975 | mutex_lock(&ib_uverbs_idr_mutex); |
976 | 976 | ||
977 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 977 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
978 | if (!qp || qp->uobject->context != file->ucontext) { | 978 | if (!qp || qp->uobject->context != file->ucontext) { |
@@ -1033,7 +1033,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, | |||
1033 | ret = in_len; | 1033 | ret = in_len; |
1034 | 1034 | ||
1035 | out: | 1035 | out: |
1036 | up(&ib_uverbs_idr_mutex); | 1036 | mutex_unlock(&ib_uverbs_idr_mutex); |
1037 | kfree(attr); | 1037 | kfree(attr); |
1038 | 1038 | ||
1039 | return ret; | 1039 | return ret; |
@@ -1054,7 +1054,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1054 | 1054 | ||
1055 | memset(&resp, 0, sizeof resp); | 1055 | memset(&resp, 0, sizeof resp); |
1056 | 1056 | ||
1057 | down(&ib_uverbs_idr_mutex); | 1057 | mutex_lock(&ib_uverbs_idr_mutex); |
1058 | 1058 | ||
1059 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1059 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1060 | if (!qp || qp->uobject->context != file->ucontext) | 1060 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1073,9 +1073,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1073 | 1073 | ||
1074 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); | 1074 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); |
1075 | 1075 | ||
1076 | down(&file->mutex); | 1076 | mutex_lock(&file->mutex); |
1077 | list_del(&uobj->uevent.uobject.list); | 1077 | list_del(&uobj->uevent.uobject.list); |
1078 | up(&file->mutex); | 1078 | mutex_unlock(&file->mutex); |
1079 | 1079 | ||
1080 | ib_uverbs_release_uevent(file, &uobj->uevent); | 1080 | ib_uverbs_release_uevent(file, &uobj->uevent); |
1081 | 1081 | ||
@@ -1088,7 +1088,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1088 | ret = -EFAULT; | 1088 | ret = -EFAULT; |
1089 | 1089 | ||
1090 | out: | 1090 | out: |
1091 | up(&ib_uverbs_idr_mutex); | 1091 | mutex_unlock(&ib_uverbs_idr_mutex); |
1092 | 1092 | ||
1093 | return ret ? ret : in_len; | 1093 | return ret ? ret : in_len; |
1094 | } | 1094 | } |
@@ -1119,7 +1119,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, | |||
1119 | if (!user_wr) | 1119 | if (!user_wr) |
1120 | return -ENOMEM; | 1120 | return -ENOMEM; |
1121 | 1121 | ||
1122 | down(&ib_uverbs_idr_mutex); | 1122 | mutex_lock(&ib_uverbs_idr_mutex); |
1123 | 1123 | ||
1124 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1124 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1125 | if (!qp || qp->uobject->context != file->ucontext) | 1125 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1224,7 +1224,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, | |||
1224 | ret = -EFAULT; | 1224 | ret = -EFAULT; |
1225 | 1225 | ||
1226 | out: | 1226 | out: |
1227 | up(&ib_uverbs_idr_mutex); | 1227 | mutex_unlock(&ib_uverbs_idr_mutex); |
1228 | 1228 | ||
1229 | while (wr) { | 1229 | while (wr) { |
1230 | next = wr->next; | 1230 | next = wr->next; |
@@ -1341,7 +1341,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, | |||
1341 | if (IS_ERR(wr)) | 1341 | if (IS_ERR(wr)) |
1342 | return PTR_ERR(wr); | 1342 | return PTR_ERR(wr); |
1343 | 1343 | ||
1344 | down(&ib_uverbs_idr_mutex); | 1344 | mutex_lock(&ib_uverbs_idr_mutex); |
1345 | 1345 | ||
1346 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1346 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1347 | if (!qp || qp->uobject->context != file->ucontext) | 1347 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1362,7 +1362,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, | |||
1362 | ret = -EFAULT; | 1362 | ret = -EFAULT; |
1363 | 1363 | ||
1364 | out: | 1364 | out: |
1365 | up(&ib_uverbs_idr_mutex); | 1365 | mutex_unlock(&ib_uverbs_idr_mutex); |
1366 | 1366 | ||
1367 | while (wr) { | 1367 | while (wr) { |
1368 | next = wr->next; | 1368 | next = wr->next; |
@@ -1392,7 +1392,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, | |||
1392 | if (IS_ERR(wr)) | 1392 | if (IS_ERR(wr)) |
1393 | return PTR_ERR(wr); | 1393 | return PTR_ERR(wr); |
1394 | 1394 | ||
1395 | down(&ib_uverbs_idr_mutex); | 1395 | mutex_lock(&ib_uverbs_idr_mutex); |
1396 | 1396 | ||
1397 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); | 1397 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); |
1398 | if (!srq || srq->uobject->context != file->ucontext) | 1398 | if (!srq || srq->uobject->context != file->ucontext) |
@@ -1413,7 +1413,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, | |||
1413 | ret = -EFAULT; | 1413 | ret = -EFAULT; |
1414 | 1414 | ||
1415 | out: | 1415 | out: |
1416 | up(&ib_uverbs_idr_mutex); | 1416 | mutex_unlock(&ib_uverbs_idr_mutex); |
1417 | 1417 | ||
1418 | while (wr) { | 1418 | while (wr) { |
1419 | next = wr->next; | 1419 | next = wr->next; |
@@ -1446,7 +1446,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file, | |||
1446 | if (!uobj) | 1446 | if (!uobj) |
1447 | return -ENOMEM; | 1447 | return -ENOMEM; |
1448 | 1448 | ||
1449 | down(&ib_uverbs_idr_mutex); | 1449 | mutex_lock(&ib_uverbs_idr_mutex); |
1450 | 1450 | ||
1451 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 1451 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
1452 | if (!pd || pd->uobject->context != file->ucontext) { | 1452 | if (!pd || pd->uobject->context != file->ucontext) { |
@@ -1498,11 +1498,11 @@ retry: | |||
1498 | goto err_idr; | 1498 | goto err_idr; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | down(&file->mutex); | 1501 | mutex_lock(&file->mutex); |
1502 | list_add_tail(&uobj->list, &file->ucontext->ah_list); | 1502 | list_add_tail(&uobj->list, &file->ucontext->ah_list); |
1503 | up(&file->mutex); | 1503 | mutex_unlock(&file->mutex); |
1504 | 1504 | ||
1505 | up(&ib_uverbs_idr_mutex); | 1505 | mutex_unlock(&ib_uverbs_idr_mutex); |
1506 | 1506 | ||
1507 | return in_len; | 1507 | return in_len; |
1508 | 1508 | ||
@@ -1513,7 +1513,7 @@ err_destroy: | |||
1513 | ib_destroy_ah(ah); | 1513 | ib_destroy_ah(ah); |
1514 | 1514 | ||
1515 | err_up: | 1515 | err_up: |
1516 | up(&ib_uverbs_idr_mutex); | 1516 | mutex_unlock(&ib_uverbs_idr_mutex); |
1517 | 1517 | ||
1518 | kfree(uobj); | 1518 | kfree(uobj); |
1519 | return ret; | 1519 | return ret; |
@@ -1530,7 +1530,7 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file, | |||
1530 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1530 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1531 | return -EFAULT; | 1531 | return -EFAULT; |
1532 | 1532 | ||
1533 | down(&ib_uverbs_idr_mutex); | 1533 | mutex_lock(&ib_uverbs_idr_mutex); |
1534 | 1534 | ||
1535 | ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle); | 1535 | ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle); |
1536 | if (!ah || ah->uobject->context != file->ucontext) | 1536 | if (!ah || ah->uobject->context != file->ucontext) |
@@ -1544,14 +1544,14 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file, | |||
1544 | 1544 | ||
1545 | idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle); | 1545 | idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle); |
1546 | 1546 | ||
1547 | down(&file->mutex); | 1547 | mutex_lock(&file->mutex); |
1548 | list_del(&uobj->list); | 1548 | list_del(&uobj->list); |
1549 | up(&file->mutex); | 1549 | mutex_unlock(&file->mutex); |
1550 | 1550 | ||
1551 | kfree(uobj); | 1551 | kfree(uobj); |
1552 | 1552 | ||
1553 | out: | 1553 | out: |
1554 | up(&ib_uverbs_idr_mutex); | 1554 | mutex_unlock(&ib_uverbs_idr_mutex); |
1555 | 1555 | ||
1556 | return ret ? ret : in_len; | 1556 | return ret ? ret : in_len; |
1557 | } | 1557 | } |
@@ -1569,7 +1569,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, | |||
1569 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1569 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1570 | return -EFAULT; | 1570 | return -EFAULT; |
1571 | 1571 | ||
1572 | down(&ib_uverbs_idr_mutex); | 1572 | mutex_lock(&ib_uverbs_idr_mutex); |
1573 | 1573 | ||
1574 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1574 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1575 | if (!qp || qp->uobject->context != file->ucontext) | 1575 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1602,7 +1602,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, | |||
1602 | kfree(mcast); | 1602 | kfree(mcast); |
1603 | 1603 | ||
1604 | out: | 1604 | out: |
1605 | up(&ib_uverbs_idr_mutex); | 1605 | mutex_unlock(&ib_uverbs_idr_mutex); |
1606 | 1606 | ||
1607 | return ret ? ret : in_len; | 1607 | return ret ? ret : in_len; |
1608 | } | 1608 | } |
@@ -1620,7 +1620,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, | |||
1620 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1620 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1621 | return -EFAULT; | 1621 | return -EFAULT; |
1622 | 1622 | ||
1623 | down(&ib_uverbs_idr_mutex); | 1623 | mutex_lock(&ib_uverbs_idr_mutex); |
1624 | 1624 | ||
1625 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1625 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1626 | if (!qp || qp->uobject->context != file->ucontext) | 1626 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1641,7 +1641,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, | |||
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | out: | 1643 | out: |
1644 | up(&ib_uverbs_idr_mutex); | 1644 | mutex_unlock(&ib_uverbs_idr_mutex); |
1645 | 1645 | ||
1646 | return ret ? ret : in_len; | 1646 | return ret ? ret : in_len; |
1647 | } | 1647 | } |
@@ -1673,7 +1673,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, | |||
1673 | if (!uobj) | 1673 | if (!uobj) |
1674 | return -ENOMEM; | 1674 | return -ENOMEM; |
1675 | 1675 | ||
1676 | down(&ib_uverbs_idr_mutex); | 1676 | mutex_lock(&ib_uverbs_idr_mutex); |
1677 | 1677 | ||
1678 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 1678 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
1679 | 1679 | ||
@@ -1730,11 +1730,11 @@ retry: | |||
1730 | goto err_idr; | 1730 | goto err_idr; |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | down(&file->mutex); | 1733 | mutex_lock(&file->mutex); |
1734 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); | 1734 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); |
1735 | up(&file->mutex); | 1735 | mutex_unlock(&file->mutex); |
1736 | 1736 | ||
1737 | up(&ib_uverbs_idr_mutex); | 1737 | mutex_unlock(&ib_uverbs_idr_mutex); |
1738 | 1738 | ||
1739 | return in_len; | 1739 | return in_len; |
1740 | 1740 | ||
@@ -1746,7 +1746,7 @@ err_destroy: | |||
1746 | atomic_dec(&pd->usecnt); | 1746 | atomic_dec(&pd->usecnt); |
1747 | 1747 | ||
1748 | err_up: | 1748 | err_up: |
1749 | up(&ib_uverbs_idr_mutex); | 1749 | mutex_unlock(&ib_uverbs_idr_mutex); |
1750 | 1750 | ||
1751 | kfree(uobj); | 1751 | kfree(uobj); |
1752 | return ret; | 1752 | return ret; |
@@ -1764,7 +1764,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, | |||
1764 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1764 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1765 | return -EFAULT; | 1765 | return -EFAULT; |
1766 | 1766 | ||
1767 | down(&ib_uverbs_idr_mutex); | 1767 | mutex_lock(&ib_uverbs_idr_mutex); |
1768 | 1768 | ||
1769 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); | 1769 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); |
1770 | if (!srq || srq->uobject->context != file->ucontext) { | 1770 | if (!srq || srq->uobject->context != file->ucontext) { |
@@ -1778,7 +1778,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, | |||
1778 | ret = ib_modify_srq(srq, &attr, cmd.attr_mask); | 1778 | ret = ib_modify_srq(srq, &attr, cmd.attr_mask); |
1779 | 1779 | ||
1780 | out: | 1780 | out: |
1781 | up(&ib_uverbs_idr_mutex); | 1781 | mutex_unlock(&ib_uverbs_idr_mutex); |
1782 | 1782 | ||
1783 | return ret ? ret : in_len; | 1783 | return ret ? ret : in_len; |
1784 | } | 1784 | } |
@@ -1796,7 +1796,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1796 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1796 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1797 | return -EFAULT; | 1797 | return -EFAULT; |
1798 | 1798 | ||
1799 | down(&ib_uverbs_idr_mutex); | 1799 | mutex_lock(&ib_uverbs_idr_mutex); |
1800 | 1800 | ||
1801 | memset(&resp, 0, sizeof resp); | 1801 | memset(&resp, 0, sizeof resp); |
1802 | 1802 | ||
@@ -1812,9 +1812,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1812 | 1812 | ||
1813 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); | 1813 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); |
1814 | 1814 | ||
1815 | down(&file->mutex); | 1815 | mutex_lock(&file->mutex); |
1816 | list_del(&uobj->uobject.list); | 1816 | list_del(&uobj->uobject.list); |
1817 | up(&file->mutex); | 1817 | mutex_unlock(&file->mutex); |
1818 | 1818 | ||
1819 | ib_uverbs_release_uevent(file, uobj); | 1819 | ib_uverbs_release_uevent(file, uobj); |
1820 | 1820 | ||
@@ -1827,7 +1827,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1827 | ret = -EFAULT; | 1827 | ret = -EFAULT; |
1828 | 1828 | ||
1829 | out: | 1829 | out: |
1830 | up(&ib_uverbs_idr_mutex); | 1830 | mutex_unlock(&ib_uverbs_idr_mutex); |
1831 | 1831 | ||
1832 | return ret ? ret : in_len; | 1832 | return ret ? ret : in_len; |
1833 | } | 1833 | } |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 81737bd6faea..96ea79b63df7 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -66,7 +66,7 @@ enum { | |||
66 | 66 | ||
67 | static struct class *uverbs_class; | 67 | static struct class *uverbs_class; |
68 | 68 | ||
69 | DECLARE_MUTEX(ib_uverbs_idr_mutex); | 69 | DEFINE_MUTEX(ib_uverbs_idr_mutex); |
70 | DEFINE_IDR(ib_uverbs_pd_idr); | 70 | DEFINE_IDR(ib_uverbs_pd_idr); |
71 | DEFINE_IDR(ib_uverbs_mr_idr); | 71 | DEFINE_IDR(ib_uverbs_mr_idr); |
72 | DEFINE_IDR(ib_uverbs_mw_idr); | 72 | DEFINE_IDR(ib_uverbs_mw_idr); |
@@ -180,7 +180,7 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, | |||
180 | if (!context) | 180 | if (!context) |
181 | return 0; | 181 | return 0; |
182 | 182 | ||
183 | down(&ib_uverbs_idr_mutex); | 183 | mutex_lock(&ib_uverbs_idr_mutex); |
184 | 184 | ||
185 | list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) { | 185 | list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) { |
186 | struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id); | 186 | struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id); |
@@ -250,7 +250,7 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, | |||
250 | kfree(uobj); | 250 | kfree(uobj); |
251 | } | 251 | } |
252 | 252 | ||
253 | up(&ib_uverbs_idr_mutex); | 253 | mutex_unlock(&ib_uverbs_idr_mutex); |
254 | 254 | ||
255 | return context->device->dealloc_ucontext(context); | 255 | return context->device->dealloc_ucontext(context); |
256 | } | 256 | } |
@@ -653,7 +653,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) | |||
653 | file->ucontext = NULL; | 653 | file->ucontext = NULL; |
654 | file->async_file = NULL; | 654 | file->async_file = NULL; |
655 | kref_init(&file->ref); | 655 | kref_init(&file->ref); |
656 | init_MUTEX(&file->mutex); | 656 | mutex_init(&file->mutex); |
657 | 657 | ||
658 | filp->private_data = file; | 658 | filp->private_data = file; |
659 | 659 | ||