From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Tomasz Figa <tfiga@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sakari Ailus <sakari.ailus@iki.fi>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Pawel Osciak <posciak@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv4 03/11] videobuf2: add V4L2_FLAG_MEMORY_NON_CONSISTENT flag
Date: Fri, 6 Mar 2020 14:58:40 +0100 [thread overview]
Message-ID: <40b1cc23-5e28-837b-49d5-e32d9dd3edee@xs4all.nl> (raw)
In-Reply-To: <20200302041213.27662-4-senozhatsky@chromium.org>
On 02/03/2020 05:12, Sergey Senozhatsky wrote:
> By setting or clearing V4L2_FLAG_MEMORY_NON_CONSISTENT flag
> user-space should be able to set or clear queue's NON_CONSISTENT
> ->dma_attrs. Queue's ->dma_attrs are passed to the underlying
> allocator in __vb2_buf_mem_alloc(), so thus user-space is able
> to request vb2 buffer's memory to be either consistent (coherent)
> or non-consistent.
>
> The patch set also adds a corresponding capability flag:
> fill_buf_caps() reports V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS when
> queue supports user-space cache management hints.
When building the docs I got a bunch of reference errors. This patch fixes those:
-----------------------------------------------
diff --git b/Documentation/media/uapi/v4l/buffer.rst a/Documentation/media/uapi/v4l/buffer.rst
index 8084e3f2a58d..82bad4dbec16 100644
--- b/Documentation/media/uapi/v4l/buffer.rst
+++ a/Documentation/media/uapi/v4l/buffer.rst
@@ -695,7 +695,7 @@ Memory Consistency Flags
:stub-columns: 0
:widths: 3 1 4
- * .. _`V4L2_FLAG_MEMORY_NON_CONSISTENT`:
+ * .. _`V4L2-FLAG-MEMORY-NON-CONSISTENT`:
- ``V4L2_FLAG_MEMORY_NON_CONSISTENT``
- 0x00000001
@@ -709,7 +709,9 @@ Memory Consistency Flags
consistency is needed. If this flag is set V4L2 will attempt to
allocate the buffer in non-consistent memory. The flag takes effect
only if the buffer is used for :ref:`memory mapping <mmap>` I/O and the
- queue reports the :ref:`V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS` capability.
+ queue reports the
+ :ref:`V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS <V4L2-BUF-CAP-SUPPORTS-CACHE-HINTS>`
+ capability.
.. c:type:: v4l2_memory
diff --git b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
index faf0df4f9bb6..1c0299424fbc 100644
--- b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
+++ a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
@@ -133,6 +133,7 @@ aborting or finishing any DMA in progress, an implicit
.. _V4L2-BUF-CAP-SUPPORTS-REQUESTS:
.. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS:
.. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF:
+.. _V4L2-BUF-CAP-SUPPORTS-CACHE-HINTS:
.. cssclass:: longtable
@@ -166,9 +167,10 @@ aborting or finishing any DMA in progress, an implicit
* - ``V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS``
- 0x00000040
- Set when the queue/buffer supports memory consistency and cache
- management hints. See :ref:`V4L2_FLAG_MEMORY_NON_CONSISTENT`,
- :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE` and
- :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN`.
+ management hints. See
+ :ref:`V4L2_FLAG_MEMORY_NON_CONSISTENT <V4L2-FLAG-MEMORY-NON-CONSISTENT>`,
+ :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE <V4L2-BUF-FLAG-NO-CACHE-INVALIDATE>` and
+ :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN <V4L2-BUF-FLAG-NO-CACHE-CLEAN>`.
Return Value
-----------------------------------------------
Please fold that in this patch.
Regards,
Hans
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> ---
> Documentation/media/uapi/v4l/buffer.rst | 29 +++++++++++++++++++
> .../media/uapi/v4l/vidioc-reqbufs.rst | 7 +++++
> .../media/common/videobuf2/videobuf2-v4l2.c | 2 ++
> include/uapi/linux/videodev2.h | 3 ++
> 4 files changed, 41 insertions(+)
>
> diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst
> index 3112300c2fa0..8084e3f2a58d 100644
> --- a/Documentation/media/uapi/v4l/buffer.rst
> +++ b/Documentation/media/uapi/v4l/buffer.rst
> @@ -681,6 +681,35 @@ Buffer Flags
>
> \normalsize
>
> +.. _memory-flags:
> +
> +Memory Consistency Flags
> +========================
> +
> +.. tabularcolumns:: |p{7.0cm}|p{2.2cm}|p{8.3cm}|
> +
> +.. cssclass:: longtable
> +
> +.. flat-table::
> + :header-rows: 0
> + :stub-columns: 0
> + :widths: 3 1 4
> +
> + * .. _`V4L2_FLAG_MEMORY_NON_CONSISTENT`:
> +
> + - ``V4L2_FLAG_MEMORY_NON_CONSISTENT``
> + - 0x00000001
> + - A buffer is allocated either in consistent (it will be automatically
> + coherent between the CPU and the bus) or non-consistent memory. The
> + latter can provide performance gains, for instance the CPU cache
> + sync/flush operations can be avoided if the buffer is accessed by the
> + corresponding device only and the CPU does not read/write to/from that
> + buffer. However, this requires extra care from the driver -- it must
> + guarantee memory consistency by issuing a cache flush/sync when
> + consistency is needed. If this flag is set V4L2 will attempt to
> + allocate the buffer in non-consistent memory. The flag takes effect
> + only if the buffer is used for :ref:`memory mapping <mmap>` I/O and the
> + queue reports the :ref:`V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS` capability.
>
> .. c:type:: v4l2_memory
>
> diff --git a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
> index d0c643db477a..21ecacc72487 100644
> --- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
> +++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
> @@ -156,6 +156,13 @@ aborting or finishing any DMA in progress, an implicit
> - Only valid for stateless decoders. If set, then userspace can set the
> ``V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF`` flag to hold off on returning the
> capture buffer until the OUTPUT timestamp changes.
> + * - ``V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS``
> + - 0x00000040
> + - Set when the queue/buffer supports memory consistency and cache
> + management hints. See :ref:`V4L2_FLAG_MEMORY_NON_CONSISTENT`,
> + :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE` and
> + :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN`.
> +
>
> Return Value
> ============
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 2a604bd7793a..c847bcea6e95 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -711,6 +711,8 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
> *caps |= V4L2_BUF_CAP_SUPPORTS_DMABUF;
> if (q->subsystem_flags & VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF)
> *caps |= V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF;
> + if (q->allow_cache_hints && (q->io_modes & VB2_MMAP))
> + *caps |= V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS;
> #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
> if (q->supports_requests)
> *caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 5f9357dcb060..e92c29864730 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -189,6 +189,8 @@ enum v4l2_memory {
> V4L2_MEMORY_DMABUF = 4,
> };
>
> +#define V4L2_FLAG_MEMORY_NON_CONSISTENT (1 << 0)
> +
> /* see also http://vektor.theorem.ca/graphics/ycbcr/ */
> enum v4l2_colorspace {
> /*
> @@ -946,6 +948,7 @@ struct v4l2_requestbuffers {
> #define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3)
> #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4)
> #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
> +#define V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS (1 << 6)
>
> /**
> * struct v4l2_plane - plane info for multi-planar buffers
>
next prev parent reply other threads:[~2020-03-06 13:58 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 4:12 [PATCHv4 00/11] Implement V4L2_BUF_FLAG_NO_CACHE_* flags Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 01/11] videobuf2: add cache management members Sergey Senozhatsky
2020-03-06 13:57 ` Hans Verkuil
2020-03-07 5:22 ` Sergey Senozhatsky
2020-03-07 9:46 ` Sergey Senozhatsky
2020-03-07 10:10 ` Hans Verkuil
2020-03-07 11:28 ` Sergey Senozhatsky
2020-03-07 11:47 ` Hans Verkuil
2020-03-09 3:27 ` Sergey Senozhatsky
2020-03-09 3:44 ` Sergey Senozhatsky
2020-03-09 7:21 ` Hans Verkuil
2020-03-09 7:25 ` Sergey Senozhatsky
2020-03-09 7:28 ` Hans Verkuil
2020-03-09 7:39 ` Sergey Senozhatsky
2020-03-09 8:58 ` Tomasz Figa
2020-03-09 9:08 ` Sergey Senozhatsky
2020-03-09 9:17 ` Tomasz Figa
2020-03-09 9:29 ` Sergey Senozhatsky
2020-03-09 4:03 ` Sergey Senozhatsky
2020-03-09 7:17 ` Hans Verkuil
2020-03-02 4:12 ` [PATCHv4 02/11] videobuf2: handle V4L2 buffer cache flags Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 03/11] videobuf2: add V4L2_FLAG_MEMORY_NON_CONSISTENT flag Sergey Senozhatsky
2020-03-06 13:58 ` Hans Verkuil [this message]
2020-03-07 8:09 ` Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 04/11] videobuf2: add queue memory consistency parameter Sergey Senozhatsky
2020-03-06 14:04 ` Hans Verkuil
2020-03-07 7:50 ` Sergey Senozhatsky
2020-03-07 10:03 ` Hans Verkuil
2020-03-20 13:46 ` Dafna Hirschfeld
2020-03-24 2:39 ` Sergey Senozhatsky
2020-03-24 10:17 ` Ezequiel Garcia
2020-03-25 2:32 ` Sergey Senozhatsky
2020-03-27 11:27 ` Tomasz Figa
2020-03-02 4:12 ` [PATCHv4 05/11] videobuf2: handle V4L2_FLAG_MEMORY_NON_CONSISTENT flag Sergey Senozhatsky
2020-03-06 15:30 ` Hans Verkuil
2020-03-07 7:51 ` Sergey Senozhatsky
2020-03-07 9:38 ` Sergey Senozhatsky
2020-03-07 10:05 ` Hans Verkuil
2020-03-02 4:12 ` [PATCHv4 06/11] videobuf2: factor out planes prepare/finish functions Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 07/11] videobuf2: do not sync caches when we are allowed not to Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 08/11] videobuf2: check ->synced flag in prepare() and finish() Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 09/11] videobuf2: add begin/end cpu_access callbacks to dma-contig Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 10/11] videobuf2: add begin/end cpu_access callbacks to dma-sg Sergey Senozhatsky
2020-03-06 14:04 ` Hans Verkuil
2020-03-07 5:26 ` Sergey Senozhatsky
2020-03-07 9:32 ` Hans Verkuil
2020-03-07 9:39 ` Sergey Senozhatsky
2020-03-02 4:12 ` [PATCHv4 11/11] videobuf2: don't test db_attach in dma-contig prepare and finish Sergey Senozhatsky
2020-03-06 14:18 ` [PATCHv4 00/11] Implement V4L2_BUF_FLAG_NO_CACHE_* flags Hans Verkuil
2020-03-07 8:08 ` 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=40b1cc23-5e28-837b-49d5-e32d9dd3edee@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=hans.verkuil@cisco.com \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=posciak@chromium.org \
--cc=sakari.ailus@iki.fi \
--cc=senozhatsky@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 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).