From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Tomasz Figa <tfiga@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH] videobuf2: always re-init queue memory consistency attribute
Date: Tue, 9 Jun 2020 15:04:17 +0900 [thread overview]
Message-ID: <20200609060417.8066-1-sergey.senozhatsky@gmail.com> (raw)
We need a combination of two factors in order to permit modification
of queue's memory consistency attribute in set_queue_consistency():
(1) queue should allow user-space cache hints
(2) queue should be used for MMAP-ed I/O
Therefore the code in videobuf2 core looks as follows:
q->memory = req->memory;
set_queue_consistency(q, consistent);
This works when we do something like this (suppose that queue allows
cache hints)
reqbufs.memory = V4L2_MEMORY_DMABUF;
reqbufs.flags = 0;
doioctl(node, VIDIOC_REQBUFS, &reqbufs);
reqbufs.memory = V4L2_MEMORY_MMAP;
reqbufs.flags = V4L2_FLAG_MEMORY_NON_CONSISTENT;
doioctl(node, VIDIOC_REQBUFS, &reqbufs);
However, this doesn't work the other way around
reqbufs.memory = V4L2_MEMORY_MMAP;
reqbufs.flags = V4L2_FLAG_MEMORY_NON_CONSISTENT;
doioctl(node, VIDIOC_REQBUFS, &reqbufs);
reqbufs.memory = V4L2_MEMORY_DMABUF;
reqbufs.flags = 0;
doioctl(node, VIDIOC_REQBUFS, &reqbufs);
because __vb2_queue_free() doesn't clear queue's ->dma_attrs
once its don't freeing queue buffers, and by the time we call
set_queue_consistency() the queue is DMABUF so (2) is false
and we never clear the stale consistency attribute.
Re-implement set_queue_consistency() - it must always clear
queue's non-consistency attr and set it only if (1) and (2).
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/media/common/videobuf2/videobuf2-core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 7e081716b8da..37d0186ba330 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -704,12 +704,11 @@ EXPORT_SYMBOL(vb2_verify_memory_type);
static void set_queue_consistency(struct vb2_queue *q, bool consistent_mem)
{
+ q->dma_attrs &= ~DMA_ATTR_NON_CONSISTENT;
+
if (!vb2_queue_allows_cache_hints(q))
return;
-
- if (consistent_mem)
- q->dma_attrs &= ~DMA_ATTR_NON_CONSISTENT;
- else
+ if (!consistent_mem)
q->dma_attrs |= DMA_ATTR_NON_CONSISTENT;
}
--
2.27.0
next reply other threads:[~2020-06-09 6:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 6:04 Sergey Senozhatsky [this message]
2020-06-10 9:54 ` Hans Verkuil
2020-06-10 10:10 ` Sergey Senozhatsky
2020-06-10 10:17 ` Tomasz Figa
2020-06-10 10:48 ` 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=20200609060417.8066-1-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®