From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 355CC376481 for ; Mon, 4 May 2026 09:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777886175; cv=none; b=agXUnuMYs0aOHuofjNrKZz6LjNp8iHnhQu5wAUx37pQAsE5oCuXooxqCb/fNODeFHXC0bfS2MhFDBKPjotd7K4+fNHEw0r8AbRonbRR5nhOyGLDMiK0wCC4XPzKy6kO2fAjzKg/vK3jVGNMP0cdLCtb+UGkn0RYW1M9EmSXi0X0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777886175; c=relaxed/simple; bh=E2/0/3HZlF6L8ECZLIYbqr1RiP5uPZYK7csbvS2Zlkg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tU+xRwhzuoLY95px2bMlaX125NDUeLNsKpSSbim23hPGM2GcwCFtdB7LvEhJ1pWcarG0hrtEOck8AQWs0Y1Lk2HXLx6IDymN8Lb9aTycuAheLgiL7fVhmlu7ZlfhaYg/D1zMyuknLrBM8Eyu/Z0nVhwF821hYmnEiOpXe7h4NiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VW378ljQ; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VW378ljQ" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-43d77f6092eso2246095f8f.2 for ; Mon, 04 May 2026 02:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777886171; x=1778490971; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=shwVhb77dPxS4n2JZIDKWi0MH3W6ZtPKvDbHq7WuSc0=; b=VW378ljQFtJFndtwpgqqwJa3pg/tS/8wsf7hXoZz0nOixIR/jCgO16zt9+y/t5TN20 I9wn5oGMv8oTe1Z5FWzTfuernXj/XQhv2rGHeKkl0BshvG7fI557DZyRs25WI6q6ShIn 8T6IGE2YjDYOqEaJncMz0sptQI1a16FbTiuxMY93KcaWfSAXDet0svQQvJwqpyntb/14 XnuqnmjsYJC/mCXBOEnnJ0ZAXg2uU37aSGgO0TDGfKq/01sWvW6Ey17Al7b4mKSC0X1s XNYJZx4myWDmDTZlDVU8CF7iBoTZYyNnRItr56ollyddAeYqmEcNfmue6Wtk0ilPxN8J SPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777886171; x=1778490971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=shwVhb77dPxS4n2JZIDKWi0MH3W6ZtPKvDbHq7WuSc0=; b=HGVt8sdtWasKPEOg8Yw18UFO0erw8wfwp/IfM36IdJKJrYaCiQVP/mM29VAqnVAhjt yiPo/NnPCshWQ94sETNkJg5OaN4CpQFIN5FhOJCNWhjA9BiUTkiw73uNSEl/Or+6vUNT AHkao0xtU/rIzM1KVJp+KfyflKmvNRK8DJyCbj7ECUoX0mTAyakflCnL7BYCMhj7cfjr qFADAiLwGmmL0G0kZKamdLoGIfIA/pDNllk0RB+y7sf81lm1/8xxKoBIXuxZy2qV0/BO ZcgV+3W+SSPjW7WyFxo47Cparlz2Yb5YWxOAYuy/073ToFL3+qkLdbZF4zyk08vlkqBq Wd2g== X-Forwarded-Encrypted: i=1; AFNElJ9/Lsk0q4T+dgMQUeRZe/2HSRwn/D07Jum964dKh8Qe1gEZ2uACPrxM/g8dGqRxaIJh7388P55N/AwUovI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+/dzFzkRNiOwK9jj4YmEu3NkhQHbByX6+ktOvH5neL2atZgHR SrO03xPiu6KRjdm6CNCv/A8h835FqlKdX251Kvdn4r+lSOZK4UAHflv+ X-Gm-Gg: AeBDieuFCAzSXCwsGAG2gxebac/J1XskyxpOCjxFdznWPXg8GfkhvQ+HrVnOQ1WOEHp VLT+kZJgKev/WtsbNe6HvOyFN76BVijBt7AaLued5OAF95C62+n4kcHtg8ZT10kSmB3ZXufIyzg BtlEF2BNprldPUorA/pBbf8q6uwyKWz4E4+3AlWn2MRVkyn2NBf0jMC+NrTcezaR/htQ/DThBdN l1A3OzQYQ0wBKF/QKfOX3kjFQpcDh858KRwVOsFe4f24cGXUC6oHzz6pBqdG+Kzyyb1axhO1/CN EmzFzOnfytn//PQxH6xKZji/q1QQQiIm4Zv3JHYmzY9E46bsbG3Wq77zBIQgsW1ZWMsR49tu7j8 Eqwf2LhWKuBU9sieaFka60Llno4Y1VH+eB+9lZspwnfb3yUfgHu4kEMNIvnNSmE7gThRJiT9A/6 jp/xEo9N96hURma93W/fVc3V+AuxsJePIqgKK8DSDoaaE0gw== X-Received: by 2002:a5d:5c89:0:b0:43d:77a8:3baf with SMTP id ffacd0b85a97d-44bb5b4cbdamr14418493f8f.32.1777886171160; Mon, 04 May 2026 02:16:11 -0700 (PDT) Received: from foxbook (bgt227.neoplus.adsl.tpnet.pl. [83.28.83.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a981dee90sm23981273f8f.22.2026.05.04.02.16.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 04 May 2026 02:16:10 -0700 (PDT) Date: Mon, 4 May 2026 11:16:06 +0200 From: Michal Pecio To: Greg KH , Alan Stern , Mathias Nyman Cc: "Xuetao (kirin)" , , , Subject: [PATCH v2 2/3] usb: core: Fix up Interrupt IN endpoints with bogus wBytesPerInterval Message-ID: <20260504111606.3a312549.michal.pecio@gmail.com> In-Reply-To: <20260504111353.55ba2530.michal.pecio@gmail.com> References: <20260504111353.55ba2530.michal.pecio@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Tao Xue found that some common devices violate USB3 section 9.6.7 by reporting wBytesPerInterval lower than the size of packets they actually send. I confirmed that AX88179 may set it to 0 and RTL8153 CDC configuration sets it to 8 but sends both 8 and 16 byte packets: S Ii:11:007:3 -115:128 16 < C Ii:11:007:3 0:128 8 = a1000000 01000000 S Ii:11:007:3 -115:128 16 < C Ii:11:007:3 0:128 16 = a12a0000 01000800 00000000 00000000 Most xHCI host controllers neglect interrupt bandwidth reservations and let such devices exceed theirs, some fail the URB with EOVERFLOW. Assume that wBytesPerInterval lower than wMaxPacketSize is bogus and increase it to the worst case maximum on interrupt IN endpoints. This solves xHCI problems and appears to have no other effect. Interrupt transfers are not limited to one interval and drivers submit URBs of class defined size without looking at wBytesPerInterval. Any multi- interval transfer is considered terminated by a packet shorter than wMaxPacketSize regardless of wBytesPerInterval - see USB3 8.10.3. Stay in spec on OUT endpoints and isochronous. No buggy devices are known and we don't want to risk sending more data than the device is prepared to handle or confusing isoc drivers regarding altsetting capacities guaranteed by the device itself. And don't complain when wMaxPacketSize <= wBytesPerInterval < wMaxPacketSize * (bMaxBurst+1) because enabling this seems to be the exact goal of the spec. Reported-and-tested-by: Tao Xue Closes: https://lore.kernel.org/linux-usb/20260402021400.28853-1-xuetao09@huawei.com/ Cc: stable@vger.kernel.org Signed-off-by: Michal Pecio --- v2: - added reporter's tested-by - use usb_endpoint_is_int_in() as suggested by Alan drivers/usb/core/config.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 6a1fd967e0a6..74945cd30cd2 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -191,7 +191,14 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno, (desc->bMaxBurst + 1); else max_tx = 999999; - if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) { + /* + * wBytesPerInterval > max_tx is bogus, but USB3 spec doesn't forbid the opposite. + * Experience shows that wBytesPerInterval < wMaxPacketSize on common interrupt IN + * endpoints is usually bogus too, and recent HCs enforce interrupt BW limits. + */ + if (le16_to_cpu(desc->wBytesPerInterval) > max_tx || + (le16_to_cpu(desc->wBytesPerInterval) < usb_endpoint_maxp(&ep->desc) && + usb_endpoint_is_int_in(&ep->desc))) { dev_notice(ddev, "%s endpoint with wBytesPerInterval of %d in " "config %d interface %d altsetting %d ep %d: " "setting to %d\n", -- 2.48.1