@@ -115,9 +115,10 @@ static void vb2_dc_finish(void *buf_priv)
* DMABUF exporter will flush the cache for us; only USERPTR
* and MMAP buffers with non-coherent memory will be flushed.
*/
- if (buf->attrs & DMA_ATTR_NON_CONSISTENT && !WARN_ON_ONCE(!sgt))
+ if (buf->attrs & DMA_ATTR_NON_CONSISTENT && !WARN_ON_ONCE(!sgt) &&
+ buf->dma_dir == DMA_FROM_DEVICE)
dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir);
+ DMA_FROM_DEVICE);
}
/*********************************************/
@@ -218,9 +218,10 @@ static void vb2_dma_sg_finish(void *buf_priv)
* DMABUF exporter will flush the cache for us; only USERPTR
* and MMAP buffers with non-coherent memory will be flushed.
*/
- if (buf->dma_attrs & DMA_ATTR_NON_CONSISTENT)
+ if (buf->dma_attrs & DMA_ATTR_NON_CONSISTENT &&
+ buf->dma_dir == DMA_FROM_DEVICE)
dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents,
- buf->dma_dir);
+ DMA_FROM_DEVICE);
}
static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr,
There is no need synchronise buffer cache for OUTPUT devices when the buffer is dequeued as the hardware only reads from the buffer. Only sync for capture buffers. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 5 +++-- drivers/media/v4l2-core/videobuf2-dma-sg.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)