summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2018-04-30 12:56:28 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-05-09 16:25:12 -0400
commit4573027b67cbf51a1b4363e0e75437491c5279d9 (patch)
treeaed863c8a4b66d0ac32fcbe0693cd942072b99e2 /drivers/media/v4l2-core
parentc591358446a298aab69cc7b405fc0db4f6da2d53 (diff)
downloadop-kernel-dev-4573027b67cbf51a1b4363e0e75437491c5279d9.zip
op-kernel-dev-4573027b67cbf51a1b4363e0e75437491c5279d9.tar.gz
media: videobuf-dma-sg: Fix dma_{sync,unmap}_sg() calls
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>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/videobuf-dma-sg.c4
1 files 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 eb3e2ac..87b1677 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;
}
OpenPOWER on IntegriCloud