From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@iki.fi>,
Tomasz Figa <tfiga@chromium.org>,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Nicolas Dufresne <nicolas@ndufresne.ca>
Subject: Re: [RFC] Request API questions
Date: Thu, 16 Aug 2018 08:15:22 -0300 [thread overview]
Message-ID: <20180816081522.76f71891@coco.lan> (raw)
In-Reply-To: <93ca4ddc-e803-ee5a-f345-7b72ded1f757@xs4all.nl>
Em Thu, 16 Aug 2018 12:25:25 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> Laurent raised a few API issues/questions in his review of the documentation.
>
> I've consolidated those in this RFC. I would like to know what others think
> and if I should make changes.
>
> 1) Should you be allowed to set controls directly if they are also used in
> requests? Right now this is allowed, although we warn in the spec that
> this can lead to undefined behavior.
>
> In my experience being able to do this is very useful while testing,
> and restricting this is not all that easy to implement. I also think it is
> not our job. It is not as if something will break when you do this.
>
> If there really is a good reason why you can't mix this for a specific
> control, then the driver can check this and return -EBUSY.
IMHO, there's not much sense on preventing it. Just having a warning
at the spec is enough.
+.. caution::
+
+ Setting the same control through a request and also directly can lead to
+ undefined behavior!
It is already warned with a caution. Anyone that decides to ignore a
warning like that will deserve his faith if things stop work.
>
> 2) If request_fd in QBUF or the control ioctls is not a request fd, then we
> now return ENOENT. Laurent suggests using EBADR ('Invalid request descriptor')
> instead. This seems like a good idea to me. Should I change this?
I don't have a strong opinion, but EBADR value seems to be arch-dependent:
arch/alpha/include/uapi/asm/errno.h:#define EBADR 98 /* Invalid request descriptor */
arch/mips/include/uapi/asm/errno.h:#define EBADR 51 /* Invalid request descriptor */
arch/parisc/include/uapi/asm/errno.h:#define EBADR 161 /* Invalid request descriptor */
arch/sparc/include/uapi/asm/errno.h:#define EBADR 103 /* Invalid request descriptor */
include/uapi/asm-generic/errno.h:#define EBADR 53 /* Invalid request descriptor */
Also, just because its name says "invalid request", it doesn't mean that it
is the right error code. In this specific case, we're talking about a file
descriptor. Invalid file descriptors is something that the FS subsystem
has already a defined set of return codes. We should stick with whatever
FS uses when a file descriptor is invalid.
Where the VFS code returns EBADR? Does it make sense for our use cases?
>
> 3) Calling VIDIOC_G_EXT_CTRLS for a request that has not been queued yet will
> return either the value of the control you set earlier in the request, or
> the current HW control value if it was never set in the request.
>
> I believe it makes sense to return what was set in the request previously
> (if you set it, you should be able to get it), but it is an idea to return
> ENOENT when calling this for controls that are NOT in the request.
>
> I'm inclined to implement that. Opinions?
Return the request "cached" value, IMO, doesn't make sense. If the
application needs such cache, it can implement itself.
Return an error code if the request has not yet completed makes
sense. Not sure what would be the best error code here... if the
request is queued already (but not processed), EBUSY seems to be the
better choice, but, if it was not queued yet, I'm not sure. I guess
ENOENT would work.
>
> 4) When queueing a buffer to a request with VIDIOC_QBUF you set V4L2_BUF_FLAG_REQUEST_FD
> to indicate a valid request_fd. For other queue ioctls that take a struct v4l2_buffer
> this flag and the request_fd field are just ignored. Should we return EINVAL
> instead if the flag is set for those ioctls?
>
> The argument for just ignoring it is that older kernels that do not know about
> this flag will ignore it as well. There is no check against unknown flags.
As I answered before, I don't see any need to add extra code for checking invalid
flags.
It might make sense to ask users to clean the flag if not QBUF, just at the
eventual remote case we might want to use it on other ioctls.
Thanks,
Mauro
next prev parent reply other threads:[~2018-08-16 14:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 10:25 [RFC] Request API questions Hans Verkuil
2018-08-16 11:15 ` Mauro Carvalho Chehab [this message]
2018-08-17 10:02 ` Tomasz Figa
2018-08-17 10:09 ` Hans Verkuil
2018-08-17 10:38 ` Mauro Carvalho Chehab
2018-08-20 7:17 ` Tomasz Figa
2018-08-23 9:45 ` Hans Verkuil
2018-08-21 10:00 ` Sakari Ailus
2018-08-21 10:01 ` Tomasz Figa
2018-08-20 9:10 ` Sakari Ailus
2018-08-23 9:46 ` Hans Verkuil
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=20180816081522.76f71891@coco.lan \
--to=mchehab+samsung@kernel.org \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=maxime.ripard@bootlin.com \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=paul.kocialkowski@bootlin.com \
--cc=sakari.ailus@iki.fi \
--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