]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: videobuf2-dma-contig: Invalidate vmap range before DMA range
authorSergey Senozhatsky <senozhatsky@chromium.org>
Wed, 19 Jan 2022 08:14:17 +0000 (09:14 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 7 Mar 2022 10:05:17 +0000 (11:05 +0100)
Christoph suggests [1] that invalidating vmap range before
direct mapping range makes more sense.

[1]: https://lore.kernel.org/all/20220111085958.GA22795@lst.de/

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/common/videobuf2/videobuf2-dma-contig.c

index 7c4096e62173870c1b132aa18d8d211b6a8f5ea2..0e3f264122affcbdec2b21f7c1eac7f49646b475 100644 (file)
@@ -132,12 +132,12 @@ static void vb2_dc_prepare(void *buf_priv)
        if (!buf->non_coherent_mem)
                return;
 
-       /* For both USERPTR and non-coherent MMAP */
-       dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
-
        /* Non-coherent MMAP only */
        if (buf->vaddr)
                flush_kernel_vmap_range(buf->vaddr, buf->size);
+
+       /* For both USERPTR and non-coherent MMAP */
+       dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
 }
 
 static void vb2_dc_finish(void *buf_priv)
@@ -152,12 +152,12 @@ static void vb2_dc_finish(void *buf_priv)
        if (!buf->non_coherent_mem)
                return;
 
-       /* For both USERPTR and non-coherent MMAP */
-       dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
-
        /* Non-coherent MMAP only */
        if (buf->vaddr)
                invalidate_kernel_vmap_range(buf->vaddr, buf->size);
+
+       /* For both USERPTR and non-coherent MMAP */
+       dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
 }
 
 /*********************************************/