public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: Re: [PATCH v2 2/4] media: uvcvideo: Do not set an async control owned by other fh
Date: Fri, 29 Nov 2024 00:22:32 +0200	[thread overview]
Message-ID: <20241128222232.GF25731@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20241127-uvc-fix-async-v2-2-510aab9570dd@chromium.org>

Hi Ricardo,

(CC'ing Hans Verkuil)

Thank you for the patch.

On Wed, Nov 27, 2024 at 12:14:50PM +0000, Ricardo Ribalda wrote:
> If a file handle is waiting for a response from an async control, avoid
> that other file handle operate with it.
> 
> Without this patch, the first file handle will never get the event
> associated with that operation, which can lead to endless loops in
> applications. Eg:
> If an application A wants to change the zoom and to know when the
> operation has completed:
> it will open the video node, subscribe to the zoom event, change the
> control and wait for zoom to finish.
> If before the zoom operation finishes, another application B changes
> the zoom, the first app A will loop forever.

Hans, the V4L2 specification isn't very clear on this. I see pros and
cons for both behaviours, with a preference for the current behaviour,
as with this patch the control will remain busy until the file handle is
closed if the device doesn't send the control event for any reason. What
do you think ?

> Cc: stable@vger.kernel.org
> Fixes: e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives")
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index b6af4ff92cbd..3f8ae35cb3bc 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1955,6 +1955,10 @@ int uvc_ctrl_set(struct uvc_fh *handle,
>  	if (!(ctrl->info.flags & UVC_CTRL_FLAG_SET_CUR))
>  		return -EACCES;
>  
> +	/* Other file handle is waiting a response from this async control. */
> +	if (ctrl->handle && ctrl->handle != handle)
> +		return -EBUSY;
> +
>  	/* Clamp out of range values. */
>  	switch (mapping->v4l2_type) {
>  	case V4L2_CTRL_TYPE_INTEGER:

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-11-28 22:22 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 12:14 [PATCH v2 0/4] media: uvcvideo: Two fixes for async controls Ricardo Ribalda
2024-11-27 12:14 ` [PATCH v2 1/4] media: uvcvideo: Remove dangling pointers Ricardo Ribalda
2024-11-28 22:16   ` Laurent Pinchart
2024-11-28 22:25     ` Ricardo Ribalda
2024-11-28 22:28       ` Laurent Pinchart
2024-11-29  0:21         ` Ricardo Ribalda
2024-11-29 21:22     ` Ricardo Ribalda
2024-11-27 12:14 ` [PATCH v2 2/4] media: uvcvideo: Do not set an async control owned by other fh Ricardo Ribalda
2024-11-28 22:22   ` Laurent Pinchart [this message]
2024-11-28 22:28     ` Ricardo Ribalda
2024-11-28 22:33       ` Laurent Pinchart
2024-11-29 10:36         ` Hans Verkuil
2024-11-29 10:59           ` Ricardo Ribalda
2024-11-29 11:06             ` Laurent Pinchart
2024-11-29 11:54               ` Ricardo Ribalda
2024-11-29 13:13                 ` Hans Verkuil
2024-11-29 13:41                   ` Ricardo Ribalda
2024-11-29 18:47                     ` Ricardo Ribalda
2024-11-29 22:03                       ` Laurent Pinchart
2024-11-29 22:18                         ` Ricardo Ribalda
2024-12-02  0:18                           ` Laurent Pinchart
2024-12-02  7:28                             ` Ricardo Ribalda
2024-12-02  8:38                               ` Laurent Pinchart
2024-12-02 10:11                                 ` Ricardo Ribalda
2024-12-02  8:05                             ` Hans Verkuil
2024-12-02  8:11                               ` Laurent Pinchart
2024-12-02  8:44                                 ` Hans Verkuil
2024-12-02 10:26                                   ` Hans de Goede
2024-12-02 10:50                                     ` Ricardo Ribalda
2024-12-02 12:19                                       ` Hans de Goede
2024-12-02 13:29                                         ` Ricardo Ribalda
2024-12-03 19:32                                           ` Laurent Pinchart
2024-12-04 13:46                                             ` Hans de Goede
2024-12-02 10:55                                     ` Hans Verkuil
2024-12-03 17:18                                       ` Laurent Pinchart
2024-12-04  7:59                                         ` Hans Verkuil
2024-12-04  8:04                                           ` Hans Verkuil
2024-12-04  9:13                                             ` Laurent Pinchart
2024-12-04  9:02                                           ` Laurent Pinchart
2024-11-29 13:10               ` Hans Verkuil
2024-11-29 13:32                 ` Hans Verkuil
2024-11-29 13:37                 ` Ricardo Ribalda
2024-11-29 21:47                   ` Laurent Pinchart
2024-11-29 11:01           ` 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=20241128222232.GF25731@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=guennadi.liakhovetski@intel.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    --cc=stable@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