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;
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 {
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);
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);
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);
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);
}
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);
return NULL;
}
- mutex_lock(&handle->lock);
+ spin_lock(&handle->lock);
if (!handle->owner) {
- mutex_unlock(&handle->lock);
+ spin_unlock(&handle->lock);
return NULL;
}
fail:
mutex_unlock(&handle->owner->share->pin_lock);
- mutex_unlock(&handle->lock);
+ spin_unlock(&handle->lock);
return heap_block_new;
}
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++;
}
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)
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]);
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;