From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF55155389 for ; Fri, 10 Apr 2026 00:28:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775780940; cv=none; b=c8el6/qHiG3hGYb/ctCH5gy+/TIrAEqk4KjHTyX9R1DrOMhNz4i84tPCMENGz89VShUdkHYpbXsQoyVWR9XtrNhP7MR80976uTpy7Fgn4dqPQU0bU1qOUpXllV4a9nhgNY6Yy/osE7rJHUNIlAOGMNOP7v4hw0DDmR3WaTckgz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775780940; c=relaxed/simple; bh=ax/QlneOJPW/C07fAtozxCuOB9NREghfagK8LVCvkVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E5RRKi53Hyndx3NUjFCxFtXttR1d7it+shlGcP8DeMyvV6ay26AbG3VPhpSV6zAVPrV4VpY3EgfKU1yGR2cqqjVpiXzUPSreJvdDH68gmRnrBoL83cii4AY4PyfDd4na5akndr5N6M/u5/Yo+ScDXoC3HuwvdLFJBhHxNiygLdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=jphein.com; spf=pass smtp.mailfrom=jphein.com; dkim=pass (2048-bit key) header.d=jphein.com header.i=@jphein.com header.b=DEvqTFaW; arc=none smtp.client-ip=74.125.82.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=jphein.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jphein.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jphein.com header.i=@jphein.com header.b="DEvqTFaW" Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-1273349c56bso2052433c88.0 for ; Thu, 09 Apr 2026 17:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jphein.com; s=google; t=1775780938; x=1776385738; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zu3oR09vRQkDFwrDcL3IwsvCJguXM5kG+ZQlWAVYGNg=; b=DEvqTFaWvZSWx9/AnkCJ7w0oCofrVFwpksgrkZxqNhzi/XBuz8WxqOuF4rHkLtuUw9 ZPZyv3PAli4R8ATOf5hTMnOAfmjrIZtef6oFEczhC8SXZA/gfjSyLu8Wi7hh7oJWTqoQ AaTGucFhs8ulsjfzpStWgCWn/WnSccDO0W3VXslryWFbJta8wi7rETdVL+FKbTCSXQHg Ad3pL/Rb/f6W1CvgFkgb+MPNzNRE07xl82h6oIsJj5j+U3cRHBBdbCjJ6O6oVwh1NoxC rVGZzxBzitMiRRwSIFV7S0vDCJy0x6hvDaBNjtGvU6XEaL+ajL4kOXMzZ5uJh/fe5I0t /O9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775780938; x=1776385738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Zu3oR09vRQkDFwrDcL3IwsvCJguXM5kG+ZQlWAVYGNg=; b=TDusz4ZI8Qfh8St06jx5E25TrFS4g9nnb5A0Yv5tujmJfPjUaN2aWP7OXNIRKJL31p U9PS8kP+vtoMLvZ5dbU9hrCDzNELylyIGvSfbhrSnSIaIxNeyQX+dvBMTer9lolo5dqx pFFwr2fJoMQx/VHTPySgg7zYTEkYyeDfwyy0MKmBKRKkNylw+oHU7YPHbpXODdx51dAo Bf4wzw1eGF+BDXIKP/+rtHTkHLh7RowiSv1AKwbq/PDKssoWq1hoq2Iv48bUHD7v0usd TFilY5fMstujXeW4njugGMc2ldoVUKSFF2kUeyw8Wgc+JJHFlHLVU1ix34lqHx36SwE7 R5gg== X-Forwarded-Encrypted: i=1; AJvYcCVUveFncPSSTrDGm8C5e8GLbXkLA0z4CeJOw+7Q7riYXnevO/Yq8HzJrrq/vADYY1NGgcUFmuqhTmo=@vger.kernel.org X-Gm-Message-State: AOJu0YyngxfBDaW/Abie06Y2hkvDui/xwzUXowcJOyomSjamue0sGRL1 1MVneCS5L3jxfXWLdXaIMekDmkWAR3JVCDvN4zSnXpFFSycZpGluO1AjxxDuAeYU+g== X-Gm-Gg: AeBDietsRbLal9d9adK33YYmYsDk+rU5B/sjXMr/Z62RnIUx+9A5YZZclulh7EWUkRz r10tJcfVCpXZ1NRKCSzEmVZEP0uOlWOK5BScCNkzDIv5vNUKhSGakjW2uDOpm0xlQQG0q+Ysz4D tGoLhd2g7o4Ys01fo9T5SMVqooGGt3iTCB74lYClDHBAhOSO6mPMFcuJyAKTVxKHEyuXw8rOlvu Z2Vd2sNl1opebC3Parinect8V9Z4ksVOhFFIY38Ayp04zI/cJ2lwQxPKqxkV8inTckC51A/O5gZ RcBDzLg+1qWDex+68gWbXd7aYOmTRxV4WHfSDqYCvPaJ7ngCJ+uVEZ6R+DE3epzI+rNvNer45yM 2rXLHSTsppv8d+ByjrgW7JHkRCNOYqzz/ynCzh02Xr5MQyzxx++gwAnslHvNq3lYRoRgn9+u5ep KrbYcYRHY7aqZwY4ZMzU3sb83hF0kjF8D6YzpeWhWMn5b9XunIeIjxrStz5BVFh1KRHe+dQ/d8x 5k/oAUER7vg7DA2tlB/gC/GLJrxr+cLZqDW1A== X-Received: by 2002:a05:7023:b0f:b0:128:d5bd:357f with SMTP id a92af1059eb24-12c34f09283mr660067c88.30.1775780937794; Thu, 09 Apr 2026 17:28:57 -0700 (PDT) Received: from katana.dragonfish-mirfak.ts.net ([108.74.4.89]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c346eb162sm1400680c88.11.2026.04.09.17.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 17:28:57 -0700 (PDT) From: JP Hein To: Laurent Pinchart , Hans de Goede , Greg Kroah-Hartman Cc: linux-media@vger.kernel.org, linux-usb@vger.kernel.org, Ricardo Ribalda , Michal Pecio , JP Hein Subject: [PATCH v7 1/2] media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile USB firmware Date: Thu, 9 Apr 2026 17:28:30 -0700 Message-ID: <20260410002831.1046407-2-jp@jphein.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260410002831.1046407-1-jp@jphein.com> References: <20260331003806.212565-1-jp@jphein.com> <20260410002831.1046407-1-jp@jphein.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some UVC devices have firmware that locks up under sustained rapid USB control transfers, crashing the xHCI host controller and taking all USB devices on the bus with it. The Razer Kiyo Pro (1532:0e05) is the first known example: approximately 25 rapid consecutive control transfers cause the firmware to stall an endpoint. Add UVC_QUIRK_CTRL_THROTTLE which rate-limits all USB control transfers to 50ms intervals in __uvc_query_ctrl(), the lowest-level UVC control transfer function, ensuring all callers are throttled including uvc_set_video_ctrl() which bypasses uvc_query_ctrl(). The 50ms interval was determined experimentally: the device is stable at this rate under sustained operation, while shorter intervals eventually trigger the firmware bug. Signed-off-by: JP Hein --- drivers/media/usb/uvc/uvc_video.c | 20 ++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index a5013a7..1d1206f 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -36,6 +36,26 @@ static int __uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, u8 type = USB_TYPE_CLASS | USB_RECIP_INTERFACE; unsigned int pipe; + /* + * Rate-limit control transfers for devices with fragile firmware. + * The Razer Kiyo Pro locks up under sustained rapid control + * transfers (hundreds without delay), crashing the xHCI controller. + * Throttle in this low-level function to cover all callers, + * including uvc_set_video_ctrl() which bypasses uvc_query_ctrl(). + */ + if (dev->quirks & UVC_QUIRK_CTRL_THROTTLE) { + unsigned long min_interval = msecs_to_jiffies(50); + + if (dev->last_ctrl_jiffies && + time_before(jiffies, + dev->last_ctrl_jiffies + min_interval)) { + unsigned long wait = dev->last_ctrl_jiffies + + min_interval - jiffies; + msleep(jiffies_to_msecs(wait)); + } + dev->last_ctrl_jiffies = jiffies; + } + pipe = (query & 0x80) ? usb_rcvctrlpipe(dev->udev, 0) : usb_sndctrlpipe(dev->udev, 0); type |= (query & 0x80) ? USB_DIR_IN : USB_DIR_OUT; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 757254f..31f2af5 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -78,6 +78,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 @@ -583,6 +584,8 @@ struct uvc_device { struct usb_interface *intf; unsigned long warnings; u32 quirks; + /* UVC control transfer throttling (UVC_QUIRK_CTRL_THROTTLE) */ + unsigned long last_ctrl_jiffies; int intfnum; char name[32]; -- 2.43.0