[openib-general] [PATCH] git ucm for 2.6.18: convert semaphore to mutex
Sean Hefty
sean.hefty at intel.com
Thu May 25 10:03:23 PDT 2006
>I think semaphore->mutex conversions can wait for 2.6.18. I don't
>know if the other change is a bug or not -- maybe Sean remembers?
The other change was an attempt to fix an issue that Arlin was hitting
with uDAPL, but I don't think that it's needed. Please add the patch
below to the for-2.6.18 branch, which will bring the ucm up to date.
---
Convert semaphore in ib_ucm_file to a real mutex.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index fefc9b6..67caf36 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -64,7 +64,7 @@ struct ib_ucm_device {
};
struct ib_ucm_file {
- struct semaphore mutex;
+ struct mutex file_mutex;
struct file *filp;
struct ib_ucm_device *device;
@@ -153,7 +153,7 @@ static void ib_ucm_cleanup_events(struct
{
struct ib_ucm_event *uevent;
- down(&ctx->file->mutex);
+ mutex_lock(&ctx->file->file_mutex);
list_del(&ctx->file_list);
while (!list_empty(&ctx->events)) {
@@ -168,7 +168,7 @@ static void ib_ucm_cleanup_events(struct
kfree(uevent);
}
- up(&ctx->file->mutex);
+ mutex_unlock(&ctx->file->file_mutex);
}
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 i
if (result)
goto err2;
- down(&ctx->file->mutex);
+ mutex_lock(&ctx->file->file_mutex);
list_add_tail(&uevent->file_list, &ctx->file->events);
list_add_tail(&uevent->ctx_list, &ctx->events);
wake_up_interruptible(&ctx->file->poll_wait);
- up(&ctx->file->mutex);
+ mutex_unlock(&ctx->file->file_mutex);
return 0;
err2:
@@ -405,7 +405,7 @@ static ssize_t ib_ucm_event(struct ib_uc
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT;
- down(&file->mutex);
+ mutex_lock(&file->file_mutex);
while (list_empty(&file->events)) {
if (file->filp->f_flags & O_NONBLOCK) {
@@ -420,9 +420,9 @@ static ssize_t ib_ucm_event(struct ib_uc
prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE);
- up(&file->mutex);
+ mutex_unlock(&file->file_mutex);
schedule();
- down(&file->mutex);
+ mutex_lock(&file->file_mutex);
finish_wait(&file->poll_wait, &wait);
}
@@ -482,7 +482,7 @@ static ssize_t ib_ucm_event(struct ib_uc
kfree(uevent->info);
kfree(uevent);
done:
- up(&file->mutex);
+ mutex_unlock(&file->file_mutex);
return result;
}
@@ -501,9 +501,9 @@ static ssize_t ib_ucm_create_id(struct i
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT;
- down(&file->mutex);
+ mutex_lock(&file->file_mutex);
ctx = ib_ucm_ctx_alloc(file);
- up(&file->mutex);
+ mutex_unlock(&file->file_mutex);
if (!ctx)
return -ENOMEM;
@@ -1159,10 +1159,8 @@ static unsigned int ib_ucm_poll(struct f
poll_wait(filp, &file->poll_wait, wait);
- down(&file->mutex);
if (!list_empty(&file->events))
mask = POLLIN | POLLRDNORM;
- up(&file->mutex);
return mask;
}
@@ -1179,7 +1177,7 @@ static int ib_ucm_open(struct inode *ino
INIT_LIST_HEAD(&file->ctxs);
init_waitqueue_head(&file->poll_wait);
- init_MUTEX(&file->mutex);
+ mutex_init(&file->file_mutex);
filp->private_data = file;
file->filp = filp;
@@ -1193,11 +1191,11 @@ static int ib_ucm_close(struct inode *in
struct ib_ucm_file *file = filp->private_data;
struct ib_ucm_context *ctx;
- down(&file->mutex);
+ mutex_lock(&file->file_mutex);
while (!list_empty(&file->ctxs)) {
ctx = list_entry(file->ctxs.next,
struct ib_ucm_context, file_list);
- up(&file->mutex);
+ mutex_unlock(&file->file_mutex);
mutex_lock(&ctx_id_mutex);
idr_remove(&ctx_id_table, ctx->id);
@@ -1207,9 +1205,9 @@ static int ib_ucm_close(struct inode *in
ib_ucm_cleanup_events(ctx);
kfree(ctx);
- down(&file->mutex);
+ mutex_lock(&file->file_mutex);
}
- up(&file->mutex);
+ mutex_unlock(&file->file_mutex);
kfree(file);
return 0;
}
More information about the general
mailing list