Skip to content

USB webcam device disconnects don't trigger the associated kernel disconnect processing #3546

@P33M

Description

@P33M

Seen on latest 4.19 and rpi-update 5.4 on a Pi 4B.

Steps to reproduce: Configure a Pi Zero as a USB gadget webcam (legacy g_webcam was used). Plug the device in to any hub port while running the uvc-video script.

  • Device attaches
  • Is probed
  • USB activity goes quiescent
    Disconnect the Pi Zero
  • No disconnect message appears in the message log, and ffmpeg can still attempt to access the device (but it obviously fails).
  • Plugging in a different device into the dead port does not generate a connect event message.

Swap g_webcam for g_ether -> disconnect is registered correctly.
Swap g_webcam for g_cdc -> disconnect is registered correctly.

I can provoke a disconnect when using g_webcam if it is unplugged before this uvcvideo trace message appears about suspending the interface:

[  168.090046] usb 1-1.4.3: new high-speed USB device number 5 using xhci_hcd
[  168.221025] usb 1-1.4.3: New USB device found, idVendor=1337, idProduct=0001, bcdDevice= 0.01
[  168.221041] usb 1-1.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  168.221053] usb 1-1.4.3: Product: webbycam
[  168.221066] usb 1-1.4.3: Manufacturer: Dave
[  168.221079] usb 1-1.4.3: SerialNumber: 12345
[  168.223401] uvcvideo: Probing generic UVC device 1.4.3
[  168.223588] uvcvideo: Found format YUV 4:2:2 (YUYV).
[  168.223600] uvcvideo: - 640x360 (15.0 fps)
[  168.223610] uvcvideo: - 1280x720 (2.0 fps)
[  168.223621] uvcvideo: Found format MJPEG.
[  168.223631] uvcvideo: - 640x360 (15.0 fps)
[  168.223641] uvcvideo: - 1280x720 (2.0 fps)
[  168.223658] uvcvideo: Found a Status endpoint (addr 81).
[  168.223669] uvcvideo: Found UVC 1.00 device webbycam (1337:0001)
[  168.224001] uvcvideo: Added control 00000000-0000-0000-0000-000000000001/2 to device 1.4.3 entity 1
[  168.224018] uvcvideo: Adding mapping 'Exposure, Auto' to control 00000000-0000-0000-0000-000000000001/2.
[  168.224276] uvcvideo: Added control 00000000-0000-0000-0000-000000000101/2 to device 1.4.3 entity 2
[  168.224289] uvcvideo: Adding mapping 'Brightness' to control 00000000-0000-0000-0000-000000000101/2.
[  168.224305] uvcvideo: Scanning UVC chain: OT 3 <- PU 2 <- IT 1
[  168.224329] uvcvideo: Found a valid video chain (1 -> 3).
[  168.225764] uvcvideo 1-1.4.3:1.0: Entity type for entity Processing 2 was not initialized!
[  168.225780] uvcvideo 1-1.4.3:1.0: Entity type for entity Camera 1 was not initialized!
[  168.226137] input: webbycam: UVC Camera as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/input/input0
[  168.226162] uvcvideo: UVC device initialized.
[  168.305309] uvcvideo: uvc_v4l2_open
[  168.305774] uvcvideo: uvc_v4l2_release
[  168.363400] uvcvideo: uvc_v4l2_open
[  168.363409] uvcvideo: uvc_v4l2_open
[  168.363453] uvcvideo: uvc_v4l2_release
[  168.363455] uvcvideo: uvc_v4l2_release
[  168.363809] uvcvideo: uvc_v4l2_open
[  168.364121] uvcvideo: uvc_v4l2_open
[  168.365354] uvcvideo: uvc_v4l2_release
[  168.365371] uvcvideo: uvc_v4l2_release
[  171.129630] uvcvideo: Suspending interface 1
[  171.129643] uvcvideo: Suspending interface 0


vs.

[  666.314342] usb 1-1.4.4: new high-speed USB device number 9 using xhci_hcd
[  666.445340] usb 1-1.4.4: New USB device found, idVendor=1d6b, idProduct=0102, bcdDevice= 4.19
[  666.445356] usb 1-1.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  666.445369] usb 1-1.4.4: Product: Webcam gadget
[  666.445381] usb 1-1.4.4: Manufacturer: Linux Foundation
[  666.447533] uvcvideo: Probing generic UVC device 1.4.4
[  666.447705] uvcvideo: Found format YUV 4:2:2 (YUYV).
[  666.447718] uvcvideo: - 640x360 (15.0 fps)
[  666.447728] uvcvideo: - 1280x720 (2.0 fps)
[  666.447738] uvcvideo: Found format MJPEG.
[  666.447748] uvcvideo: - 640x360 (15.0 fps)
[  666.447758] uvcvideo: - 1280x720 (2.0 fps)
[  666.447775] uvcvideo: Found a Status endpoint (addr 81).
[  666.447786] uvcvideo: Found UVC 1.00 device Webcam gadget (1d6b:0102)
[  666.448117] uvcvideo: Added control 00000000-0000-0000-0000-000000000001/2 to device 1.4.4 entity 1
[  666.448135] uvcvideo: Adding mapping 'Exposure, Auto' to control 00000000-0000-0000-0000-000000000001/2.
[  666.448368] uvcvideo: Added control 00000000-0000-0000-0000-000000000101/2 to device 1.4.4 entity 2
[  666.448382] uvcvideo: Adding mapping 'Brightness' to control 00000000-0000-0000-0000-000000000101/2.
[  666.448397] uvcvideo: Scanning UVC chain: OT 3 <- PU 2 <- IT 1
[  666.448421] uvcvideo: Found a valid video chain (1 -> 3).
[  666.449692] uvcvideo 1-1.4.4:1.0: Entity type for entity Processing 2 was not initialized!
[  666.449708] uvcvideo 1-1.4.4:1.0: Entity type for entity Camera 1 was not initialized!
[  666.450048] input: Webcam gadget: UVC Camera as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4:1.0/input/input2
[  666.450221] uvcvideo: UVC device initialized.
[  666.506873] uvcvideo: uvc_v4l2_open
[  666.507363] uvcvideo: uvc_v4l2_release
[  666.543203] uvcvideo: uvc_v4l2_open
[  666.543248] uvcvideo: uvc_v4l2_release
[  666.543892] uvcvideo: uvc_v4l2_open
[  666.545569] uvcvideo: uvc_v4l2_open
[  666.545594] uvcvideo: uvc_v4l2_release
[  666.545763] uvcvideo: uvc_v4l2_release
[  666.545852] uvcvideo: uvc_v4l2_open
[  666.546076] uvcvideo: uvc_v4l2_release
[  667.496107] usb 1-1.4.4: USB disconnect, device number 9

So there is a critical window in which the device behaves normally.

If I have a port in the "dead" state, i.e. one which previously had a g_webcam Pi Zero attached, and was unplugged outside of the critical window, then unplugging a Pi Zero webcam from a different port results in two disconnect messages - one for the dead port and one for the webcam.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions