+ videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: videobuf2/videobuf2-dma-sg.c: convert to use vm_map_pages()
has been added to the -mm tree.  Its filename is
     videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Souptick Joarder <jrdr.linux@xxxxxxxxx>
Subject: 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@xxxxxxxxx
Signed-off-by: Souptick Joarder <jrdr.linux@xxxxxxxxx>
Suggested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Reviewed-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Cc: David Airlie <airlied@xxxxxxxx>
Cc: Heiko Stuebner <heiko@xxxxxxxxx>
Cc: Joerg Roedel <joro@xxxxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>
Cc: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx>
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
Cc: Pawel Osciak <pawel@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxxx>
Cc: Robin Murphy <robin.murphy@xxxxxxx>
Cc: Russell King <linux@xxxxxxxxxxxxxxx>
Cc: Sandy Huang <hjc@xxxxxxxxxxxxxx>
Cc: Stefan Richter <stefanr@xxxxxxxxxxxxxxxxx>
Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Cc: Thierry Reding <treding@xxxxxxxxxx>
Cc: Vlastimil Babka <vbabka@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/media/common/videobuf2/videobuf2-core.c       |    7 +++
 drivers/media/common/videobuf2/videobuf2-dma-contig.c |    6 --
 drivers/media/common/videobuf2/videobuf2-dma-sg.c     |   22 ++--------
 3 files changed, 13 insertions(+), 22 deletions(-)

--- a/drivers/media/common/videobuf2/videobuf2-core.c~videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages
+++ a/drivers/media/common/videobuf2/videobuf2-core.c
@@ -2188,6 +2188,13 @@ int vb2_mmap(struct vb2_queue *q, struct
 		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:
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c~videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages
+++ a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -186,12 +186,6 @@ static int vb2_dc_mmap(void *buf_priv, s
 		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);
 
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c~videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages
+++ a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -328,28 +328,18 @@ static unsigned int vb2_dma_sg_num_users
 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.
_

Patches currently in -mm which might be from jrdr.linux@xxxxxxxxx are

mm-introduce-new-vm_map_pages-and-vm_map_pages_zero-api.patch
arm-mm-dma-mapping-convert-to-use-vm_map_pages.patch
drivers-firewire-core-isoc-convert-to-use-vm_map_pages_zero.patch
drm-rockchip-rockchip_drm_gemc-convert-to-use-vm_map_pages.patch
drm-xen-xen_drm_front_gemc-convert-to-use-vm_map_pages.patch
iommu-dma-iommuc-convert-to-use-vm_map_pages.patch
videobuf2-videobuf2-dma-sgc-convert-to-use-vm_map_pages.patch
xen-gntdevc-convert-to-use-vm_map_pages.patch
xen-privcmd-bufc-convert-to-use-vm_map_pages_zero.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux