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>
This commit is contained in:
Ingo Molnar 2006-01-13 14:51:39 -08:00 коммит произвёл Roland Dreier
Родитель 9eacee2ac6
Коммит 95ed644fd1
11 изменённых файлов: 145 добавлений и 144 удалений

Просмотреть файл

@ -38,8 +38,7 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include "core_priv.h"
@ -57,13 +56,13 @@ static LIST_HEAD(device_list);
static LIST_HEAD(client_list);
/*
* device_sem protects access to both device_list and client_list.
* device_mutex protects access to both device_list and client_list.
* There's no real point to using multiple locks or something fancier
* like an rwsem: we always access both lists, and we're always
* modifying one list or the other list. In any case this is not a
* hot path so there's no point in trying to optimize.
*/
static DECLARE_MUTEX(device_sem);
static DEFINE_MUTEX(device_mutex);
static int ib_device_check_mandatory(struct ib_device *device)
{
@ -221,7 +220,7 @@ int ib_register_device(struct ib_device *device)
{
int ret;
down(&device_sem);
mutex_lock(&device_mutex);
if (strchr(device->name, '%')) {
ret = alloc_name(device->name);
@ -259,7 +258,7 @@ int ib_register_device(struct ib_device *device)
}
out:
up(&device_sem);
mutex_unlock(&device_mutex);
return ret;
}
EXPORT_SYMBOL(ib_register_device);
@ -276,7 +275,7 @@ void ib_unregister_device(struct ib_device *device)
struct ib_client_data *context, *tmp;
unsigned long flags;
down(&device_sem);
mutex_lock(&device_mutex);
list_for_each_entry_reverse(client, &client_list, list)
if (client->remove)
@ -284,7 +283,7 @@ void ib_unregister_device(struct ib_device *device)
list_del(&device->core_list);
up(&device_sem);
mutex_unlock(&device_mutex);
spin_lock_irqsave(&device->client_data_lock, flags);
list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
@ -312,14 +311,14 @@ int ib_register_client(struct ib_client *client)
{
struct ib_device *device;
down(&device_sem);
mutex_lock(&device_mutex);
list_add_tail(&client->list, &client_list);
list_for_each_entry(device, &device_list, core_list)
if (client->add && !add_client_context(device, client))
client->add(device);
up(&device_sem);
mutex_unlock(&device_mutex);
return 0;
}
@ -339,7 +338,7 @@ void ib_unregister_client(struct ib_client *client)
struct ib_device *device;
unsigned long flags;
down(&device_sem);
mutex_lock(&device_mutex);
list_for_each_entry(device, &device_list, core_list) {
if (client->remove)
@ -355,7 +354,7 @@ void ib_unregister_client(struct ib_client *client)
}
list_del(&client->list);
up(&device_sem);
mutex_unlock(&device_mutex);
}
EXPORT_SYMBOL(ib_unregister_client);

Просмотреть файл

@ -42,6 +42,7 @@
#include <linux/mount.h>
#include <linux/cdev.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
@ -113,7 +114,7 @@ static struct ib_client ucm_client = {
.remove = ib_ucm_remove_one
};
static DECLARE_MUTEX(ctx_id_mutex);
static DEFINE_MUTEX(ctx_id_mutex);
static DEFINE_IDR(ctx_id_table);
static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
@ -121,7 +122,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
{
struct ib_ucm_context *ctx;
down(&ctx_id_mutex);
mutex_lock(&ctx_id_mutex);
ctx = idr_find(&ctx_id_table, id);
if (!ctx)
ctx = ERR_PTR(-ENOENT);
@ -129,7 +130,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
ctx = ERR_PTR(-EINVAL);
else
atomic_inc(&ctx->ref);
up(&ctx_id_mutex);
mutex_unlock(&ctx_id_mutex);
return ctx;
}
@ -186,9 +187,9 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
if (!result)
goto error;
down(&ctx_id_mutex);
mutex_lock(&ctx_id_mutex);
result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
up(&ctx_id_mutex);
mutex_unlock(&ctx_id_mutex);
} while (result == -EAGAIN);
if (result)
@ -550,9 +551,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
err2:
ib_destroy_cm_id(ctx->cm_id);
err1:
down(&ctx_id_mutex);
mutex_lock(&ctx_id_mutex);
idr_remove(&ctx_id_table, ctx->id);
up(&ctx_id_mutex);
mutex_unlock(&ctx_id_mutex);
kfree(ctx);
return result;
}
@ -572,7 +573,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT;
down(&ctx_id_mutex);
mutex_lock(&ctx_id_mutex);
ctx = idr_find(&ctx_id_table, cmd.id);
if (!ctx)
ctx = ERR_PTR(-ENOENT);
@ -580,7 +581,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
ctx = ERR_PTR(-EINVAL);
else
idr_remove(&ctx_id_table, ctx->id);
up(&ctx_id_mutex);
mutex_unlock(&ctx_id_mutex);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
@ -1280,9 +1281,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
struct ib_ucm_context, file_list);
up(&file->mutex);
down(&ctx_id_mutex);
mutex_lock(&ctx_id_mutex);
idr_remove(&ctx_id_table, ctx->id);
up(&ctx_id_mutex);
mutex_unlock(&ctx_id_mutex);
ib_destroy_cm_id(ctx->cm_id);
ib_ucm_cleanup_events(ctx);

Просмотреть файл

@ -41,6 +41,7 @@
#include <linux/kref.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_user_verbs.h>
@ -88,7 +89,7 @@ struct ib_uverbs_event_file {
struct ib_uverbs_file {
struct kref ref;
struct semaphore mutex;
struct mutex mutex;
struct ib_uverbs_device *device;
struct ib_ucontext *ucontext;
struct ib_event_handler event_handler;
@ -131,7 +132,7 @@ struct ib_ucq_object {
u32 async_events_reported;
};
extern struct semaphore ib_uverbs_idr_mutex;
extern struct mutex ib_uverbs_idr_mutex;
extern struct idr ib_uverbs_pd_idr;
extern struct idr ib_uverbs_mr_idr;
extern struct idr ib_uverbs_mw_idr;

Просмотреть файл

@ -67,7 +67,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&file->mutex);
mutex_lock(&file->mutex);
if (file->ucontext) {
ret = -EINVAL;
@ -119,7 +119,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
fd_install(resp.async_fd, filp);
up(&file->mutex);
mutex_unlock(&file->mutex);
return in_len;
@ -131,7 +131,7 @@ err_free:
ibdev->dealloc_ucontext(ucontext);
err:
up(&file->mutex);
mutex_unlock(&file->mutex);
return ret;
}
@ -290,7 +290,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
pd->uobject = uobj;
atomic_set(&pd->usecnt, 0);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
retry:
if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) {
@ -314,11 +314,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&uobj->list, &file->ucontext->pd_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -326,7 +326,7 @@ err_idr:
idr_remove(&ib_uverbs_pd_idr, uobj->id);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
ib_dealloc_pd(pd);
err:
@ -346,7 +346,7 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
if (!pd || pd->uobject->context != file->ucontext)
@ -360,14 +360,14 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&uobj->list);
up(&file->mutex);
mutex_unlock(&file->mutex);
kfree(uobj);
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -426,7 +426,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
obj->umem.virt_base = cmd.hca_va;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
if (!pd || pd->uobject->context != file->ucontext) {
@ -476,11 +476,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -492,7 +492,7 @@ err_unreg:
atomic_dec(&pd->usecnt);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
ib_umem_release(file->device->ib_dev, &obj->umem);
@ -513,7 +513,7 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle);
if (!mr || mr->uobject->context != file->ucontext)
@ -527,15 +527,15 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&memobj->uobject.list);
up(&file->mutex);
mutex_unlock(&file->mutex);
ib_umem_release(file->device->ib_dev, &memobj->umem);
kfree(memobj);
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -628,7 +628,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
cq->cq_context = ev_file;
atomic_set(&cq->usecnt, 0);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
retry:
if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) {
@ -653,11 +653,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -665,7 +665,7 @@ err_idr:
idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
ib_destroy_cq(cq);
err:
@ -701,7 +701,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
goto out_wc;
}
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
if (!cq || cq->uobject->context != file->ucontext) {
ret = -EINVAL;
@ -731,7 +731,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
kfree(resp);
out_wc:
@ -750,14 +750,14 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
if (cq && cq->uobject->context == file->ucontext) {
ib_req_notify_cq(cq, cmd.solicited_only ?
IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
ret = in_len;
}
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret;
}
@ -779,7 +779,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
memset(&resp, 0, sizeof resp);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
if (!cq || cq->uobject->context != file->ucontext)
@ -795,9 +795,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&uobj->uobject.list);
up(&file->mutex);
mutex_unlock(&file->mutex);
ib_uverbs_release_ucq(file, ev_file, uobj);
@ -811,7 +811,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -845,7 +845,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
if (!uobj)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle);
@ -930,11 +930,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -950,7 +950,7 @@ err_destroy:
atomic_dec(&attr.srq->usecnt);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
kfree(uobj);
return ret;
@ -972,7 +972,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
if (!attr)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext) {
@ -1033,7 +1033,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
ret = in_len;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
kfree(attr);
return ret;
@ -1054,7 +1054,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
memset(&resp, 0, sizeof resp);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext)
@ -1073,9 +1073,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&uobj->uevent.uobject.list);
up(&file->mutex);
mutex_unlock(&file->mutex);
ib_uverbs_release_uevent(file, &uobj->uevent);
@ -1088,7 +1088,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -1119,7 +1119,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
if (!user_wr)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext)
@ -1224,7 +1224,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
while (wr) {
next = wr->next;
@ -1341,7 +1341,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
if (IS_ERR(wr))
return PTR_ERR(wr);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext)
@ -1362,7 +1362,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
while (wr) {
next = wr->next;
@ -1392,7 +1392,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
if (IS_ERR(wr))
return PTR_ERR(wr);
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
if (!srq || srq->uobject->context != file->ucontext)
@ -1413,7 +1413,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
while (wr) {
next = wr->next;
@ -1446,7 +1446,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
if (!uobj)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
if (!pd || pd->uobject->context != file->ucontext) {
@ -1498,11 +1498,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&uobj->list, &file->ucontext->ah_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -1513,7 +1513,7 @@ err_destroy:
ib_destroy_ah(ah);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
kfree(uobj);
return ret;
@ -1530,7 +1530,7 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle);
if (!ah || ah->uobject->context != file->ucontext)
@ -1544,14 +1544,14 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&uobj->list);
up(&file->mutex);
mutex_unlock(&file->mutex);
kfree(uobj);
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -1569,7 +1569,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext)
@ -1602,7 +1602,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
kfree(mcast);
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -1620,7 +1620,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
if (!qp || qp->uobject->context != file->ucontext)
@ -1641,7 +1641,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
}
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -1673,7 +1673,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
if (!uobj)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
@ -1730,11 +1730,11 @@ retry:
goto err_idr;
}
down(&file->mutex);
mutex_lock(&file->mutex);
list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list);
up(&file->mutex);
mutex_unlock(&file->mutex);
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return in_len;
@ -1746,7 +1746,7 @@ err_destroy:
atomic_dec(&pd->usecnt);
err_up:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
kfree(uobj);
return ret;
@ -1764,7 +1764,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
if (!srq || srq->uobject->context != file->ucontext) {
@ -1778,7 +1778,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
@ -1796,7 +1796,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
memset(&resp, 0, sizeof resp);
@ -1812,9 +1812,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle);
down(&file->mutex);
mutex_lock(&file->mutex);
list_del(&uobj->uobject.list);
up(&file->mutex);
mutex_unlock(&file->mutex);
ib_uverbs_release_uevent(file, uobj);
@ -1827,7 +1827,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
ret = -EFAULT;
out:
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}

Просмотреть файл

@ -66,7 +66,7 @@ enum {
static struct class *uverbs_class;
DECLARE_MUTEX(ib_uverbs_idr_mutex);
DEFINE_MUTEX(ib_uverbs_idr_mutex);
DEFINE_IDR(ib_uverbs_pd_idr);
DEFINE_IDR(ib_uverbs_mr_idr);
DEFINE_IDR(ib_uverbs_mw_idr);
@ -180,7 +180,7 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
if (!context)
return 0;
down(&ib_uverbs_idr_mutex);
mutex_lock(&ib_uverbs_idr_mutex);
list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) {
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,
kfree(uobj);
}
up(&ib_uverbs_idr_mutex);
mutex_unlock(&ib_uverbs_idr_mutex);
return context->device->dealloc_ucontext(context);
}
@ -653,7 +653,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
file->ucontext = NULL;
file->async_file = NULL;
kref_init(&file->ref);
init_MUTEX(&file->mutex);
mutex_init(&file->mutex);
filp->private_data = file;

Просмотреть файл

@ -45,11 +45,11 @@
#include <linux/config.h>
#include <linux/kref.h>
#include <linux/if_infiniband.h>
#include <linux/mutex.h>
#include <net/neighbour.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_pack.h>
@ -123,8 +123,8 @@ struct ipoib_dev_priv {
unsigned long flags;
struct semaphore mcast_mutex;
struct semaphore vlan_mutex;
struct mutex mcast_mutex;
struct mutex vlan_mutex;
struct rb_root path_tree;
struct list_head path_list;

Просмотреть файл

@ -52,7 +52,7 @@ MODULE_PARM_DESC(data_debug_level,
#define IPOIB_OP_RECV (1ul << 31)
static DECLARE_MUTEX(pkey_sem);
static DEFINE_MUTEX(pkey_mutex);
struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
struct ib_pd *pd, struct ib_ah_attr *attr)
@ -445,10 +445,10 @@ int ipoib_ib_dev_down(struct net_device *dev)
/* Shutdown the P_Key thread if still active */
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
down(&pkey_sem);
mutex_lock(&pkey_mutex);
set_bit(IPOIB_PKEY_STOP, &priv->flags);
cancel_delayed_work(&priv->pkey_task);
up(&pkey_sem);
mutex_unlock(&pkey_mutex);
flush_workqueue(ipoib_workqueue);
}
@ -599,13 +599,13 @@ void ipoib_ib_dev_flush(void *_dev)
if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
ipoib_ib_dev_up(dev);
down(&priv->vlan_mutex);
mutex_lock(&priv->vlan_mutex);
/* Flush any child interfaces too */
list_for_each_entry(cpriv, &priv->child_intfs, list)
ipoib_ib_dev_flush(&cpriv->dev);
up(&priv->vlan_mutex);
mutex_unlock(&priv->vlan_mutex);
}
void ipoib_ib_dev_cleanup(struct net_device *dev)
@ -651,12 +651,12 @@ void ipoib_pkey_poll(void *dev_ptr)
if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
ipoib_open(dev);
else {
down(&pkey_sem);
mutex_lock(&pkey_mutex);
if (!test_bit(IPOIB_PKEY_STOP, &priv->flags))
queue_delayed_work(ipoib_workqueue,
&priv->pkey_task,
HZ);
up(&pkey_sem);
mutex_unlock(&pkey_mutex);
}
}
@ -670,12 +670,12 @@ int ipoib_pkey_dev_delay_open(struct net_device *dev)
/* P_Key value not assigned yet - start polling */
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
down(&pkey_sem);
mutex_lock(&pkey_mutex);
clear_bit(IPOIB_PKEY_STOP, &priv->flags);
queue_delayed_work(ipoib_workqueue,
&priv->pkey_task,
HZ);
up(&pkey_sem);
mutex_unlock(&pkey_mutex);
return 1;
}

Просмотреть файл

@ -105,7 +105,7 @@ int ipoib_open(struct net_device *dev)
struct ipoib_dev_priv *cpriv;
/* Bring up any child interfaces too */
down(&priv->vlan_mutex);
mutex_lock(&priv->vlan_mutex);
list_for_each_entry(cpriv, &priv->child_intfs, list) {
int flags;
@ -115,7 +115,7 @@ int ipoib_open(struct net_device *dev)
dev_change_flags(cpriv->dev, flags | IFF_UP);
}
up(&priv->vlan_mutex);
mutex_unlock(&priv->vlan_mutex);
}
netif_start_queue(dev);
@ -140,7 +140,7 @@ static int ipoib_stop(struct net_device *dev)
struct ipoib_dev_priv *cpriv;
/* Bring down any child interfaces too */
down(&priv->vlan_mutex);
mutex_lock(&priv->vlan_mutex);
list_for_each_entry(cpriv, &priv->child_intfs, list) {
int flags;
@ -150,7 +150,7 @@ static int ipoib_stop(struct net_device *dev)
dev_change_flags(cpriv->dev, flags & ~IFF_UP);
}
up(&priv->vlan_mutex);
mutex_unlock(&priv->vlan_mutex);
}
return 0;
@ -892,8 +892,8 @@ static void ipoib_setup(struct net_device *dev)
spin_lock_init(&priv->lock);
spin_lock_init(&priv->tx_lock);
init_MUTEX(&priv->mcast_mutex);
init_MUTEX(&priv->vlan_mutex);
mutex_init(&priv->mcast_mutex);
mutex_init(&priv->vlan_mutex);
INIT_LIST_HEAD(&priv->path_list);
INIT_LIST_HEAD(&priv->child_intfs);

Просмотреть файл

@ -55,7 +55,7 @@ MODULE_PARM_DESC(mcast_debug_level,
"Enable multicast debug tracing if > 0");
#endif
static DECLARE_MUTEX(mcast_mutex);
static DEFINE_MUTEX(mcast_mutex);
/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
struct ipoib_mcast {
@ -385,10 +385,10 @@ static void ipoib_mcast_join_complete(int status,
if (!status && !ipoib_mcast_join_finish(mcast, mcmember)) {
mcast->backoff = 1;
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
queue_work(ipoib_workqueue, &priv->mcast_task);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
complete(&mcast->done);
return;
}
@ -418,7 +418,7 @@ static void ipoib_mcast_join_complete(int status,
mcast->query = NULL;
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) {
if (status == -ETIMEDOUT)
queue_work(ipoib_workqueue, &priv->mcast_task);
@ -427,7 +427,7 @@ static void ipoib_mcast_join_complete(int status,
mcast->backoff * HZ);
} else
complete(&mcast->done);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
return;
}
@ -482,12 +482,12 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
if (mcast->backoff > IPOIB_MAX_BACKOFF_SECONDS)
mcast->backoff = IPOIB_MAX_BACKOFF_SECONDS;
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
queue_delayed_work(ipoib_workqueue,
&priv->mcast_task,
mcast->backoff * HZ);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
} else
mcast->query_id = ret;
}
@ -520,11 +520,11 @@ void ipoib_mcast_join_task(void *dev_ptr)
priv->broadcast = ipoib_mcast_alloc(dev, 1);
if (!priv->broadcast) {
ipoib_warn(priv, "failed to allocate broadcast group\n");
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
queue_delayed_work(ipoib_workqueue,
&priv->mcast_task, HZ);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
return;
}
@ -580,10 +580,10 @@ int ipoib_mcast_start_thread(struct net_device *dev)
ipoib_dbg_mcast(priv, "starting multicast thread\n");
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags))
queue_work(ipoib_workqueue, &priv->mcast_task);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
return 0;
}
@ -595,10 +595,10 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
ipoib_dbg_mcast(priv, "stopping multicast thread\n");
down(&mcast_mutex);
mutex_lock(&mcast_mutex);
clear_bit(IPOIB_MCAST_RUN, &priv->flags);
cancel_delayed_work(&priv->mcast_task);
up(&mcast_mutex);
mutex_unlock(&mcast_mutex);
if (flush)
flush_workqueue(ipoib_workqueue);

Просмотреть файл

@ -65,9 +65,9 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
}
/* attach QP to multicast group */
down(&priv->mcast_mutex);
mutex_lock(&priv->mcast_mutex);
ret = ib_attach_mcast(priv->qp, mgid, mlid);
up(&priv->mcast_mutex);
mutex_unlock(&priv->mcast_mutex);
if (ret)
ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret);
@ -81,9 +81,9 @@ int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
struct ipoib_dev_priv *priv = netdev_priv(dev);
int ret;
down(&priv->mcast_mutex);
mutex_lock(&priv->mcast_mutex);
ret = ib_detach_mcast(priv->qp, mgid, mlid);
up(&priv->mcast_mutex);
mutex_unlock(&priv->mcast_mutex);
if (ret)
ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret);

Просмотреть файл

@ -63,7 +63,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
ppriv = netdev_priv(pdev);
down(&ppriv->vlan_mutex);
mutex_lock(&ppriv->vlan_mutex);
/*
* First ensure this isn't a duplicate. We check the parent device and
@ -124,7 +124,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
list_add_tail(&priv->list, &ppriv->child_intfs);
up(&ppriv->vlan_mutex);
mutex_unlock(&ppriv->vlan_mutex);
return 0;
@ -139,7 +139,7 @@ device_init_failed:
free_netdev(priv->dev);
err:
up(&ppriv->vlan_mutex);
mutex_unlock(&ppriv->vlan_mutex);
return result;
}
@ -153,7 +153,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
ppriv = netdev_priv(pdev);
down(&ppriv->vlan_mutex);
mutex_lock(&ppriv->vlan_mutex);
list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {
if (priv->pkey == pkey) {
unregister_netdev(priv->dev);
@ -167,7 +167,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
break;
}
}
up(&ppriv->vlan_mutex);
mutex_unlock(&ppriv->vlan_mutex);
return ret;
}