diff options
author | Kirill Artamonov <kartamonov@nvidia.com> | 2011-02-15 01:07:20 +0200 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-02-16 00:10:30 -0800 |
commit | 2e25fa9c17c2863c44a4c207e68e6480ff09f1ac (patch) | |
tree | 681d03d8b2f39367acebbe7e2362822f7f4edf63 | |
parent | d3b07f3a86353a37900a5928d1af518b01469b13 (diff) |
video: tegra: nvmap: replace mutex with spinlock
There are places where nvmap_free_handle_id is called
when interrupts are disabled and mutex cannot be used as
nvmap handle lock.
Change-Id: Icc220fe627c08f21c677d936a54f70c818dc8e8c
Reviewed-on: http://git-master/r/19489
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap.c | 4 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap.h | 2 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_dev.c | 4 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_handle.c | 14 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_heap.c | 10 | ||||
-rwxr-xr-x | drivers/video/tegra/nvmap/nvmap_ioctl.c | 12 |
6 files changed, 23 insertions, 23 deletions
diff --git a/drivers/video/tegra/nvmap/nvmap.c b/drivers/video/tegra/nvmap/nvmap.c index 00b9a5adb49f..46d3386059b6 100644 --- a/drivers/video/tegra/nvmap/nvmap.c +++ b/drivers/video/tegra/nvmap/nvmap.c @@ -579,9 +579,9 @@ unsigned long nvmap_handle_address(struct nvmap_client *c, unsigned long id) h = nvmap_get_handle_id(c, id); if (!h) return -EPERM; - mutex_lock(&h->lock); + spin_lock(&h->lock); phys = handle_phys(h); - mutex_unlock(&h->lock); + spin_unlock(&h->lock); nvmap_handle_put(h); return phys; diff --git a/drivers/video/tegra/nvmap/nvmap.h b/drivers/video/tegra/nvmap/nvmap.h index 54d9fc664591..0d1e1eec48b5 100644 --- a/drivers/video/tegra/nvmap/nvmap.h +++ b/drivers/video/tegra/nvmap/nvmap.h @@ -81,7 +81,7 @@ struct nvmap_handle { bool secure; /* zap IOVMM area on unpin */ bool heap_pgalloc; /* handle is page allocated (sysmem / iovmm) */ bool alloc; /* handle has memory allocated */ - struct mutex lock; + spinlock_t lock; }; struct nvmap_share { diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c index 3d0e69b83b51..780fadc02743 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev.c +++ b/drivers/video/tegra/nvmap/nvmap_dev.c @@ -651,10 +651,10 @@ static void destroy_client(struct nvmap_client *client) smp_rmb(); pins = atomic_read(&ref->pin); - mutex_lock(&ref->handle->lock); + spin_lock(&ref->handle->lock); if (ref->handle->owner == client) ref->handle->owner = NULL; - mutex_unlock(&ref->handle->lock); + spin_unlock(&ref->handle->lock); while (pins--) nvmap_unpin_handles(client, &ref->handle, 1); diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index f01149dfabe4..c8a2c1fc9c79 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -371,11 +371,11 @@ void nvmap_free_handle_id(struct nvmap_client *client, unsigned long id) atomic_sub(h->size, &client->iovm_commit); if (h->alloc && !h->heap_pgalloc) { - mutex_lock(&h->lock); + spin_lock(&h->lock); nvmap_carveout_commit_subtract(client, nvmap_heap_to_arg(nvmap_block_to_heap(h->carveout)), h->size); - mutex_unlock(&h->lock); + spin_unlock(&h->lock); } nvmap_ref_unlock(client); @@ -387,10 +387,10 @@ void nvmap_free_handle_id(struct nvmap_client *client, unsigned long id) while (pins--) nvmap_unpin_handles(client, &ref->handle, 1); - mutex_lock(&h->lock); + spin_lock(&h->lock); if (h->owner == client) h->owner = NULL; - mutex_unlock(&h->lock); + spin_unlock(&h->lock); kfree(ref); @@ -446,7 +446,7 @@ struct nvmap_handle_ref *nvmap_create_handle(struct nvmap_client *client, BUG_ON(!h->owner); h->size = h->orig_size = size; h->flags = NVMAP_HANDLE_WRITE_COMBINE; - mutex_init(&h->lock); + spin_lock_init(&h->lock); nvmap_handle_add(client->dev, h); @@ -516,11 +516,11 @@ struct nvmap_handle_ref *nvmap_duplicate_handle_id(struct nvmap_client *client, } if (!h->heap_pgalloc) { - mutex_lock(&h->lock); + spin_lock(&h->lock); nvmap_carveout_commit_add(client, nvmap_heap_to_arg(nvmap_block_to_heap(h->carveout)), h->size); - mutex_unlock(&h->lock); + spin_unlock(&h->lock); } atomic_set(&ref->dupes, 1); diff --git a/drivers/video/tegra/nvmap/nvmap_heap.c b/drivers/video/tegra/nvmap/nvmap_heap.c index c8355684f1f9..0d7e1cd31bb8 100644 --- a/drivers/video/tegra/nvmap/nvmap_heap.c +++ b/drivers/video/tegra/nvmap/nvmap_heap.c @@ -702,10 +702,10 @@ static struct nvmap_heap_block *do_heap_relocate_listblock( return NULL; } - mutex_lock(&handle->lock); + spin_lock(&handle->lock); if (!handle->owner) { - mutex_unlock(&handle->lock); + spin_unlock(&handle->lock); return NULL; } @@ -756,7 +756,7 @@ static struct nvmap_heap_block *do_heap_relocate_listblock( fail: mutex_unlock(&handle->owner->share->pin_lock); - mutex_unlock(&handle->lock); + spin_unlock(&handle->lock); return heap_block_new; } @@ -829,9 +829,9 @@ static void nvmap_heap_compact(struct nvmap_heap *heap, void nvmap_usecount_inc(struct nvmap_handle *h) { if (h->alloc && !h->heap_pgalloc) { - mutex_lock(&h->lock); + spin_lock(&h->lock); h->usecount++; - mutex_unlock(&h->lock); + spin_unlock(&h->lock); } else { h->usecount++; } diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 886f0ee252ad..051794708109 100755 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -321,7 +321,7 @@ int nvmap_ioctl_get_param(struct file *filp, void __user* arg) op.result = h->orig_size; break; case NVMAP_HANDLE_PARAM_ALIGNMENT: - mutex_lock(&h->lock); + spin_lock(&h->lock); if (!h->alloc) op.result = 0; else if (h->heap_pgalloc) @@ -330,15 +330,15 @@ int nvmap_ioctl_get_param(struct file *filp, void __user* arg) op.result = (h->carveout->base & -h->carveout->base); else op.result = SZ_4M; - mutex_unlock(&h->lock); + spin_unlock(&h->lock); break; case NVMAP_HANDLE_PARAM_BASE: if (WARN_ON(!h->alloc || !atomic_add_return(0, &h->pin))) op.result = -1ul; else if (!h->heap_pgalloc) { - mutex_lock(&h->lock); + spin_lock(&h->lock); op.result = h->carveout->base; - mutex_unlock(&h->lock); + spin_unlock(&h->lock); } else if (h->pgalloc.contig) op.result = page_to_phys(h->pgalloc.pages[0]); @@ -351,9 +351,9 @@ int nvmap_ioctl_get_param(struct file *filp, void __user* arg) if (!h->alloc) op.result = 0; else if (!h->heap_pgalloc) { - mutex_lock(&h->lock); + spin_lock(&h->lock); op.result = nvmap_carveout_usage(client, h->carveout); - mutex_unlock(&h->lock); + spin_unlock(&h->lock); } else if (h->pgalloc.contig) op.result = NVMAP_HEAP_SYSMEM; |