public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] uvcvideo: Attempt N to land UVC race conditions fixes
@ 2023-11-21 19:53 Ricardo Ribalda
  2023-11-21 19:53 ` [PATCH v3 1/3] media: uvcvideo: Always use uvc_status_stop() Ricardo Ribalda
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Ricardo Ribalda @ 2023-11-21 19:53 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Guenter Roeck, Tomasz Figa, Laurent Pinchart, Alan Stern,
	Hans Verkuil, linux-media, linux-kernel, Sean Paul,
	Ricardo Ribalda, Sakari Ailus

Back in 2020 Guenter published a set of patches to fix some race
conditions on UVC.
https://lore.kernel.org/all/20200917022547.198090-5-linux@roeck-us.net/

That kind of race conditions are not only seen on UVC, but are a common
sin on almost all the kernel, so this is what it was decided back then
that we should try to fix them at higher levels.

After that. A lot of video_is_registered() were added to the core:

```
ribalda@alco:~/work/linux$ git grep is_registered drivers/media/v4l2-core/
drivers/media/v4l2-core/v4l2-compat-ioctl32.c:  if (!video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (video_is_registered(vdev)) {
drivers/media/v4l2-core/v4l2-dev.c:             if (video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (!video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (vdev == NULL || !video_is_registered(vdev)) {
drivers/media/v4l2-core/v4l2-dev.c:             if (video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-dev.c:     if (!vdev || !video_is_registered(vdev))
drivers/media/v4l2-core/v4l2-ioctl.c:   if (!video_is_registered(vfd)) {
drivers/media/v4l2-core/v4l2-subdev.c:  if (video_is_registered(vdev)) {
```

And recently Sakari is trying to land:
https://lore.kernel.org/linux-media/20230201214535.347075-1-sakari.ailus@linux.intel.com/

Which will make obsolete a lot of (all?) of the video_is_registered() checks on
Guenter's patches.

Besides those checks, there were some other valid races fixed on his
patches.

This series is just a rebase of what I think is missing on UVC even
if we fixed v4l2/core with all the video_is_register() checks removed.

Thanks!

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v3:
- Introduce media: uvcvideo: Do not halt the device after disconnect
- Introduce media: uvcvideo: Always use uvc_status_stop()
- Link to v2: https://lore.kernel.org/r/20230309-guenter-mini-v2-0-e6410d590d43@chromium.org

Changes in v2:
- Actually send the series to the ML an not only to individuals.
- Link to v1: https://lore.kernel.org/r/20230309-guenter-mini-v1-0-627d10cf6e96@chromium.org

---
Guenter Roeck (1):
      media: uvcvideo: Lock video streams and queues while unregistering

Ricardo Ribalda (2):
      media: uvcvideo: Always use uvc_status_stop()
      media: uvcvideo: Do not halt the device after disconnect

 drivers/media/usb/uvc/uvc_ctrl.c   |  4 ----
 drivers/media/usb/uvc/uvc_driver.c | 11 ++++++++++
 drivers/media/usb/uvc/uvc_status.c |  2 +-
 drivers/media/usb/uvc/uvc_video.c  | 45 ++++++++++++++++++++++++--------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 5 files changed, 42 insertions(+), 22 deletions(-)
---
base-commit: 98b1cc82c4affc16f5598d4fa14b1858671b2263
change-id: 20230309-guenter-mini-89861b084ef1

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-11-22 14:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21 19:53 [PATCH v3 0/3] uvcvideo: Attempt N to land UVC race conditions fixes Ricardo Ribalda
2023-11-21 19:53 ` [PATCH v3 1/3] media: uvcvideo: Always use uvc_status_stop() Ricardo Ribalda
2023-11-22  7:21   ` Sergey Senozhatsky
2023-11-22  7:35     ` Ricardo Ribalda
2023-11-22  9:53       ` Ricardo Ribalda
2023-11-22  9:58   ` Sakari Ailus
2023-11-22 10:33     ` Ricardo Ribalda
2023-11-21 19:53 ` [PATCH v3 2/3] media: uvcvideo: Do not halt the device after disconnect Ricardo Ribalda
2023-11-22  7:47   ` Sergey Senozhatsky
2023-11-22  8:01     ` Sergey Senozhatsky
2023-11-22  9:55       ` Ricardo Ribalda
2023-11-22 10:25   ` Sakari Ailus
2023-11-22 10:32     ` Ricardo Ribalda
2023-11-22 11:03       ` Sakari Ailus
2023-11-22 11:35         ` Ricardo Ribalda
2023-11-21 19:53 ` [PATCH v3 3/3] media: uvcvideo: Lock video streams and queues while unregistering Ricardo Ribalda
2023-11-22  8:22   ` Sergey Senozhatsky
2023-11-22 10:21   ` Sakari Ailus
2023-11-22 13:14     ` Laurent Pinchart
2023-11-22 13:59       ` Ricardo Ribalda
2023-11-22 14:04         ` Laurent Pinchart
2023-11-22 14:23           ` Ricardo Ribalda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox