Skip to content

Commit bac63f1

Browse files
sergey-senozhatskymchehab
authored andcommitted
media: vb2: set cache sync hints when init buffers
We need to set ->need_cache_sync_on_prepare and ->need_cache_sync_on_finish when we initialize vb2 buffer. Currently these flags are set/adjusted only in V4L2's vb2_queue_or_prepare_buf(), which means that for the code paths that don't use V4L2 vb2 will always tell videobuf2 core to skip ->prepare() and ->finish() cache syncs/flushes. Fix this by setting cache sync hints for new buffers; except VB2_MEMORY_DMABUF buffers, for which DMA exporter syncs caches. Fixes: f5f5fa7 ("media: videobuf2: handle V4L2 buffer cache flags") Reported-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 45ba1c0 commit bac63f1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/media/common/videobuf2/videobuf2-core.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,17 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
414414
vb->index = q->num_buffers + buffer;
415415
vb->type = q->type;
416416
vb->memory = memory;
417+
/*
418+
* We need to set these flags here so that the videobuf2 core
419+
* will call ->prepare()/->finish() cache sync/flush on vb2
420+
* buffers when appropriate. However, we can avoid explicit
421+
* ->prepare() and ->finish() cache sync for DMABUF buffers,
422+
* because DMA exporter takes care of it.
423+
*/
424+
if (q->memory != VB2_MEMORY_DMABUF) {
425+
vb->need_cache_sync_on_prepare = 1;
426+
vb->need_cache_sync_on_finish = 1;
427+
}
417428
for (plane = 0; plane < num_planes; ++plane) {
418429
vb->planes[plane].length = plane_sizes[plane];
419430
vb->planes[plane].min_length = plane_sizes[plane];

0 commit comments

Comments
 (0)