aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/videobuf2-vmalloc.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2015-03-17 08:56:31 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-01 07:17:27 -0300
commit48b25a3a713b90988b6882d318f7c0a6bed9aabc (patch)
tree818fab949bd94cbafbef001ca307d4756dd9df1c /drivers/media/v4l2-core/videobuf2-vmalloc.c
parent9c3f205252f8ae2af9794d68bcbfc49fb0812ccf (diff)
[media] vb2: Push mmap_sem down to memops
Currently vb2 core acquires mmap_sem just around call to __qbuf_userptr(). However since commit f035eb4e976ef5 (videobuf2: fix lockdep warning) it isn't necessary to acquire it so early as we no longer have to drop queue mutex before acquiring mmap_sem. So push acquisition of mmap_sem down into .get_userptr and .put_userptr memops so that the semaphore is acquired for a shorter time and it is clearer what it is needed for. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf2-vmalloc.c')
-rw-r--r--drivers/media/v4l2-core/videobuf2-vmalloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 657ab302a5cf..0ba40be21ebd 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -89,7 +89,7 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr,
offset = vaddr & ~PAGE_MASK;
buf->size = size;
-
+ down_read(&current->mm->mmap_sem);
vma = find_vma(current->mm, vaddr);
if (vma && (vma->vm_flags & VM_PFNMAP) && (vma->vm_pgoff)) {
if (vb2_get_contig_userptr(vaddr, size, &vma, &physp))
@@ -121,6 +121,7 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr,
if (!buf->vaddr)
goto fail_get_user_pages;
}
+ up_read(&current->mm->mmap_sem);
buf->vaddr += offset;
return buf;
@@ -133,6 +134,7 @@ fail_get_user_pages:
kfree(buf->pages);
fail_pages_array_alloc:
+ up_read(&current->mm->mmap_sem);
kfree(buf);
return NULL;
@@ -144,6 +146,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
unsigned long vaddr = (unsigned long)buf->vaddr & PAGE_MASK;
unsigned int i;
+ down_read(&current->mm->mmap_sem);
if (buf->pages) {
if (vaddr)
vm_unmap_ram((void *)vaddr, buf->n_pages);
@@ -157,6 +160,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
vb2_put_vma(buf->vma);
iounmap((__force void __iomem *)buf->vaddr);
}
+ up_read(&current->mm->mmap_sem);
kfree(buf);
}

Privacy Policy