All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Tomasz Figa <tfiga@chromium.org>,
	Ricardo Ribalda <ribalda@chromium.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests
Date: Fri, 10 Sep 2021 23:16:27 +0900	[thread overview]
Message-ID: <YTtouz4IG/UPq84K@google.com> (raw)
In-Reply-To: <YTtePjJoynZ4imCp@google.com>

On (21/09/10 22:31), Sergey Senozhatsky wrote:
> > 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));


Alternatively, we can do something like below on the kernel side instead:
do nothing in v4l2 for DMABUF and preserve b->flags (if user-space has
passed cache management flags).

// But I think it'll be better to clear b->flags cache hints for DMABUF. To
// indicate that we don't accept cache-hints for DMABUF.


---

diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 6edf4508c636..fc8e31b7dced 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -345,6 +345,13 @@ static void set_buffer_cache_hints(struct vb2_queue *q,
 				   struct vb2_buffer *vb,
 				   struct v4l2_buffer *b)
 {
+	/*
+	 * No user-space cache hints for DMABUF, but we preserve b->flags
+	 * cache hints (if user-space has passed any).
+	 */
+	if (q->memory == VB2_MEMORY_DMABUF)
+		return;
+
 	if (!vb2_queue_allows_cache_hints(q)) {
 		/*
 		 * Clear buffer cache flags if queue does not support user

  reply	other threads:[~2021-09-10 14:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  9:22 [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Sergey Senozhatsky
2021-09-10 12:20 ` Hans Verkuil
2021-09-10 12:48   ` Sergey Senozhatsky
2021-09-10 13:31     ` Sergey Senozhatsky
2021-09-10 14:16       ` Sergey Senozhatsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-04-27 13:20 Sergey Senozhatsky
2021-03-02  0:46 [PATCH 0/8] videobuf2: support new noncontiguous DMA API Sergey Senozhatsky
2021-03-02  0:49 ` [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Sergey Senozhatsky
2021-03-02  0:50   ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YTtouz4IG/UPq84K@google.com \
    --to=senozhatsky@chromium.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=ribalda@chromium.org \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.