linux-stable/drivers/usb
Alan Stern 8cded8d953 USB: core: Fix oversight in SuperSpeed initialization
commit 59cf445754 upstream.

Commit 85d07c5562 ("USB: core: Unite old scheme and new scheme
descriptor reads") altered the way USB devices are enumerated
following detection, and in the process it messed up the
initialization of SuperSpeed (or faster) devices:

[   31.650759] usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 2 using xhci_hcd
[   31.663107] usb 2-1: device descriptor read/8, error -71
[   31.952697] usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 3 using xhci_hcd
[   31.965122] usb 2-1: device descriptor read/8, error -71
[   32.080991] usb usb2-port1: attempt power cycle
...

The problem was caused by the commit forgetting that in SuperSpeed or
faster devices, the device descriptor uses a logarithmic encoding of
the bMaxPacketSize0 value.  (For some reason I thought the 255 case in
the switch statement was meant for these devices, but it isn't -- it
was meant for Wireless USB and is no longer needed.)

We can fix the oversight by testing for buf->bMaxPacketSize0 = 9
(meaning 512, the actual maxpacket size for ep0 on all SuperSpeed
devices) and straightening out the logic that checks and adjusts our
initial guesses of the maxpacket value.

Reported-and-tested-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Closes: https://lore.kernel.org/linux-usb/20230810002257.nadxmfmrobkaxgnz@synopsys.com/
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Fixes: 85d07c5562 ("USB: core: Unite old scheme and new scheme descriptor reads")
Link: https://lore.kernel.org/r/8809e6c5-59d5-4d2d-ac8f-6d106658ad73@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-13 09:48:44 +02:00
..
atm
c67x00
cdns3 usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config 2023-08-03 10:26:04 +02:00
chipidea usb: chipidea: imx: improve logic if samsung,picophy-* parameter is 0 2023-09-06 21:25:30 +01:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-13 17:25:49 +09:00
common usb: common: usb-conn-gpio: Prevent bailing out if initial role is none 2023-08-16 18:32:21 +02:00
core USB: core: Fix oversight in SuperSpeed initialization 2023-09-13 09:48:44 +02:00
dwc2 usb: dwc2: Fix some error handling paths 2023-07-19 16:36:26 +02:00
dwc3 usb: dwc3: meson-g12a: do post init to fix broken usb after resumption 2023-09-06 21:25:30 +01:00
early usb: early: xhci-dbc: Use memcpy_and_pad() 2023-01-31 10:40:54 +01:00
fotg210 USB: fotg210: fix memory leak with using debugfs_lookup() 2023-02-06 13:46:42 +01:00
gadget USB: gadget: f_mass_storage: Fix unused variable warning 2023-09-13 09:48:31 +02:00
host xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-08-23 17:32:31 +02:00
image scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
isp1760
misc usb: misc: ehset: fix wrong if condition 2023-08-03 10:26:04 +02:00
mon driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
mtu3 usb: mtu3: add optional clock xhci_ck and frmcnt_ck 2023-04-20 11:17:05 +02:00
musb Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-19 16:36:36 +02:00
phy usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host() 2023-09-13 09:48:27 +02:00
renesas_usbhs usb: renesas_usbhs: drop of_match_ptr for ID table 2023-03-16 12:15:23 +01:00
roles Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-19 16:36:36 +02:00
serial USB: serial: option: add FOXCONN T99W368/T99W373 product 2023-09-06 21:25:30 +01:00
storage usb-storage: alauda: Fix uninit-value in alauda_check_media() 2023-08-16 18:32:21 +02:00
typec usb: typec: bus: verify partner exists in typec_altmode_attention 2023-09-13 09:48:43 +02:00
usbip Including fixes from bpf, netfilter and can. 2022-12-21 08:41:32 -08:00
Kconfig usb: move config USB_USS720 to usb's misc Kconfig 2023-03-29 10:34:08 +02:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
usb-skeleton.c