linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv17 02/34] uapi/linux/media.h: add request API
Date: Tue, 14 Aug 2018 09:34:36 -0300	[thread overview]
Message-ID: <20180814093436.63836600@coco.lan> (raw)
In-Reply-To: <176579c0-a430-a25c-49f7-578c6c544025@xs4all.nl>

Em Tue, 14 Aug 2018 11:57:48 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 14/08/18 10:46, Mauro Carvalho Chehab wrote:
> > Em Fri, 10 Aug 2018 09:21:59 +0200
> > Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> >   
> >> On 08/09/2018 07:53 PM, Mauro Carvalho Chehab wrote:  
> >>> Em Sat,  4 Aug 2018 14:44:54 +0200
> >>> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> >>>     
> >>>> From: Hans Verkuil <hans.verkuil@cisco.com>
> >>>>
> >>>> Define the public request API.
> >>>>
> >>>> This adds the new MEDIA_IOC_REQUEST_ALLOC ioctl to allocate a request
> >>>> and two ioctls that operate on a request in order to queue the
> >>>> contents of the request to the driver and to re-initialize the
> >>>> request.
> >>>>
> >>>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> >>>> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> >>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>> ---
> >>>>  include/uapi/linux/media.h | 12 ++++++++++++
> >>>>  1 file changed, 12 insertions(+)
> >>>>
> >>>> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> >>>> index 36f76e777ef9..cf77f00a0f2d 100644
> >>>> --- a/include/uapi/linux/media.h
> >>>> +++ b/include/uapi/linux/media.h
> >>>> @@ -364,11 +364,23 @@ struct media_v2_topology {
> >>>>  
> >>>>  /* ioctls */
> >>>>  
> >>>> +struct __attribute__ ((packed)) media_request_alloc {
> >>>> +	__s32 fd;
> >>>> +};
> >>>> +
> >>>>  #define MEDIA_IOC_DEVICE_INFO	_IOWR('|', 0x00, struct media_device_info)
> >>>>  #define MEDIA_IOC_ENUM_ENTITIES	_IOWR('|', 0x01, struct media_entity_desc)
> >>>>  #define MEDIA_IOC_ENUM_LINKS	_IOWR('|', 0x02, struct media_links_enum)
> >>>>  #define MEDIA_IOC_SETUP_LINK	_IOWR('|', 0x03, struct media_link_desc)
> >>>>  #define MEDIA_IOC_G_TOPOLOGY	_IOWR('|', 0x04, struct media_v2_topology)
> >>>> +#define MEDIA_IOC_REQUEST_ALLOC	_IOWR('|', 0x05, struct media_request_alloc)    
> > 
> > The definition here is wrong... the fd field is not R/W, it is just R, as no
> > fields inside this struct should be filled by userspace.
> > The right declaration for it would be:
> > 
> > 	#define MEDIA_IOC_REQUEST_ALLOC	_IOR('|', 0x05, struct media_request_alloc)
> > 
> > I do have a strong opinion here: ioctls that just return stuff should use _IOR.  
> 
> You are right, this should be _IOR.
> 
> >   
> >>>
> >>> Same comment as in patch 1: keep it simpler: just pass a s32 * as the
> >>> argument for this ioctl.    
> >>
> >> Same comment as in patch 1: I have no strong opinion, but I want the input from others
> >> as well.  
> > 
> > I'm transcribing a comment you wrote on patch 01/34 here, for the sake of
> > keeping everything on a single thread:
> >   
> >> The first version just had a s32 argument, not a struct. The main reason for
> >> going back to a struct was indeed to make it easier to add new fields in the
> >> future. I don't foresee any, but then, you never do.  
> > 
> > First of all, if we declare it as it should be, e. g.: 
> > 
> > #define MEDIA_IOC_REQUEST_ALLOC	_IOR('|', 0x05, int) 
> > 
> > If later find the need for some struct:
> > 
> > 	struct media_request_alloc {
> > 		__s32 fd;
> > 		__s32 foo;
> > 	} __packed;
> > 
> > Assuming that "foo" is a write argument, we'll then have:
> > 
> > 	#define MEDIA_IOC_REQUEST_ALLOC		_IOR('|', 0x05, int) 
> > 	#define MEDIA_IOC_REQUEST_ALLOC_V2	_IOWR('|', 0x05, struct media_request_alloc)  
> > 
> > The size of the ioctl will also be different, and also the direction.
> > So, the magic number will be different.
> > 
> > The Kernel can easily handle it on both ways, and, as 
> > MEDIA_IOC_REQUEST_ALLOC has only an integer output parameter, 
> > there's no need for compat32 or to keep any old struct.
> > The MEDIA_IOC_REQUEST_ALLOC code handler will still be very simple,
> > and backward compatible comes for free.
> > 
> > If, on the other hand, we declare it as:
> > 	#define MEDIA_IOC_REQUEST_ALLOC	_IOR('|', 0x05, struct media_request_alloc_old)
> > 
> > And then we change it to:
> > 	#define MEDIA_IOC_REQUEST_ALLOC	_IORW('|', 0x05, struct media_request_alloc_new)
> > 
> > Keeping backward compatible will be painful, and will require efforts for
> > no gain.  
> 
> In the kernel it doesn't matter much, I agree. But applications that have to
> be able to handle both old and new ioctls will have to switch between either
> an fd or a struct. Whereas if we use a struct from the beginning, then the
> only difference between the old and new ioctls are whether or not additional
> fields beyond the first fd field are set.

Well, if we change the API by adding other fields, applications will need
both behaviors anyway, if they want to support multiple kernel versions
and need the newer version behavior, if available.

> As mentioned before, I don't have very strong feelings about this, but I
> do want input from others on this before making this change.

Feel free to wait for other inputs.

> Frankly, I think it is unlikely that we will need more fields beyond just
> the fd, but I've been wrong about such things before...

In this specific ioctl, I don't expect other fields either. Even on
brain storm with crazy ideas, I can't find any other parameter that
might make any sense here. I'm almost certain that, if we end
by needing some other things for this ioctl to work, the userspace
logic will very likely require a non-trivial logic, up to a point
that implementing it with a different name or have something like
"MEDIA_IOC_PREP_REQUEST_ALLOC" would likely be better than re-using
the same ioctl name and changing its behavior.

Thanks,
Mauro

  reply	other threads:[~2018-08-14 15:21 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 12:44 [PATCHv17 00/34] Request API Hans Verkuil
2018-08-04 12:44 ` [PATCHv17 01/34] Documentation: v4l: document request API Hans Verkuil
2018-08-06 23:44   ` Pavel Machek
2018-08-09 17:43   ` Mauro Carvalho Chehab
2018-08-10  7:20     ` Hans Verkuil
2018-08-14  8:21       ` Mauro Carvalho Chehab
2018-08-14  7:57     ` Hans Verkuil
2018-08-14  8:48       ` Mauro Carvalho Chehab
2018-08-14  9:51         ` Hans Verkuil
2018-08-14 12:18           ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 02/34] uapi/linux/media.h: add " Hans Verkuil
2018-08-09 17:53   ` Mauro Carvalho Chehab
2018-08-10  7:21     ` Hans Verkuil
2018-08-14  8:46       ` Mauro Carvalho Chehab
2018-08-14  9:57         ` Hans Verkuil
2018-08-14 12:34           ` Mauro Carvalho Chehab [this message]
2018-08-04 12:44 ` [PATCHv17 03/34] media-request: implement media requests Hans Verkuil
2018-08-09 18:37   ` Mauro Carvalho Chehab
2018-08-10  7:28     ` Hans Verkuil
2018-08-14 13:33   ` Hans Verkuil
2018-08-04 12:44 ` [PATCHv17 04/34] media: doc: Add media-request.h header to documentation build Hans Verkuil
2018-08-09 18:43   ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 05/34] media-request: add media_request_get_by_fd Hans Verkuil
2018-08-09 19:55   ` Mauro Carvalho Chehab
2018-08-10  7:32     ` Hans Verkuil
2018-08-14  9:00       ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 06/34] media-request: add media_request_object_find Hans Verkuil
2018-08-09 19:56   ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 07/34] v4l2-device.h: add v4l2_device_supports_requests() helper Hans Verkuil
2018-08-09 19:57   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 08/34] v4l2-dev: lock req_queue_mutex Hans Verkuil
2018-08-09 20:03   ` Mauro Carvalho Chehab
2018-08-10  7:39     ` Hans Verkuil
2018-08-14  8:09       ` Mauro Carvalho Chehab
2018-08-14 12:00     ` Hans Verkuil
2018-08-14 12:39       ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 09/34] videodev2.h: add request_fd field to v4l2_ext_controls Hans Verkuil
2018-08-09 20:04   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 10/34] v4l2-ctrls: v4l2_ctrl_add_handler: add from_other_dev Hans Verkuil
2018-08-09 20:10   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 11/34] v4l2-ctrls: prepare internal structs for request API Hans Verkuil
2018-08-09 20:16   ` Mauro Carvalho Chehab
2018-08-10  7:41     ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 12/34] v4l2-ctrls: alloc memory for p_req Hans Verkuil
2018-08-09 20:19   ` Mauro Carvalho Chehab
2018-08-10  7:41     ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 13/34] v4l2-ctrls: use ref in helper instead of ctrl Hans Verkuil
2018-08-09 20:22   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 14/34] v4l2-ctrls: add core request support Hans Verkuil
2018-08-13 10:55   ` Mauro Carvalho Chehab
2018-08-14  8:34     ` Hans Verkuil
2018-08-14  8:59       ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 15/34] v4l2-ctrls: support g/s_ext_ctrls for requests Hans Verkuil
2018-08-13 11:05   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 16/34] v4l2-ctrls: add v4l2_ctrl_request_hdl_find/put/ctrl_find functions Hans Verkuil
2018-08-13 11:07   ` Mauro Carvalho Chehab
2018-08-14  8:45     ` Hans Verkuil
2018-08-14  8:55       ` Mauro Carvalho Chehab
2018-08-14 10:50         ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 17/34] vb2: store userspace data in vb2_v4l2_buffer Hans Verkuil
2018-08-13 11:15   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 18/34] davinci_vpfe: remove bogus vb2->state check Hans Verkuil
2018-08-13 11:17   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 19/34] vb2: drop VB2_BUF_STATE_PREPARED, use bool prepared/synced instead Hans Verkuil
2018-08-13 11:30   ` Mauro Carvalho Chehab
2018-08-14  8:58     ` Hans Verkuil
2018-08-14  9:06       ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 20/34] videodev2.h: Add request_fd field to v4l2_buffer Hans Verkuil
2018-08-13 11:41   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 21/34] vb2: add init_buffer buffer op Hans Verkuil
2018-08-13 11:56   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 22/34] videobuf2-core: embed media_request_object Hans Verkuil
2018-08-13 11:58   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 23/34] videobuf2-core: integrate with media requests Hans Verkuil
2018-08-13 12:09   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 24/34] videobuf2-v4l2: " Hans Verkuil
2018-08-13 14:30   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 25/34] videobuf2-core: add request helper functions Hans Verkuil
2018-08-13 14:50   ` Mauro Carvalho Chehab
2018-08-14  7:22     ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 26/34] videobuf2-v4l2: add vb2_request_queue/validate helpers Hans Verkuil
2018-08-13 14:53   ` Mauro Carvalho Chehab
2018-08-14  7:19     ` Hans Verkuil
2018-08-14  7:49       ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 27/34] videobuf2-core: add uses_requests/qbuf flags Hans Verkuil
2018-08-13 14:55   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 28/34] videobuf2-v4l2: refuse qbuf if queue uses requests or vv Hans Verkuil
2018-08-13 14:56   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 29/34] v4l2-mem2mem: add vb2_m2m_request_queue Hans Verkuil
2018-08-13 15:02   ` Mauro Carvalho Chehab
2018-08-14  7:26     ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 30/34] vim2m: use workqueue Hans Verkuil
2018-08-13 15:05   ` Mauro Carvalho Chehab
2018-08-14  7:28     ` Hans Verkuil
2018-08-14  7:41       ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 31/34] vim2m: support requests Hans Verkuil
2018-08-06 21:02   ` Ezequiel Garcia
2018-08-13 15:08   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 32/34] vivid: add mc Hans Verkuil
2018-08-13 15:09   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 33/34] vivid: add request support Hans Verkuil
2018-08-13 15:11   ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 34/34] RFC: media-requests: add debugfs node Hans Verkuil
2018-08-13 15:15   ` Mauro Carvalho Chehab
2018-08-14  7:33     ` Hans Verkuil
2018-08-14  7:43       ` Mauro Carvalho Chehab

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=20180814093436.63836600@coco.lan \
    --to=mchehab+samsung@kernel.org \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.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 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).