Re: [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests

From: Sergey Senozhatsky
Date: Fri Sep 10 2021 - 09:32:01 EST


On (21/09/10 21:48), Sergey Senozhatsky wrote:
> > Streaming ioctls:
> > test read/write: OK (Not Supported)
> > test blocking wait: OK
> > Video Capture: Captured 8 buffers
> > test MMAP (no poll): OK
> > Video Capture: Captured 8 buffers
> > test MMAP (select): OK
> > Video Capture: Captured 8 buffers
> > test MMAP (epoll): OK
> > Video Capture: Captured 8 buffers
> > test USERPTR (no poll): OK
> > Video Capture: Captured 8 buffers
> > test USERPTR (select): OK
> > fail: v4l2-test-buffers.cpp(1869): !(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE)
> > fail: v4l2-test-buffers.cpp(1932): setupDmaBuf(expbuf_node, node, q, exp_q)
> > test DMABUF (no poll): FAIL
> > fail: v4l2-test-buffers.cpp(1869): !(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE)
> > fail: v4l2-test-buffers.cpp(1932): setupDmaBuf(expbuf_node, node, q, exp_q)
> > test DMABUF (select): FAIL
> >
> > The same happens with e.g. vivid, but vim2m is quicker to test.
> >
> > I'm not sure whether this is a bug in this v4l2-compliance patch or whether it is
> > a bug in the v6 series, but it should be checked.
>
> Looking into it now. I ran v4l2-compliance, but not "contrib/test/test-media"

AFAICT the problem is in v4l2-compliance patch.

We clear request flags if queue does not support user-space cache hints:

q->allow_cache_hints && q->memory == VB2_MEMORY_MMAP

But for DMABUF buffers (only) we set cache hints internally in
set_buffer_cache_hints() and always skip cache sync/flush on
prepare/finish regardless of what is passed from the user-space:

if (q->memory == VB2_MEMORY_DMABUF) {
vb->skip_cache_sync_on_finish = 1;
vb->skip_cache_sync_on_prepare = 1;
return;
}

Technically we don't support user-space cache hints for DMABUF, so we
clear passed user-space cache hint flags.

I think the fix should look like this (tested with "test-media vivid"):

---

diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index 9b87c90f..baa306f1 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -1865,9 +1865,10 @@ static int setupDmaBuf(struct node *expbuf_node, struct node *node,
fail_on_test(!buf.g_bytesused(p));
}
flags = buf.g_flags();
- /* We always skip cache sync/flush for DMABUF memory type */
- fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE));
- fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN));
+
+ /* Make sure that flags are cleared */
+ fail_on_test((flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE));
+ fail_on_test((flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN));
fail_on_test(flags & V4L2_BUF_FLAG_DONE);
fail_on_test(buf.querybuf(node, i));
fail_on_test(buf.check(q, Queued, i));