* [PATCH] media: uvcvideo: Fail probe when no video device is registered
@ 2026-11-04 2:21 Chen Changcheng
2026-11-04 6:04 ` Laurent Pinchart
2026-11-04 7:41 ` Laurent Pinchart
0 siblings, 2 replies; 4+ messages in thread
From: Chen Changcheng @ 2026-11-04 2:21 UTC (permalink / raw)
To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Chen Changcheng
When a UVC device is unbound while userspace still holds the video
device open, the VS interface claims are released only after the last
file descriptor is closed. Rebinding before that fails to claim the VS
interfaces, leaving the VC interface bound without a usable video
device:
[ 3229.189556] uvcvideo: Probing generic UVC device 1
[ 3229.190496] uvcvideo: device 2 interface 1 is already claimed
...
[ 3229.193758] uvcvideo: Scanning UVC chain: OT 4 <- XU 3 <- PU 2 <- IT 1
[ 3229.193766] uvcvideo: Found a valid video chain (1 -> 4).
[ 3229.193771] usb 9-1: No streaming interface found for terminal 4.
Check after registering all video chains that at least one video device
was registered, and fail the probe with -ENODEV otherwise.
Devices with no usable streaming interface at all will now also stay
unbound instead of being bound without any video device.
Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
---
drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index e289cc71ba98..0943db4eae07 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2156,6 +2156,19 @@ static int uvc_register_terms(struct uvc_device *dev,
return 0;
}
+static int uvc_has_video_node(struct uvc_device *dev)
+{
+ struct uvc_streaming *stream;
+
+ list_for_each_entry(stream, &dev->streams, list)
+ if (video_is_registered(&stream->queue.vdev))
+ return 0;
+
+ dev_info(&dev->intf->dev,
+ "No usable streaming interface found\n");
+ return -ENODEV;
+}
+
static int uvc_register_chains(struct uvc_device *dev)
{
struct uvc_video_chain *chain;
@@ -2174,7 +2187,7 @@ static int uvc_register_chains(struct uvc_device *dev)
#endif
}
- return 0;
+ return uvc_has_video_node(dev);
}
/* ------------------------------------------------------------------------
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: uvcvideo: Fail probe when no video device is registered
2026-11-04 2:21 [PATCH] media: uvcvideo: Fail probe when no video device is registered Chen Changcheng
@ 2026-11-04 6:04 ` Laurent Pinchart
2026-11-04 7:21 ` Chen Changcheng
2026-11-04 7:41 ` Laurent Pinchart
1 sibling, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2026-11-04 6:04 UTC (permalink / raw)
To: Chen Changcheng
Cc: Hans de Goede, Mauro Carvalho Chehab, linux-media, linux-kernel
On Wed, Nov 04, 2026 at 10:21:46AM +0800, Chen Changcheng wrote:
> When a UVC device is unbound while userspace still holds the video
> device open, the VS interface claims are released only after the last
> file descriptor is closed. Rebinding before that fails to claim the VS
> interfaces, leaving the VC interface bound without a usable video
> device:
>
> [ 3229.189556] uvcvideo: Probing generic UVC device 1
> [ 3229.190496] uvcvideo: device 2 interface 1 is already claimed
> ...
> [ 3229.193758] uvcvideo: Scanning UVC chain: OT 4 <- XU 3 <- PU 2 <- IT 1
> [ 3229.193766] uvcvideo: Found a valid video chain (1 -> 4).
> [ 3229.193771] usb 9-1: No streaming interface found for terminal 4.
Please provide the USB descriptors for your device.
> Check after registering all video chains that at least one video device
> was registered, and fail the probe with -ENODEV otherwise.
>
> Devices with no usable streaming interface at all will now also stay
> unbound instead of being bound without any video device.
>
> Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
> ---
> drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index e289cc71ba98..0943db4eae07 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2156,6 +2156,19 @@ static int uvc_register_terms(struct uvc_device *dev,
> return 0;
> }
>
> +static int uvc_has_video_node(struct uvc_device *dev)
> +{
> + struct uvc_streaming *stream;
> +
> + list_for_each_entry(stream, &dev->streams, list)
> + if (video_is_registered(&stream->queue.vdev))
> + return 0;
> +
> + dev_info(&dev->intf->dev,
> + "No usable streaming interface found\n");
> + return -ENODEV;
> +}
> +
> static int uvc_register_chains(struct uvc_device *dev)
> {
> struct uvc_video_chain *chain;
> @@ -2174,7 +2187,7 @@ static int uvc_register_chains(struct uvc_device *dev)
> #endif
> }
>
> - return 0;
> + return uvc_has_video_node(dev);
> }
>
> /* ------------------------------------------------------------------------
>
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: uvcvideo: Fail probe when no video device is registered
2026-11-04 6:04 ` Laurent Pinchart
@ 2026-11-04 7:21 ` Chen Changcheng
0 siblings, 0 replies; 4+ messages in thread
From: Chen Changcheng @ 2026-11-04 7:21 UTC (permalink / raw)
To: laurent.pinchart
Cc: chenchangcheng, hansg, linux-kernel, linux-media, mchehab
Hi Laurent Pinchart,
Below is the detailed USB device descriptor.
Bus 009 Device 002: ID 2ef4:220c Hopewin Electronics Co., Ltd. Integrated Camera
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x2ef4
idProduct 0x220c
bcdDevice 0.04
iManufacturer 2 Hopewin Electronics Co., Ltd.
iProduct 1 Integrated Camera
iSerial 3 SN0001
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0357
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 5 Integrated Camera
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 0
iInterface 5 Integrated Camera
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.00
wTotalLength 0x004f
dwClockFrequency 15.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 4
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
VideoControl Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 3
guidExtensionCode {28f03370-6311-4a2e-ba2c-6890eb334016}
bNumControl 24
bNrPins 1
baSourceID( 0) 2
bControlSize 3
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0x07
iExtension 0
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x0020000e
Auto-Exposure Mode
Auto-Exposure Priority
Exposure Time (Absolute)
VideoControl Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
Warning: Descriptor too short
bUnitID 2
bSourceID 1
wMaxMultiplier 0
bControlSize 2
bmControls 0x0000177f
Brightness
Contrast
Hue
Saturation
Sharpness
Gamma
White Balance Temperature
Backlight Compensation
Gain
Power Line Frequency
White Balance Temperature, Auto
iProcessing 0
bmVideoStandards 0x00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 6
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
VideoStreaming Interface Descriptor:
bLength 15
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 2
wTotalLength 0x025f
bEndPointAddress 129
bmInfo 0
bTerminalLink 4
bStillCaptureMethod 0
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 0
bmaControls( 1) 0
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 1
bNumFrameDescriptors 6
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 0
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x00
Still image unsupported
wWidth 1920
wHeight 1080
dwMinBitRate 165888000
dwMaxBitRate 995328000
dwMaxVideoFrameBufferSize 4147789
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 2
bmCapabilities 0x00
Still image unsupported
wWidth 1280
wHeight 720
dwMinBitRate 73728000
dwMaxBitRate 442368000
dwMaxVideoFrameBufferSize 1843789
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 3
bmCapabilities 0x00
Still image unsupported
wWidth 960
wHeight 540
dwMinBitRate 41472000
dwMaxBitRate 248832000
dwMaxVideoFrameBufferSize 1037389
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 4
bmCapabilities 0x00
Still image unsupported
wWidth 848
wHeight 480
dwMinBitRate 32563200
dwMaxBitRate 195379200
dwMaxVideoFrameBufferSize 814669
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 5
bmCapabilities 0x00
Still image unsupported
wWidth 640
wHeight 480
dwMinBitRate 24576000
dwMaxBitRate 147456000
dwMaxVideoFrameBufferSize 614989
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 6
bmCapabilities 0x00
Still image unsupported
wWidth 640
wHeight 360
dwMinBitRate 18432000
dwMaxBitRate 110592000
dwMaxVideoFrameBufferSize 461389
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 27
bDescriptorType 36
bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)
bFormatIndex 2
bNumFrameDescriptors 6
guidFormat {32595559-0000-0010-8000-00aa00389b71}
bBitsPerPixel 16
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 0
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 1
bmCapabilities 0x00
Still image unsupported
wWidth 1920
wHeight 1080
dwMinBitRate 165888000
dwMaxBitRate 165888000
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 2000000
bFrameIntervalType 1
dwFrameInterval( 0) 2000000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 2
bmCapabilities 0x00
Still image unsupported
wWidth 1280
wHeight 720
dwMinBitRate 73728000
dwMaxBitRate 147456000
dwMaxVideoFrameBufferSize 1843200
dwDefaultFrameInterval 1000000
bFrameIntervalType 2
dwFrameInterval( 0) 1000000
dwFrameInterval( 1) 2000000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 3
bmCapabilities 0x00
Still image unsupported
wWidth 960
wHeight 540
dwMinBitRate 41472000
dwMaxBitRate 165888000
dwMaxVideoFrameBufferSize 1036800
dwDefaultFrameInterval 500000
bFrameIntervalType 4
dwFrameInterval( 0) 500000
dwFrameInterval( 1) 666666
dwFrameInterval( 2) 1000000
dwFrameInterval( 3) 2000000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 4
bmCapabilities 0x00
Still image unsupported
wWidth 848
wHeight 480
dwMinBitRate 32563200
dwMaxBitRate 130252800
dwMaxVideoFrameBufferSize 814080
dwDefaultFrameInterval 500000
bFrameIntervalType 4
dwFrameInterval( 0) 500000
dwFrameInterval( 1) 666666
dwFrameInterval( 2) 1000000
dwFrameInterval( 3) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 5
bmCapabilities 0x00
Still image unsupported
wWidth 640
wHeight 480
dwMinBitRate 24576000
dwMaxBitRate 147456000
dwMaxVideoFrameBufferSize 614400
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 50
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 6
bmCapabilities 0x00
Still image unsupported
wWidth 640
wHeight 360
dwMinBitRate 18432000
dwMaxBitRate 110592000
dwMaxVideoFrameBufferSize 460800
dwDefaultFrameInterval 333333
bFrameIntervalType 6
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 400000
dwFrameInterval( 2) 500000
dwFrameInterval( 3) 666666
dwFrameInterval( 4) 1000000
dwFrameInterval( 5) 2000000
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 1 (BT.709,sRGB)
bTransferCharacteristics 1 (BT.709)
bMatrixCoefficients 4 (SMPTE 170M (BT.601))
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0080 1x 128 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 2
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0100 1x 256 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 3
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0320 1x 800 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 4
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0b20 2x 800 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 5
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x1320 3x 800 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 6
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x1400 3x 1024 bytes
bInterval 1
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 1
bFunctionClass 254 Application Specific Interface
bFunctionSubClass 1 Device Firmware Update
bFunctionProtocol 1
iFunction 7 USB DFU
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 254 Application Specific Interface
bInterfaceSubClass 1 Device Firmware Update
bInterfaceProtocol 1
iInterface 8 APP Mode
Device Firmware Upgrade Interface Descriptor:
bLength 9
bDescriptorType 33
bmAttributes 7
Will Not Detach
Manifestation Tolerant
Upload Supported
Download Supported
wDetachTimeout 1000 milliseconds
wTransferSize 64 bytes
bcdDFUVersion 1.10
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)
--
Regards
Chen Changcheng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: uvcvideo: Fail probe when no video device is registered
2026-11-04 2:21 [PATCH] media: uvcvideo: Fail probe when no video device is registered Chen Changcheng
2026-11-04 6:04 ` Laurent Pinchart
@ 2026-11-04 7:41 ` Laurent Pinchart
1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2026-11-04 7:41 UTC (permalink / raw)
To: Chen Changcheng
Cc: Hans de Goede, Mauro Carvalho Chehab, linux-media, linux-kernel
On Wed, Nov 04, 2026 at 10:21:46AM +0800, Chen Changcheng wrote:
> When a UVC device is unbound while userspace still holds the video
> device open, the VS interface claims are released only after the last
> file descriptor is closed. Rebinding before that fails to claim the VS
> interfaces, leaving the VC interface bound without a usable video
> device:
>
> [ 3229.189556] uvcvideo: Probing generic UVC device 1
> [ 3229.190496] uvcvideo: device 2 interface 1 is already claimed
> ...
> [ 3229.193758] uvcvideo: Scanning UVC chain: OT 4 <- XU 3 <- PU 2 <- IT 1
> [ 3229.193766] uvcvideo: Found a valid video chain (1 -> 4).
> [ 3229.193771] usb 9-1: No streaming interface found for terminal 4.
>
> Check after registering all video chains that at least one video device
> was registered, and fail the probe with -ENODEV otherwise.
That's a workaround, it doesn't fix the root cause.
> Devices with no usable streaming interface at all will now also stay
> unbound instead of being bound without any video device.
>
> Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
> ---
> drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index e289cc71ba98..0943db4eae07 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2156,6 +2156,19 @@ static int uvc_register_terms(struct uvc_device *dev,
> return 0;
> }
>
> +static int uvc_has_video_node(struct uvc_device *dev)
> +{
> + struct uvc_streaming *stream;
> +
> + list_for_each_entry(stream, &dev->streams, list)
> + if (video_is_registered(&stream->queue.vdev))
> + return 0;
> +
> + dev_info(&dev->intf->dev,
> + "No usable streaming interface found\n");
> + return -ENODEV;
> +}
> +
> static int uvc_register_chains(struct uvc_device *dev)
> {
> struct uvc_video_chain *chain;
> @@ -2174,7 +2187,7 @@ static int uvc_register_chains(struct uvc_device *dev)
> #endif
> }
>
> - return 0;
> + return uvc_has_video_node(dev);
> }
>
> /* ------------------------------------------------------------------------
>
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-04 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 2:21 [PATCH] media: uvcvideo: Fail probe when no video device is registered Chen Changcheng
2026-11-04 6:04 ` Laurent Pinchart
2026-11-04 7:21 ` Chen Changcheng
2026-11-04 7:41 ` Laurent Pinchart
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®