[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231122074742.GB1465745@google.com>
Date: Wed, 22 Nov 2023 16:47:42 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Ricardo Ribalda <ribalda@...omium.org>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Guenter Roeck <linux@...ck-us.net>,
Tomasz Figa <tfiga@...omium.org>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Alan Stern <stern@...land.harvard.edu>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Sean Paul <seanpaul@...omium.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>
Subject: Re: [PATCH v3 2/3] media: uvcvideo: Do not halt the device after
disconnect
On (23/11/21 19:53), Ricardo Ribalda wrote:
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 08fcd2ffa727..413c32867617 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2257,6 +2257,8 @@ static void uvc_disconnect(struct usb_interface *intf)
> return;
>
> uvc_unregister_video(dev);
> + /* Barrier needed to synchronize with uvc_video_stop_streaming(). */
> + smp_store_release(&dev->disconnected, true);
> kref_put(&dev->ref, uvc_delete);
> }
[..]
> +void uvc_video_stop_streaming(struct uvc_streaming *stream)
> +{
> + uvc_video_stop_transfer(stream, 1);
> +
> + /*
> + * Barrier needed to synchronize with uvc_disconnect().
> + * We cannot call usb_* functions on a disconnected USB device.
> + */
> + if (!smp_load_acquire(&stream->dev->disconnected))
> + uvc_video_halt(stream);
> +
> uvc_video_clock_cleanup(stream);
> }
Can the following happen?
CPU0 CPU1
uvc_disconnect()
uvc_video_stop_streaming()
usb_set_intfdata()
uvc_unregister_video()
if (!smp_load(&dev->disconnected))
uvc_video_halt()
smp_store_release(&dev->disconnected, true);
kref_put(&dev->ref, uvc_delete);
Powered by blists - more mailing lists