All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Dafna Hirschfeld <dafna3@gmail.com>
Cc: linux-media@vger.kernel.org, helen.koike@collabora.com,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: Re: [PATCH v5 02/23] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS
Date: Wed, 20 Mar 2019 11:39:47 +0100	[thread overview]
Message-ID: <ca97c48b-3b7f-3c97-ec19-54469604fe79@xs4all.nl> (raw)
In-Reply-To: <20190320071112.4ed71c54@coco.lan>

On 3/20/19 11:11 AM, Mauro Carvalho Chehab wrote:
> Em Wed,  6 Mar 2019 13:13:22 -0800
> Dafna Hirschfeld <dafna3@gmail.com> escreveu:
> 
>> From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>
>> Add capability to indicate that requests are required instead of
>> merely supported.
> 
> Not sure if I liked this patch, and for sure it lacks a lot of documentation:
> 
> First of all, the patch description doesn't help. For example, it doesn't
> explain or mention any use case example that would require (instead of
> merely support) a request.

Stateless codecs require the use of requests (i.e. they can't function without
this).

However, right now every driver has to check for this and return an error when
an attempt is made to stream without requests.

And userspace has no way of knowing whether requests are required by the driver
as opposed to being optional.

That's what this attempts to do: show to userspace that requests are required,
and add a vb2 flag that will force the core to check this so drivers do not need
to test for it.

Currently the only drivers that would need this are cedrus and vicodec.

> 
>>
>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>> ---
>>  Documentation/media/uapi/v4l/vidioc-reqbufs.rst | 4 ++++
>>  include/uapi/linux/videodev2.h                  | 1 +
>>  2 files changed, 5 insertions(+)
>>
>> diff --git a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
>> index d7faef10e39b..d42a3d9a7db3 100644
>> --- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
>> +++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
>> @@ -125,6 +125,7 @@ aborting or finishing any DMA in progress, an implicit
>>  .. _V4L2-BUF-CAP-SUPPORTS-DMABUF:
>>  .. _V4L2-BUF-CAP-SUPPORTS-REQUESTS:
>>  .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS:
>> +.. _V4L2-BUF-CAP-REQUIRES-REQUESTS:
>>  
>>  .. cssclass:: longtable
>>  
>> @@ -150,6 +151,9 @@ aborting or finishing any DMA in progress, an implicit
>>        - The kernel allows calling :ref:`VIDIOC_REQBUFS` while buffers are still
>>          mapped or exported via DMABUF. These orphaned buffers will be freed
>>          when they are unmapped or when the exported DMABUF fds are closed.
>> +    * - ``V4L2_BUF_CAP_REQUIRES_REQUESTS``
>> +      - 0x00000020
>> +      - This buffer type requires the use of :ref:`requests <media-request-api>`.
> 
> And the documentation here is really poor, as it doesn't explain what's
> the API and drivers expected behavior with regards to this flag.
> 
> I mean, if, on a new driver, requests are mandatory, what happens if a
> non-request-API aware application tries to use it? 

An error will be returned. And that error needs to be documented, I agree.

All this does is shift the check from the driver to the v4l2 core. It doesn't
change anything for userspace, except that with this capability flag userspace
can detect beforehand that requests are required.

> 
> Another thing that concerns me a lot is that people might want to add it
> to existing drivers. Well, if an application was written before the
> addition of this driver, and request API become mandatory, such app
> will stop working, if it doesn't use request API.
> At very least, it should be mentioned somewhere that existing drivers
> should never set this flag, as this would break it for existing
> userspace apps.
> 
> Still, I would prefer to not have to add something like that.

The only affected driver is the staging cedrus driver. And that will
actually crash if you try to use it without requests.

If you look at patch 3 you'll see that it just sets the flag and doesn't
remove any code that was supposed to check for use-without-requests.
That's because there never was a check and the driver would just crash.

So we're safe here.

I believe patches 1-3 make sense, but I also agree that the documentation
and commit logs can be improved.

I can either respin with updated patches 1-3, or, if you still have concerns,
drop 1-3 and repost the remainder of the series. But then I'll need to add
checks against the use of the stateless vicodec decoder without requests in
patch 21/23.

But this really doesn't belong in a driver. These checks should be done in the
vb2 core.

Regards,

	Hans

> 
> 
>>  
>>  Return Value
>>  ============
>> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
>> index 1db220da3bcc..97e6a6a968ba 100644
>> --- a/include/uapi/linux/videodev2.h
>> +++ b/include/uapi/linux/videodev2.h
>> @@ -895,6 +895,7 @@ struct v4l2_requestbuffers {
>>  #define V4L2_BUF_CAP_SUPPORTS_DMABUF	(1 << 2)
>>  #define V4L2_BUF_CAP_SUPPORTS_REQUESTS	(1 << 3)
>>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4)
>> +#define V4L2_BUF_CAP_REQUIRES_REQUESTS	(1 << 5)
>>  
>>  /**
>>   * struct v4l2_plane - plane info for multi-planar buffers
> 
> 
> 
> Thanks,
> Mauro
> 


  reply	other threads:[~2019-03-20 10:39 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 21:13 [PATCH v5 00/23] support for stateless decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 01/23] vb2: add requires_requests bit for stateless codecs Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:21   ` Mauro Carvalho Chehab
2019-03-20 10:45     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 02/23] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:11   ` Mauro Carvalho Chehab
2019-03-20 10:39     ` Hans Verkuil [this message]
2019-03-20 11:42       ` Mauro Carvalho Chehab
2019-03-20 12:20         ` Hans Verkuil
2019-03-20 12:37           ` Mauro Carvalho Chehab
2019-03-20 12:41             ` Hans Verkuil
2019-03-20 13:09               ` Mauro Carvalho Chehab
2019-03-06 21:13 ` [PATCH v5 03/23] cedrus: set requires_requests Dafna Hirschfeld
2019-03-12 15:32   ` Paul Kocialkowski
2019-03-13 14:59     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 04/23] media: vicodec: selection api should only check single buffer types Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 05/23] media: vicodec: upon release, call m2m release before freeing ctrl handler Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 06/23] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure Dafna Hirschfeld
2019-03-12 15:40   ` Paul Kocialkowski
2019-03-06 21:13 ` [PATCH v5 07/23] media: vicodec: change variable name for the return value of v4l2_fwht_encode Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 08/23] media: vicodec: bugfix - call v4l2_m2m_buf_copy_metadata also if decoding fails Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 09/23] media: vicodec: bugfix: free compressed_frame upon device release Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 10/23] media: vicodec: Move raw frame preparation code to a function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 11/23] media: vicodec: add field 'buf' to fwht_raw_frame Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 12/23] media: vicodec: keep the ref frame according to the format in decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 13/23] media: vicodec: Validate version dependent header values in a separate function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 14/23] media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 15/23] media: vicodec: Handle the case that the reference buffer is NULL Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 16/23] media: vicodec: add struct for encoder/decoder instance Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 17/23] media: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 18/23] media: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 19/23] media: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 20/23] media: vicodec: Introducing stateless fwht defs and structs Dafna Hirschfeld
2019-03-13 14:42   ` [PATCH v5 24/23] v4l2-ioctl.c: add V4L2_PIX_FMT_FWHT_STATELESS to v4l_fill_fmtdesc Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 21/23] media: vicodec: Register another node for stateless decoder Dafna Hirschfeld
2019-03-13 14:38   ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 22/23] media: vicodec: Add support " Dafna Hirschfeld
2019-03-13 14:37   ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 23/23] media: vicodec: set pixelformat to V4L2_PIX_FMT_FWHT_STATELESS " Dafna Hirschfeld

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=ca97c48b-3b7f-3c97-ec19-54469604fe79@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=dafna3@gmail.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.