From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Tomasz Figa <tfiga@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
senozhatsky@chromium.org
Subject: Re: [PATCH 07/10] media: uvcvideo: set error_idx to count on EACCESS
Date: Thu, 11 Mar 2021 18:18:05 +0200 [thread overview]
Message-ID: <YEpCvQYGj/4bAncp@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20210311122040.1264410-9-ribalda@chromium.org>
Hi Ricardo,
Thank you for the patch.
On Thu, Mar 11, 2021 at 01:20:37PM +0100, Ricardo Ribalda wrote:
> According to the doc:
The previous paragraph states:
This check is done to avoid leaving the hardware in an inconsistent
state due to easy-to-avoid problems. But it leads to another problem:
the application needs to know whether an error came from the validation
step (meaning that the hardware was not touched) or from an error during
the actual reading from/writing to hardware.
> The, in hindsight quite poor, solution for that is to set error_idx to
> count if the validation failed.
>
> Fixes v4l2-compliance:
> Control ioctls (Input 0):
> fail: v4l2-test-controls.cpp(645): invalid error index write only control
> test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_v4l2.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 625c216c46b5..9b6454bb2f28 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -1076,7 +1076,8 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
> ret = uvc_ctrl_get(chain, ctrl);
> if (ret < 0) {
> uvc_ctrl_rollback(handle);
> - ctrls->error_idx = i;
> + ctrls->error_idx = (ret == -EACCES) ?
> + ctrls->count : i;
No need for parentheses.
I'm not sure this is correct though. -EACCES is returned by
__uvc_ctrl_get() when the control is found and is a write-only control.
The uvc_ctrl_get() calls for the previous controls will have potentially
touched the device to read the current control value if it wasn't cached
already, to this contradicts the rationale from the specification.
I understand the need for this when setting controls, but when reading
them, it's more puzzling, as the interactions with the hardware to read
the controls are not supposed to affect the hardware state in a way that
applications should care about. It may be an issue in the V4L2
specification.
> return ret;
> }
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2021-03-11 16:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 12:20 [PATCH 00/10] uvcvideo: Pass v4l2-compliance test Ricardo Ribalda
2021-03-11 12:20 ` [PATCH 01/10] media: uvcvideo: Return -EINVAL for REQUEST API Ricardo Ribalda
2021-03-11 12:20 ` [PATCH] media: videobuf2: Explicitly state max size of planes Ricardo Ribalda
2021-03-11 12:20 ` [PATCH 02/10] media: uvcvideo: Set capability in s_param Ricardo Ribalda
2021-03-11 15:42 ` Laurent Pinchart
2021-03-11 12:20 ` [PATCH 03/10] media: uvcvideo: Return -EIO for control errors Ricardo Ribalda
2021-03-11 14:08 ` Ricardo Ribalda
2021-03-11 15:57 ` Laurent Pinchart
2021-03-11 21:56 ` Ricardo Ribalda Delgado
2021-03-11 14:08 ` Hans Verkuil
2021-03-11 12:20 ` [PATCH 04/10] media: uvcvideo: Add support for V4L2_CTRL_TYPE_CTRL_CLASS Ricardo Ribalda
2021-03-11 12:20 ` [PATCH 05/10] media: uvcvideo: Define Control and GUIDs for class ctrls Ricardo Ribalda
2021-03-11 12:20 ` [PATCH 06/10] media: uvcvideo: Implement UVC_CTRL_CLASS_UNIT Ricardo Ribalda
2021-03-11 16:06 ` Laurent Pinchart
2021-03-11 12:20 ` [PATCH 07/10] media: uvcvideo: set error_idx to count on EACCESS Ricardo Ribalda
2021-03-11 16:18 ` Laurent Pinchart [this message]
2021-03-11 21:51 ` Ricardo Ribalda Delgado
2021-03-11 12:20 ` [PATCH 08/10] media: uvcvideo: Always return a value on V4L2_CTRL_WHICH_DEF_VAL Ricardo Ribalda
2021-03-11 16:21 ` Laurent Pinchart
2021-03-11 12:20 ` [PATCH 09/10] media: uvcvideo: Do not create initial events for class ctrls Ricardo Ribalda
2021-03-11 12:20 ` [PATCH 10/10] media: uvcvideo: Populate only active control classes Ricardo Ribalda
2021-03-11 14:31 ` Hans Verkuil
2021-03-11 15:21 ` Ricardo Ribalda Delgado
2021-03-11 15:59 ` Laurent Pinchart
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=YEpCvQYGj/4bAncp@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=senozhatsky@chromium.org \
--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
all inboxes | Powered by JetHome®