From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Tomasz Figa <tfiga@chromium.org>, Christoph Hellwig <hch@lst.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests
Date: Tue, 2 Mar 2021 09:49:22 +0900 [thread overview]
Message-ID: <20210302004922.32052-1-senozhatsky@chromium.org> (raw)
In-Reply-To: <20210302004624.31294-1-senozhatsky@chromium.org>
This returns back non-coherent (previously known as NON_COHERENT)
memory flag and buffer cache management hints testing (for VB2_MEMORY_MMAP
buffers).
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
utils/common/cv4l-helpers.h | 8 +--
utils/common/v4l-helpers.h | 8 ++-
utils/v4l2-compliance/v4l2-test-buffers.cpp | 65 ++++++++++++++++++---
3 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h
index 712efde6..3cee372b 100644
--- a/utils/common/cv4l-helpers.h
+++ b/utils/common/cv4l-helpers.h
@@ -754,17 +754,17 @@ public:
int g_fd(unsigned index, unsigned plane) const { return v4l_queue_g_fd(this, index, plane); }
void s_fd(unsigned index, unsigned plane, int fd) { v4l_queue_s_fd(this, index, plane, fd); }
- int reqbufs(cv4l_fd *fd, unsigned count = 0)
+ int reqbufs(cv4l_fd *fd, unsigned count = 0, unsigned int flags = 0)
{
- return v4l_queue_reqbufs(fd->g_v4l_fd(), this, count);
+ return v4l_queue_reqbufs(fd->g_v4l_fd(), this, count, flags);
}
bool has_create_bufs(cv4l_fd *fd) const
{
return v4l_queue_has_create_bufs(fd->g_v4l_fd(), this);
}
- int create_bufs(cv4l_fd *fd, unsigned count, const v4l2_format *fmt = NULL)
+ int create_bufs(cv4l_fd *fd, unsigned count, const v4l2_format *fmt = NULL, unsigned int flags = 0)
{
- return v4l_queue_create_bufs(fd->g_v4l_fd(), this, count, fmt);
+ return v4l_queue_create_bufs(fd->g_v4l_fd(), this, count, fmt, flags);
}
int mmap_bufs(cv4l_fd *fd, unsigned from = 0)
{
diff --git a/utils/common/v4l-helpers.h b/utils/common/v4l-helpers.h
index f96b3c38..c09cd987 100644
--- a/utils/common/v4l-helpers.h
+++ b/utils/common/v4l-helpers.h
@@ -1515,7 +1515,7 @@ static inline int v4l_queue_querybufs(struct v4l_fd *f, struct v4l_queue *q, uns
}
static inline int v4l_queue_reqbufs(struct v4l_fd *f,
- struct v4l_queue *q, unsigned count)
+ struct v4l_queue *q, unsigned count, unsigned int flags = 0)
{
struct v4l2_requestbuffers reqbufs;
int ret;
@@ -1523,6 +1523,7 @@ static inline int v4l_queue_reqbufs(struct v4l_fd *f,
reqbufs.type = q->type;
reqbufs.memory = q->memory;
reqbufs.count = count;
+ reqbufs.flags = flags;
/*
* Problem: if REQBUFS returns an error, did it free any old
* buffers or not?
@@ -1547,7 +1548,7 @@ static inline bool v4l_queue_has_create_bufs(struct v4l_fd *f, const struct v4l_
static inline int v4l_queue_create_bufs(struct v4l_fd *f,
struct v4l_queue *q, unsigned count,
- const struct v4l2_format *fmt)
+ const struct v4l2_format *fmt, unsigned int flags = 0)
{
struct v4l2_create_buffers createbufs;
int ret;
@@ -1555,6 +1556,7 @@ static inline int v4l_queue_create_bufs(struct v4l_fd *f,
createbufs.format.type = q->type;
createbufs.memory = q->memory;
createbufs.count = count;
+ createbufs.flags = flags;
if (fmt) {
createbufs.format = *fmt;
} else {
@@ -1733,7 +1735,7 @@ static inline void v4l_queue_free(struct v4l_fd *f, struct v4l_queue *q)
v4l_ioctl(f, VIDIOC_STREAMOFF, &q->type);
v4l_queue_release_bufs(f, q, 0);
v4l_queue_close_exported_fds(q);
- v4l_queue_reqbufs(f, q, 0);
+ v4l_queue_reqbufs(f, q, 0, 0);
}
static inline void v4l_queue_buffer_update(const struct v4l_queue *q,
diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index e40461bd..6555c0cb 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -663,6 +663,10 @@ int testReqBufs(struct node *node)
fail_on_test(q.reqbufs(node, 0));
for (m = V4L2_MEMORY_MMAP; m <= V4L2_MEMORY_DMABUF; m++) {
+ bool cache_hints_cap = false;
+ bool consistent;
+
+ cache_hints_cap = q.g_capabilities() & V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS;
if (!(node->valid_memorytype & (1 << m)))
continue;
cv4l_queue q2(i, m);
@@ -678,8 +682,17 @@ int testReqBufs(struct node *node)
reqbufs.count = 1;
reqbufs.type = i;
reqbufs.memory = m;
+ reqbufs.flags = V4L2_FLAG_MEMORY_NON_COHERENT;
fail_on_test(doioctl(node, VIDIOC_REQBUFS, &reqbufs));
- fail_on_test(check_0(reqbufs.reserved, sizeof(reqbufs.reserved)));
+ consistent = reqbufs.flags & V4L2_FLAG_MEMORY_NON_COHERENT;
+ if (!cache_hints_cap) {
+ fail_on_test(consistent);
+ } else {
+ if (m == V4L2_MEMORY_MMAP)
+ fail_on_test(!consistent);
+ else
+ fail_on_test(consistent);
+ }
q.reqbufs(node);
ret = q.create_bufs(node, 0);
@@ -692,9 +705,32 @@ int testReqBufs(struct node *node)
node->g_fmt(crbufs.format, i);
crbufs.count = 1;
crbufs.memory = m;
+ crbufs.flags = V4L2_FLAG_MEMORY_NON_COHERENT;
fail_on_test(doioctl(node, VIDIOC_CREATE_BUFS, &crbufs));
fail_on_test(check_0(crbufs.reserved, sizeof(crbufs.reserved)));
fail_on_test(crbufs.index != q.g_buffers());
+
+ consistent = crbufs.flags & V4L2_FLAG_MEMORY_NON_COHERENT;
+ if (!cache_hints_cap) {
+ fail_on_test(consistent);
+ } else {
+ if (m == V4L2_MEMORY_MMAP)
+ fail_on_test(!consistent);
+ else
+ fail_on_test(consistent);
+ }
+
+ if (cache_hints_cap) {
+ /*
+ * Different memory consistency model. Should fail for MMAP
+ * queues which support cache hints.
+ */
+ crbufs.flags = 0;
+ if (m == V4L2_MEMORY_MMAP)
+ fail_on_test(doioctl(node, VIDIOC_CREATE_BUFS, &crbufs) != EINVAL);
+ else
+ fail_on_test(doioctl(node, VIDIOC_CREATE_BUFS, &crbufs));
+ }
q.reqbufs(node);
fail_on_test(q.create_bufs(node, 1));
@@ -1207,10 +1243,16 @@ static int setupMmap(struct node *node, cv4l_queue &q)
fail_on_test(buf.querybuf(node, i));
fail_on_test(buf.check(q, Unqueued, i));
- flags = buf.g_flags();
- flags |= V4L2_BUF_FLAG_NO_CACHE_INVALIDATE;
- flags |= V4L2_BUF_FLAG_NO_CACHE_CLEAN;
- buf.s_flags(flags);
+ /*
+ * Do not set cache hints for all the buffers, but only on
+ * some of them, so that we can test more cases.
+ */
+ if (i == 0) {
+ flags = buf.g_flags();
+ flags |= V4L2_BUF_FLAG_NO_CACHE_INVALIDATE;
+ flags |= V4L2_BUF_FLAG_NO_CACHE_CLEAN;
+ buf.s_flags(flags);
+ }
for (unsigned p = 0; p < buf.g_num_planes(); p++) {
// Try a random offset
@@ -1250,8 +1292,15 @@ static int setupMmap(struct node *node, cv4l_queue &q)
}
flags = buf.g_flags();
if (cache_hints) {
- fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE));
- fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN));
+ if (i == 0) {
+ /* We do expect cache hints on this buffer */
+ fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE));
+ fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN));
+ } else {
+ /* We expect no cache hints on this buffer */
+ fail_on_test(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE);
+ fail_on_test(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN);
+ }
} else if (node->might_support_cache_hints) {
fail_on_test(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE);
fail_on_test(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN);
@@ -1341,7 +1390,7 @@ int testMmap(struct node *node, struct node *node_m2m_cap, unsigned frame_count,
have_createbufs = false;
if (have_createbufs) {
q.reqbufs(node);
- q.create_bufs(node, 2, &cur_fmt);
+ q.create_bufs(node, 2, &cur_fmt, V4L2_FLAG_MEMORY_NON_COHERENT);
fail_on_test(setupMmap(node, q));
q.munmap_bufs(node);
q.reqbufs(node, 2);
--
2.27.0
next prev parent reply other threads:[~2021-03-02 7:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 0:46 [PATCH 0/8] videobuf2: support new noncontiguous DMA API Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 1/8] videobuf2: rework vb2_mem_ops API Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 2/8] videobuf2: inverse buffer cache_hints flags Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 3/8] videobuf2: split buffer cache_hints initialisation Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 4/8] videobuf2: move cache_hints handling to allocators Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 5/8] videobuf2: add V4L2_FLAG_MEMORY_NON_COHERENT flag Sergey Senozhatsky
2021-03-22 7:02 ` Hans Verkuil
2021-03-02 0:46 ` [PATCH 6/8] videobuf2: add queue memory coherency parameter Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 7/8] videobuf2: handle V4L2_FLAG_MEMORY_NON_COHERENT flag Sergey Senozhatsky
2021-03-22 7:16 ` Hans Verkuil
2021-03-22 7:18 ` Hans Verkuil
2021-03-02 0:46 ` [PATCH 8/8] videobuf2: handle non-contiguous DMA allocations Sergey Senozhatsky
2021-03-22 7:40 ` Hans Verkuil
2021-03-24 12:07 ` Tomasz Figa
2023-07-04 10:50 ` Hsia-Jun Li
2023-07-05 10:45 ` Tomasz Figa
2023-07-17 9:21 ` Hsia-Jun Li
2023-07-28 8:19 ` Tomasz Figa
2021-03-02 0:49 ` Sergey Senozhatsky [this message]
2021-03-02 0:50 ` [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Sergey Senozhatsky
2021-03-24 12:09 ` [PATCH 0/8] videobuf2: support new noncontiguous DMA API Tomasz Figa
2021-04-27 13:20 [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Sergey Senozhatsky
2021-07-09 9:22 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
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=20210302004922.32052-1-senozhatsky@chromium.org \
--to=senozhatsky@chromium.org \
--cc=hch@lst.de \
--cc=hverkuil-cisco@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;
as well as URLs for NNTP newsgroup(s).