Re: [PATCH] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT flag

2020-09-11 Thread Sergey Senozhatsky
On (20/09/11 12:37), Hans Verkuil wrote:
> I'll take care of that. I also discovered that one call to vb2_core_reqbufs()
> wasn't updated (in drivers/media/dvb-core/dvb_vb2.c). I've fixed that as well.

Oh.. how did I miss drivers/media/dvb-core/dvb_vb2.c?
Should have grep-ed more.

-ss


Re: [PATCH] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT flag

2020-09-11 Thread Hans Verkuil
On 11/09/2020 12:09, Christoph Hellwig wrote:
> Btw, the subject should probably read something like:
> 
> media/v4l2: remove the V4L2_FLAG_MEMORY_NON_CONSISTENT flag
> 
> I messed up the spelling because I copied it from the documentation.
> 


I'll take care of that. I also discovered that one call to vb2_core_reqbufs()
wasn't updated (in drivers/media/dvb-core/dvb_vb2.c). I've fixed that as well.

All my regression tests passed, so I plan to post a PR for 5.9 reverting this
feature soon.

Many thanks to everyone for 1) discovering this problem and 2) creating a patch
to revert this.

Regards,

Hans


Re: [PATCH] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT flag

2020-09-11 Thread Christoph Hellwig
Btw, the subject should probably read something like:

media/v4l2: remove the V4L2_FLAG_MEMORY_NON_CONSISTENT flag

I messed up the spelling because I copied it from the documentation.


[PATCH] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT flag

2020-09-10 Thread Sergey Senozhatsky
The patch partially reverts some of the UAPI bits of the buffer
cache management hints. Namely, the queue consistency (memory
coherency) user-space hint because, as it turned out, the kernel
implementation of this feature was misusing DMA_ATTR_NON_CONSISTENT.

The patch revers both kernel and user space parts: removes the
DMA consistency attr functions, rollbacks changes to v4l2_requestbuffers,
v4l2_create_buffers structures and corresponding UAPI functions
(plus compat32 layer) and cleanups the documentation.

Signed-off-by: Christoph Hellwig 
Signed-off-by: Sergey Senozhatsky 
---
 .../userspace-api/media/v4l/buffer.rst| 17 ---
 .../media/v4l/vidioc-create-bufs.rst  |  6 +--
 .../media/v4l/vidioc-reqbufs.rst  | 12 +
 .../media/common/videobuf2/videobuf2-core.c   | 46 +++
 .../common/videobuf2/videobuf2-dma-contig.c   | 19 
 .../media/common/videobuf2/videobuf2-dma-sg.c |  3 +-
 .../media/common/videobuf2/videobuf2-v4l2.c   | 18 +---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 10 +---
 drivers/media/v4l2-core/v4l2-ioctl.c  |  5 +-
 include/media/videobuf2-core.h|  7 +--
 include/uapi/linux/videodev2.h| 13 +-
 11 files changed, 22 insertions(+), 134 deletions(-)

diff --git a/Documentation/userspace-api/media/v4l/buffer.rst 
b/Documentation/userspace-api/media/v4l/buffer.rst
index 177ed8b6ce62..4f95496adc5b 100644
--- a/Documentation/userspace-api/media/v4l/buffer.rst
+++ b/Documentation/userspace-api/media/v4l/buffer.rst
@@ -694,23 +694,6 @@ Memory Consistency Flags
 :stub-columns: 0
 :widths:   3 1 4
 
-* .. _`V4L2-FLAG-MEMORY-NON-CONSISTENT`:
-
-  - ``V4L2_FLAG_MEMORY_NON_CONSISTENT``
-  - 0x0001
-  - 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 ` I/O and the
-   queue reports the :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS
-   ` capability.
-
 .. c:type:: v4l2_memory
 
 enum v4l2_memory
diff --git a/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst 
b/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst
index c050dffa4237..d999028f47df 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst
@@ -113,13 +113,9 @@ than the number requested.
If you want to just query the capabilities without making any
other changes, then set ``count`` to 0, ``memory`` to
``V4L2_MEMORY_MMAP`` and ``format.type`` to the buffer type.
-* - __u32
-  - ``flags``
-  - Specifies additional buffer management attributes.
-   See :ref:`memory-flags`.
 
 * - __u32
-  - ``reserved``\ [6]
+  - ``reserved``\ [7]
   - A place holder for future extensions. Drivers and applications
must set the array to zero.
 
diff --git a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst 
b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst
index 47e433161690..afc35cd7b614 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst
@@ -105,17 +105,10 @@ aborting or finishing any DMA in progress, an implicit
``V4L2_MEMORY_MMAP`` and ``type`` set to the buffer type. This will
free any previously allocated buffers, so this is typically something
that will be done at the start of the application.
-* - union {
-  - (anonymous)
-* - __u32
-  - ``flags``
-  - Specifies additional buffer management attributes.
-   See :ref:`memory-flags`.
 * - __u32
   - ``reserved``\ [1]
-  - Kept for backwards compatibility. Use ``flags`` instead.
-* - }
-  -
+  - A place holder for future extensions. Drivers and applications
+   must set the array to zero.
 
 .. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
 
@@ -162,7 +155,6 @@ 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_FLAG_MEMORY_NON_CONSISTENT 
`,
 :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 
` and