aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-05-22 07:16:20 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-05-22 07:16:20 (GMT)
commitde46960794c829a826c366f2b629148b147c1d55 (patch)
tree4b7e16aeefe4f48dab2b4c9a88c82e1337767a56
parent3e265872b75e632f05c9247a9a915bcc1e955a75 (diff)
Add backports/v5.1_vm_map_pages.patch
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--backports/backports.txt3
-rw-r--r--backports/v5.1_vm_map_pages.patch74
2 files changed, 77 insertions, 0 deletions
diff --git a/backports/backports.txt b/backports/backports.txt
index 5be8bce..5940005 100644
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -26,6 +26,9 @@ add pr_fmt.patch
add debug.patch
add drx39xxj.patch
+[5.1.255]
+add v5.1_vm_map_pages.patch
+
[5.0.255]
add v5.0_ipu3-cio2.patch
diff --git a/backports/v5.1_vm_map_pages.patch b/backports/v5.1_vm_map_pages.patch
new file mode 100644
index 0000000..62478b2
--- /dev/null
+++ b/backports/v5.1_vm_map_pages.patch
@@ -0,0 +1,74 @@
+diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
+index 3cf25abf5807..7ebd58a1c431 100644
+--- a/drivers/media/common/videobuf2/videobuf2-core.c
++++ b/drivers/media/common/videobuf2/videobuf2-core.c
+@@ -2201,13 +2201,6 @@ 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:
+diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+index ecbef266130b..82389aead6ed 100644
+--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
++++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+@@ -186,6 +186,12 @@ 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);
+
+diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+index 4a4c49d6085c..270c3162fdcb 100644
+--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
++++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+@@ -328,18 +328,28 @@ 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;
+- int err;
++ unsigned long uaddr = vma->vm_start;
++ unsigned long usize = vma->vm_end - vma->vm_start;
++ int i = 0;
+
+ if (!buf) {
+ printk(KERN_ERR "No memory to map\n");
+ return -EINVAL;
+ }
+
+- err = vm_map_pages(vma, buf->pages, buf->num_pages);
+- if (err) {
+- printk(KERN_ERR "Remapping memory, error: %d\n", err);
+- return err;
+- }
++ 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);
++
+
+ /*
+ * Use common vm_area operations to track buffer refcount.

Privacy Policy