diff options
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-dma-contig.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c index 7d77e4d30c8a..44cd0e530bbd 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c | |||
@@ -267,8 +267,14 @@ static void vb2_dc_dmabuf_ops_detach(struct dma_buf *dbuf, | |||
267 | 267 | ||
268 | /* release the scatterlist cache */ | 268 | /* release the scatterlist cache */ |
269 | if (attach->dma_dir != DMA_NONE) | 269 | if (attach->dma_dir != DMA_NONE) |
270 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | 270 | /* |
271 | attach->dma_dir); | 271 | * Cache sync can be skipped here, as the vb2_dc memory is |
272 | * allocated from device coherent memory, which means the | ||
273 | * memory locations do not require any explicit cache | ||
274 | * maintenance prior or after being used by the device. | ||
275 | */ | ||
276 | dma_unmap_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
277 | attach->dma_dir, DMA_ATTR_SKIP_CPU_SYNC); | ||
272 | sg_free_table(sgt); | 278 | sg_free_table(sgt); |
273 | kfree(attach); | 279 | kfree(attach); |
274 | db_attach->priv = NULL; | 280 | db_attach->priv = NULL; |
@@ -293,14 +299,17 @@ static struct sg_table *vb2_dc_dmabuf_ops_map( | |||
293 | 299 | ||
294 | /* release any previous cache */ | 300 | /* release any previous cache */ |
295 | if (attach->dma_dir != DMA_NONE) { | 301 | if (attach->dma_dir != DMA_NONE) { |
296 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | 302 | dma_unmap_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents, |
297 | attach->dma_dir); | 303 | attach->dma_dir, DMA_ATTR_SKIP_CPU_SYNC); |
298 | attach->dma_dir = DMA_NONE; | 304 | attach->dma_dir = DMA_NONE; |
299 | } | 305 | } |
300 | 306 | ||
301 | /* mapping to the client with new direction */ | 307 | /* |
302 | sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | 308 | * mapping to the client with new direction, no cache sync |
303 | dma_dir); | 309 | * required see comment in vb2_dc_dmabuf_ops_detach() |
310 | */ | ||
311 | sgt->nents = dma_map_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
312 | dma_dir, DMA_ATTR_SKIP_CPU_SYNC); | ||
304 | if (!sgt->nents) { | 313 | if (!sgt->nents) { |
305 | pr_err("failed to map scatterlist\n"); | 314 | pr_err("failed to map scatterlist\n"); |
306 | mutex_unlock(lock); | 315 | mutex_unlock(lock); |