linux-stable/drivers/usb
Alan Stern 7e3ddbea87 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-19 12:22:53 +02:00
..
atm
c67x00
cdns3 usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config 2023-08-03 10:22:42 +02:00
chipidea usb: chipidea: imx: improve logic if samsung,picophy-* parameter is 0 2023-09-06 21:28:38 +01:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-24 17:36:52 +01:00
common usb: common: usb-conn-gpio: Prevent bailing out if initial role is none 2023-08-16 18:21:59 +02:00
core USB: core: Fix oversight in SuperSpeed initialization 2023-09-19 12:22:53 +02:00
dwc2 usb: dwc2: Fix some error handling paths 2023-07-23 13:47:21 +02:00
dwc3 usb: dwc3: meson-g12a: do post init to fix broken usb after resumption 2023-09-06 21:28:38 +01:00
early usb: early: xhci-dbc: Fix a potential out-of-bound memory access 2023-03-10 09:39:39 +01:00
gadget USB: gadget: f_mass_storage: Fix unused variable warning 2023-09-19 12:22:46 +02:00
host Revert "xhci: add quirk for host controllers that don't update endpoint DCS" 2023-08-03 10:22:43 +02:00
image
isp1760
misc USB: sisusbvga: Add endpoint checks 2023-05-30 13:55:31 +01:00
mon
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-23 13:47:25 +02:00
phy usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host() 2023-09-19 12:22:44 +02:00
renesas_usbhs
roles Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-23 13:47:25 +02:00
serial USB: serial: option: add FOXCONN T99W368/T99W373 product 2023-09-06 21:28:38 +01:00
storage usb-storage: alauda: Fix uninit-value in alauda_check_media() 2023-08-16 18:21:59 +02:00
typec usb: typec: bus: verify partner exists in typec_altmode_attention 2023-09-19 12:22:53 +02:00
usbip
Kconfig
Makefile
usb-skeleton.c