From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15164C433DB for ; Mon, 22 Mar 2021 07:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2C0461973 for ; Mon, 22 Mar 2021 07:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhCVHCi (ORCPT ); Mon, 22 Mar 2021 03:02:38 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:51007 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbhCVHCI (ORCPT ); Mon, 22 Mar 2021 03:02:08 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id OEZdldH3UGEYcOEZilWFK3; Mon, 22 Mar 2021 08:02:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1616396526; bh=xX6EJ7/zMangVi2S1iQkbFpQhMJe8Ebhn1H5+8CxHmk=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=VfLDM5oLnpr6svGfSLKK/TJCyIB3yr9pVXfWfe4kqsvX2cEYBZr+tGGDU/PTRCBPs wmJ+a41wrooxwbCAF8Vys0Ci5fNmJSpOypCXQIwlZWNi4CJx3tgEGtTDnsC61cfSUt p2JdRYZ68v0hcZT8t78PJyaDUOl8XeyU3kug6gOOn09j7gA6+Qn5uo3f91U3QgPY0Z F8O/vfBVwSFS2JrOsSNOLt2mbNDXT++4NxqK2F8SH6oftnX1nBPlSC1AXTEkUvL9zw 4/8WEKqc/JNQHKClLJg2FiV6rAKfmQyHWpBLakVmwZniQPz3C79dbRK7+UISghdzwA yGMrFylOhytPQ== Subject: Re: [PATCH 5/8] videobuf2: add V4L2_FLAG_MEMORY_NON_COHERENT flag To: Sergey Senozhatsky , Tomasz Figa Cc: Christoph Hellwig , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210302004624.31294-1-senozhatsky@chromium.org> <20210302004624.31294-6-senozhatsky@chromium.org> From: Hans Verkuil Message-ID: <17db1ef3-ff90-1d4e-9b31-52efd296d224@xs4all.nl> Date: Mon, 22 Mar 2021 08:02:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210302004624.31294-6-senozhatsky@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfMFUNiHqJYzV1+oXvtvClq+OtzvnPVCRsNwSNP7fTXaGBgvNzKB9QAI3Up+mtdN+J/Ex0INsoOJFDofPN3sCu58REKyhnEy3VG9bXtbmc5joqXhAUKEm 8ArVDZBK6SbXtawEPoGo7B6FuUETHNMhtsCqH83ydVYMlNE4BeZ+NSsTiCaYWAh69+LdGSgst7hY/9/7qvuElVckGDhTN7Vx29mwye5CmUybwCjkQdbShjKI AYf+mTyauS83xLb/ecyu5qNovVYqzs8iVvxr2k6yJ4yS2zs0Ty268A7tLcP4Xv0W6j2EN01LNgqCuSxvKbbQ04miPe92/lOM3I0fmfZFWzAtIdy6S4m/0nOE dQ+qvB6b Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2021 01:46, Sergey Senozhatsky wrote: > By setting or clearing V4L2_FLAG_MEMORY_NON_COHERENT flag > user-space should be able to hint vb2 that either a non-coherent > (if supported) or coherent memory should be used for the buffer > allocation. > > The patch set also adds a corresponding capability flag: > fill_buf_caps() reports V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS > when queue supports user-space cache management hints. Hmm, this paragraph is probably outdated (copy and paste?) since this capability already exists. > > Signed-off-by: Sergey Senozhatsky > --- > .../userspace-api/media/v4l/buffer.rst | 40 ++++++++++++++++++- > .../media/v4l/vidioc-reqbufs.rst | 5 ++- > include/uapi/linux/videodev2.h | 2 + > 3 files changed, 43 insertions(+), 4 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/buffer.rst b/Documentation/userspace-api/media/v4l/buffer.rst > index 1b0fdc160533..a39852d6174f 100644 > --- a/Documentation/userspace-api/media/v4l/buffer.rst > +++ b/Documentation/userspace-api/media/v4l/buffer.rst > @@ -676,8 +676,6 @@ Buffer Flags > > \normalsize > > -.. _memory-flags: > - > enum v4l2_memory > ================ > > @@ -701,6 +699,44 @@ enum v4l2_memory > - 4 > - The buffer is used for :ref:`DMA shared buffer ` I/O. > > +.. _memory-flags: > + > +Memory Consistency Flags > +------------------------ > + > +.. raw:: latex > + > + \small > + > +.. tabularcolumns:: |p{7.0cm}|p{2.1cm}|p{8.4cm}| > + > +.. cssclass:: longtable > + > +.. flat-table:: > + :header-rows: 0 > + :stub-columns: 0 > + :widths: 3 1 4 > + > + * .. _`V4L2-FLAG-MEMORY-NON-COHERENT`: > + > + - ``V4L2_FLAG_MEMORY_NON_COHERENT`` Rename this to V4L2_MEMORY_FLAG_NON_COHERENT: this is consistent with V4L2_FMT_FLAG_ and V4L2_BUF_FLAG_. > + - 0x00000001 > + - A buffer is allocated either in coherent (it will be automatically > + coherent between the CPU and the bus) or non-coherent 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-coherent memory. The flag takes effect > + only if the buffer is used for :ref:`memory mapping ` I/O and the > + queue reports the :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS > + ` capability. > + > +.. raw:: latex > + > + \normalsize > > Timecodes > ========= > diff --git a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst > index c1c88e00b106..950e7ec1aac5 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst > @@ -154,8 +154,9 @@ aborting or finishing any DMA in progress, an implicit > - This capability is set by the driver to indicate that the queue supports > cache and memory management hints. However, it's only valid when the > queue is used for :ref:`memory mapping ` streaming I/O. See > - :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE ` and > - :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN `. > + :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE `, > + :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN ` and > + :ref:`V4L2_FLAG_MEMORY_NON_COHERENT `. > > Return Value > ============ > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 79dbde3bcf8d..b1d4171fe50b 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -954,6 +954,8 @@ struct v4l2_requestbuffers { > __u32 reserved[1]; > }; > > +#define V4L2_FLAG_MEMORY_NON_COHERENT (1 << 0) > + > /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ > #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) > #define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1) > Regards, Hans