Skip to content

Commit

Permalink
media: videobuf2: move cache_hints handling to allocators
Browse files Browse the repository at this point in the history
This moves cache hints handling from the videobuf2 core down
to the allocator's level, because allocators do the sync/flush
caches eventually and may take better decisions. Besides,
allocators already decide whether cache sync/flush should
be done or can be skipped. This patch moves the scattered
buffer cache sync logic to one common place.

Signed-off-by: Sergey Senozhatsky <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
sergey-senozhatsky authored and mchehab committed Sep 30, 2021
1 parent 0a12d65 commit cde513f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 0 additions & 6 deletions drivers/media/common/videobuf2/videobuf2-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ static void __vb2_buf_mem_prepare(struct vb2_buffer *vb)
return;

vb->synced = 1;
if (vb->skip_cache_sync_on_prepare)
return;

for (plane = 0; plane < vb->num_planes; ++plane)
call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
}
Expand All @@ -347,9 +344,6 @@ static void __vb2_buf_mem_finish(struct vb2_buffer *vb)
return;

vb->synced = 0;
if (vb->skip_cache_sync_on_finish)
return;

for (plane = 0; plane < vb->num_planes; ++plane)
call_void_memop(vb, finish, vb->planes[plane].mem_priv);
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/media/common/videobuf2/videobuf2-dma-contig.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ static void vb2_dc_prepare(void *buf_priv)
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;

if (buf->vb->skip_cache_sync_on_prepare)
return;

if (!sgt)
return;

Expand All @@ -112,6 +115,9 @@ static void vb2_dc_finish(void *buf_priv)
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;

if (buf->vb->skip_cache_sync_on_finish)
return;

if (!sgt)
return;

Expand Down
6 changes: 6 additions & 0 deletions drivers/media/common/videobuf2/videobuf2-dma-sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static void vb2_dma_sg_prepare(void *buf_priv)
struct vb2_dma_sg_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;

if (buf->vb->skip_cache_sync_on_prepare)
return;

dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
}

Expand All @@ -212,6 +215,9 @@ static void vb2_dma_sg_finish(void *buf_priv)
struct vb2_dma_sg_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;

if (buf->vb->skip_cache_sync_on_finish)
return;

dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
}

Expand Down

0 comments on commit cde513f

Please sign in to comment.