Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-10-10 22:04:15 +0200
committerTakashi Iwai <tiwai@suse.de>2018-10-10 22:04:52 +0200
commit59f750ce1cf5e38b2de439402d05fdc6186d9d66 (patch)
treef23c357f348b324fe1e0a81762f8615f8719b65b
parent5f7f6f015d7bcbd980a9ba05f46641cb11623cf8 (diff)
media: videobuf-dma-sg: Fix dma_{sync,unmap}_sg() calls
(bsc#1051510).
-rw-r--r--patches.drivers/media-videobuf-dma-sg-Fix-dma_-sync-unmap-_sg-calls.patch56
-rw-r--r--series.conf1
2 files changed, 57 insertions, 0 deletions
diff --git a/patches.drivers/media-videobuf-dma-sg-Fix-dma_-sync-unmap-_sg-calls.patch b/patches.drivers/media-videobuf-dma-sg-Fix-dma_-sync-unmap-_sg-calls.patch
new file mode 100644
index 0000000000..1bdae01e45
--- /dev/null
+++ b/patches.drivers/media-videobuf-dma-sg-Fix-dma_-sync-unmap-_sg-calls.patch
@@ -0,0 +1,56 @@
+From 4573027b67cbf51a1b4363e0e75437491c5279d9 Mon Sep 17 00:00:00 2001
+From: Robin Murphy <robin.murphy@arm.com>
+Date: Mon, 30 Apr 2018 12:56:28 -0400
+Subject: [PATCH] media: videobuf-dma-sg: Fix dma_{sync,unmap}_sg() calls
+Git-commit: 4573027b67cbf51a1b4363e0e75437491c5279d9
+Patch-mainline: v4.18-rc1
+References: bsc#1051510
+
+This reverts commit fc7f8fd42c2b934ac348995e0c530c917fc277d5.
+
+Whilst the rationale for the above commit was in general correct, i.e.
+that users *consuming* the DMA addresses should rely on sglen rather
+than num_pages, it has always been the case that the DMA API itself
+still requires that dma_{sync,unmap}_sg() are called with the original
+number of entries as passed to dma_map_sg(), not the number of mapped
+entries it returned. Thus the particular changes made in that patch
+were erroneous.
+
+At worst this might lead to data loss at the tail end of mapped buffers
+on non-coherent hardware, while at best it's an example of incorrect
+DMA API usage which has proven to mislead readers.
+
+Signed-off-by: Robin Murphy <robin.murphy@arm.com>
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/v4l2-core/videobuf-dma-sg.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c
+index eb3e2acf26a7..87b16773f326 100644
+--- a/drivers/media/v4l2-core/videobuf-dma-sg.c
++++ b/drivers/media/v4l2-core/videobuf-dma-sg.c
+@@ -334,7 +334,7 @@ int videobuf_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma)
+ if (!dma->sglen)
+ return 0;
+
+- dma_unmap_sg(dev, dma->sglist, dma->sglen, dma->direction);
++ dma_unmap_sg(dev, dma->sglist, dma->nr_pages, dma->direction);
+
+ vfree(dma->sglist);
+ dma->sglist = NULL;
+@@ -581,7 +581,7 @@ static int __videobuf_sync(struct videobuf_queue *q,
+ MAGIC_CHECK(mem->dma.magic, MAGIC_DMABUF);
+
+ dma_sync_sg_for_cpu(q->dev, mem->dma.sglist,
+- mem->dma.sglen, mem->dma.direction);
++ mem->dma.nr_pages, mem->dma.direction);
+
+ return 0;
+ }
+--
+2.18.0
+
diff --git a/series.conf b/series.conf
index a3f0d969eb..fca3618bca 100644
--- a/series.conf
+++ b/series.conf
@@ -16171,6 +16171,7 @@
patches.drivers/media-cx231xx-Add-support-for-AverMedia-DVD-EZMaker-
patches.drivers/media-siano-get-rid-of-__le32-__le16-cast-warnings
patches.drivers/media-cx88-Get-rid-of-spurious-call-to-cx8800_start_
+ patches.drivers/media-videobuf-dma-sg-Fix-dma_-sync-unmap-_sg-calls.patch
patches.drivers/media-saa7164-Fix-driver-name-in-debug-output
patches.drivers/media-media-device-fix-ioctl-function-types
patches.drivers/media-rcar_jpu-Add-missing-clk_disable_unprepare-on-