Skip to contentSkip to conversation

USB/UVC: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure

PATCH Superseded JP Hein 1 participant 4 messages Mar 22

Subsystems (4)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

JP Hein

author
#0 lore raw

v4 cover USB/UVC: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure

The Razer Kiyo Pro (1532:0e05) is a USB 3.0 webcam whose firmware has a well-documented failure mode that cascades into complete xHCI host controller death, disconnecting every USB device on the bus -- including keyboards and mice, requiring a hard reboot.

The device has two crash triggers:

1. LPM/autosuspend resume: Device enters LPM or autosuspend, fails to reinitialize on resume, producing EPIPE (-32) on UVC SET_CUR. The stalled endpoint triggers an xHCI stop-endpoint timeout, and the kernel declares the host controller dead.

2. Rapid control transfers: sustained rapid UVC SET_CUR operations (hundreds over several seconds) overwhelm the firmware. The error-code query (GET_CUR on UVC_VC_REQUEST_ERROR_CODE_CONTROL) amplifies the failure by sending a second transfer to the already-stalling device, pushing it into a full lockup and xHCI controller death.

This has been reported as Ubuntu Launchpad Bug #2061177, with reports across kernel versions 6.5 through 6.8. There are currently no device-specific quirks for this webcam in either the USB core quirks table or the UVC driver device table.

This series adds three patches:

Patch 1: USB core -- USB_QUIRK_NO_LPM to prevent Link Power Management
transitions that destabilize the device firmware.

Patch 2: UVC driver -- introduce UVC_QUIRK_CTRL_THROTTLE to rate-limit
SET_CUR control transfers (50ms minimum interval) and skip the error-code query after EPIPE errors on affected devices.

Patch 3: UVC driver -- add Razer Kiyo Pro device table entry with
UVC_QUIRK_CTRL_THROTTLE, UVC_QUIRK_DISABLE_AUTOSUSPEND, and UVC_QUIRK_NO_RESET_RESUME to address both crash triggers.

Together, these keep the device in a stable active state, prevent rapid control transfer crashes, and avoid the power management transitions that trigger the firmware bug.

Changes since v3:
- Regenerated patches against media-committers next branch to fix context mismatch (v3 was based on Ubuntu 6.8 source)

Tested on:
- Kernel: 6.8.0-106-generic (Ubuntu 24.04)
- Hardware: Intel Cannon Lake PCH xHCI (8086:a36d)
- Device: Razer Kiyo Pro (1532:0e05), firmware 8.21
- Stress test: 50 rounds of rapid UVC control changes, 0 failures

Stress test and crash evidence: https://github.com/jphein/kiyo-xhci-fix

JP Hein (3):
USB: core: add NO_LPM quirk for Razer Kiyo Pro webcam
media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile firmware
media: uvcvideo: add quirks for Razer Kiyo Pro webcam

 drivers/media/usb/uvc/uvc_driver.c | 17 ++++++++++++++++
 drivers/media/usb/uvc/uvc_video.c  | 32 ++++++++++++++++++++++++++++++
 drivers/media/usb/uvc/uvcvideo.h   |  3 +++
 drivers/usb/core/quirks.c          |  2 ++
 4 files changed, 54 insertions(+)
author
#1 lore raw

PATCH v4 1/3 USB: core: add NO_LPM quirk for Razer Kiyo Pro webcam

The Razer Kiyo Pro (1532:0e05) is a USB 3.0 UVC webcam whose firmware does not handle USB Link Power Management transitions reliably. When LPM is active, the device can enter a state where it fails to respond to control transfers, producing EPIPE (-32) errors on UVC probe control SET_CUR requests. In the worst case, the stalled endpoint triggers an xHCI stop-endpoint command that times out, causing the host controller to be declared dead and every USB device on the bus to be disconnected.

This has been reported as Ubuntu Launchpad Bug #2061177. The failure mode is:

1. UVC probe control SET_CUR returns -32 (EPIPE)
2. xHCI host not responding to stop endpoint command
3. xHCI host controller not responding, assume dead
4. All USB devices on the affected xHCI controller disconnect

Disabling LPM prevents the firmware from entering the problematic low- power states that precede the stall. This is the same approach used for other webcams with similar firmware issues (e.g., Logitech HD Webcam C270).

---
 drivers/usb/core/quirks.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/core/quirks.c +2 -0
index 9e7e49712..7c4038a1e 100644
@@ -480,6 +480,8 @@ static const struct usb_device_id usb_quirk_list[] = {
 	/* Razer - Razer Blade Keyboard */
 	{ USB_DEVICE(0x1532, 0x0116), .driver_info =
 			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
+	/* Razer - Razer Kiyo Pro Webcam */
+	{ USB_DEVICE(0x1532, 0x0e05), .driver_info = USB_QUIRK_NO_LPM },
 
 	/* Lenovo ThinkPad OneLink+ Dock twin hub controllers (VIA Labs VL812) */
 	{ USB_DEVICE(0x17ef, 0x1018), .driver_info = USB_QUIRK_RESET_RESUME },
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v4 2/3 media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile firmware

In reply to JP Hein

Some USB webcams have firmware that crashes when it receives rapid consecutive UVC control transfers (SET_CUR). The Razer Kiyo Pro (1532:0e05) is one such device -- after several hundred rapid control changes over a few seconds, the device stops responding entirely, triggering an xHCI stop-endpoint command timeout that causes the host controller to be declared dead, disconnecting every USB device on the bus.

The failure is amplified by the standard UVC error-code query: when a SET_CUR fails with EPIPE, the driver sends a second transfer (GET_CUR on UVC_VC_REQUEST_ERROR_CODE_CONTROL) to read the UVC error code. On a device that is already stalling, this second transfer pushes the firmware into a full lockup.

Introduce UVC_QUIRK_CTRL_THROTTLE (0x00080000) to address both issues:

- Enforce a minimum 50ms interval between SET_CUR control transfers, preventing the rapid-fire pattern that overwhelms the firmware. 50ms allows up to 20 control changes per second, which is sufficient for interactive slider adjustments while keeping the device stable.

- Skip the UVC_VC_REQUEST_ERROR_CODE_CONTROL query after EPIPE errors on devices with this quirk. EPIPE is returned directly without the follow-up query that would amplify the failure.

The UVC control path is serialized by ctrl_mutex, so last_ctrl_set_jiffies does not require additional locking.

---
 drivers/media/usb/uvc/uvc_video.c | 32 +++++++++++++++++++++++++++++++
 drivers/media/usb/uvc/uvcvideo.h  |  3 +++
 2 files changed, 35 insertions(+)
drivers/media/usb/uvc/uvc_video.c +32 -0
index 40c76c051..9f402f55e 100644
@@ -75,8 +75,30 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	u8 error;
 	u8 tmp;
 
+	/*
+	 * Rate-limit SET_CUR operations for devices with fragile firmware.
+	 * The Razer Kiyo Pro locks up under sustained rapid SET_CUR
+	 * transfers (hundreds without delay), crashing the xHCI controller.
+	 */
+	if (query == UVC_SET_CUR &&
+	    (dev->quirks & UVC_QUIRK_CTRL_THROTTLE)) {
+		unsigned long min_interval = msecs_to_jiffies(50);
+
+		if (dev->last_ctrl_set_jiffies &&
+		    time_before(jiffies,
+				dev->last_ctrl_set_jiffies + min_interval)) {
+			unsigned long elapsed = dev->last_ctrl_set_jiffies +
+						min_interval - jiffies;
+			msleep(jiffies_to_msecs(elapsed));
+		}
+	}
+
 	ret = __uvc_query_ctrl(dev, query, unit, intfnum, cs, data, size,
 				UVC_CTRL_CONTROL_TIMEOUT);
+
+	if (query == UVC_SET_CUR &&
+	    (dev->quirks & UVC_QUIRK_CTRL_THROTTLE))
+		dev->last_ctrl_set_jiffies = jiffies;
 	if (likely(ret == size))
 		return 0;
 
@@ -108,6 +130,16 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 		return ret < 0 ? ret : -EPIPE;
 	}
 
+	/*
+	 * Skip the error code query for devices that crash under load.
+	 * The standard error-code query (GET_CUR on
+	 * UVC_VC_REQUEST_ERROR_CODE_CONTROL) sends a second USB transfer to
+	 * a device that is already stalling, which can amplify the failure
+	 * into a full firmware lockup and xHCI controller death.
+	 */
+	if (dev->quirks & UVC_QUIRK_CTRL_THROTTLE)
+		return -EPIPE;
+
 	/* Reuse data[0] to request the error code. */
 	tmp = *(u8 *)data;
 
drivers/media/usb/uvc/uvcvideo.h +3 -0
index 8480d65ec..cafc71457 100644
@@ -81,6 +81,7 @@
 #define UVC_QUIRK_INVALID_DEVICE_SOF	0x00010000
 #define UVC_QUIRK_MJPEG_NO_EOF		0x00020000
 #define UVC_QUIRK_MSXU_META		0x00040000
+#define UVC_QUIRK_CTRL_THROTTLE		0x00080000
 
 /* Format flags */
 #define UVC_FMT_FLAG_COMPRESSED		0x00000001
@@ -579,6 +580,8 @@ struct uvc_device {
 	struct usb_interface *intf;
 	unsigned long warnings;
 	u32 quirks;
+	/* Control transfer throttling (UVC_QUIRK_CTRL_THROTTLE) */
+	unsigned long last_ctrl_set_jiffies;
 	int intfnum;
 	char name[32];
 
Signature · 1 line
2.43.0
author
#3 lore raw

PATCH v4 3/3 media: uvcvideo: add quirks for Razer Kiyo Pro webcam

In reply to JP Hein

The Razer Kiyo Pro (1532:0e05) is a USB 3.0 webcam whose firmware has two failure modes that cascade into full xHCI host controller death, disconnecting every USB device on the bus:

1. LPM/autosuspend resume: the device fails to reinitialize its UVC endpoints on resume, producing EPIPE on SET_CUR. The stalled endpoint triggers an xHCI stop-endpoint timeout.

2. Rapid control transfers: sustained rapid SET_CUR operations (hundreds over several seconds) overwhelm the firmware.

Add the device to the UVC driver table with:

- UVC_QUIRK_CTRL_THROTTLE: rate-limit SET_CUR (50ms interval) and skip error-code queries after EPIPE to prevent crash trigger #2.

- UVC_QUIRK_DISABLE_AUTOSUSPEND: prevent USB autosuspend transitions that trigger crash #1. Same approach as Insta360 Link.

- UVC_QUIRK_NO_RESET_RESUME: avoid the fragile reset-during-resume path. Same approach as Logitech Rally Bar.

---
 drivers/media/usb/uvc/uvc_driver.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +17 -0
index b0ca81d92..e8b4de942 100644
@@ -2920,6 +2920,23 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= (kernel_ulong_t)&uvc_quirk_probe_minmax },
+
+	/*
+	 * Razer Kiyo Pro -- firmware crashes under rapid control transfers
+	 * and on LPM/autosuspend resume, cascading into xHCI controller
+	 * death that disconnects all USB devices on the bus.
+	 */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x1532,
+	  .idProduct		= 0x0e05,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= 0,
+	  .driver_info		= UVC_INFO_QUIRK(UVC_QUIRK_CTRL_THROTTLE
+					| UVC_QUIRK_DISABLE_AUTOSUSPEND
+					| UVC_QUIRK_NO_RESET_RESUME) },
+
 	/* Kurokesu C1 PRO */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.43.0