mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 00:12:36 -05:00
videobuf2/videobuf2-dma-sg.c: convert to use vm_map_pages()
Convert to use vm_map_pages() to map range of kernel memory to user vma. vm_pgoff is treated in V4L2 API as a 'cookie' to select a buffer, not as a in-buffer offset by design and it always want to mmap a whole buffer from its beginning. Link: http://lkml.kernel.org/r/a953fe6b3056de1cc6eab654effdd4a22f125375.1552921225.git.jrdr.linux@gmail.com Signed-off-by: Souptick Joarder <[email protected]> Suggested-by: Marek Szyprowski <[email protected]> Reviewed-by: Marek Szyprowski <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: David Airlie <[email protected]> Cc: Heiko Stuebner <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Kees Cook <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Kyungmin Park <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Oleksandr Andrushchenko <[email protected]> Cc: Pawel Osciak <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Russell King <[email protected]> Cc: Sandy Huang <[email protected]> Cc: Stefan Richter <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
b0d0084fd9
commit
a17ae14766
3 changed files with 13 additions and 22 deletions
|
|
@ -2201,6 +2201,13 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
|
|||
goto unlock;
|
||||
}
|
||||
|
||||
/*
|
||||
* vm_pgoff is treated in V4L2 API as a 'cookie' to select a buffer,
|
||||
* not as a in-buffer offset. We always want to mmap a whole buffer
|
||||
* from its beginning.
|
||||
*/
|
||||
vma->vm_pgoff = 0;
|
||||
|
||||
ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
|
||||
|
||||
unlock:
|
||||
|
|
|
|||
|
|
@ -186,12 +186,6 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to
|
||||
* map whole buffer
|
||||
*/
|
||||
vma->vm_pgoff = 0;
|
||||
|
||||
ret = dma_mmap_attrs(buf->dev, vma, buf->cookie,
|
||||
buf->dma_addr, buf->size, buf->attrs);
|
||||
|
||||
|
|
|
|||
|
|
@ -328,28 +328,18 @@ static unsigned int vb2_dma_sg_num_users(void *buf_priv)
|
|||
static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma)
|
||||
{
|
||||
struct vb2_dma_sg_buf *buf = buf_priv;
|
||||
unsigned long uaddr = vma->vm_start;
|
||||
unsigned long usize = vma->vm_end - vma->vm_start;
|
||||
int i = 0;
|
||||
int err;
|
||||
|
||||
if (!buf) {
|
||||
printk(KERN_ERR "No memory to map\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
do {
|
||||
int ret;
|
||||
|
||||
ret = vm_insert_page(vma, uaddr, buf->pages[i++]);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Remapping memory, error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uaddr += PAGE_SIZE;
|
||||
usize -= PAGE_SIZE;
|
||||
} while (usize > 0);
|
||||
|
||||
err = vm_map_pages(vma, buf->pages, buf->num_pages);
|
||||
if (err) {
|
||||
printk(KERN_ERR "Remapping memory, error: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use common vm_area operations to track buffer refcount.
|
||||
|
|
|
|||
Loading…
Reference in a new issue