Skip to content
  • Shantur Rathore's avatar
    common: usb-hub: Reset USB 3.0 hubs only · 08e2cd6c
    Shantur Rathore authored and Marek Vasut's avatar Marek Vasut committed
    Additional testing of the changes introduced in commit 33e06dcb "common:
    usb-hub: Reset hub port before scanning") revealed that some USB 2.0 and 3.0
    flash drives didn't work in U-Boot on some Allwinner SoCs that support USB
    2.0 interfaces only.  More precisely, some of the tested USB 2.0 and 3.0
    flash drives failed to be detected and work on an OrangePi Zero 3, based on
    the Allwinner H616 SoC that supports USB 2.0 only, while the same USB flash
    drives worked just fine on a Pine64 H64, based on the Allwinner H6 SoC that
    supports both USB 2.0 and USB 3.0 interfaces.
    
    The USB ID of the above-mentioned USB 3.0 flash drive that failed to work is
    1f75:0917 (Innostor Technology Corporation IS917 Mass storage), it is 32 GB
    in size and sold under the PNY brand.  The mentioned USB 2.0 drive is some
    inexpensive no-name drive with an invalid USB ID.
    
    Resetting USB 3.0 hubs only, which this patch introduces to the USB hub
    resets, has been tested to work as expected, resolving the identified issues
    on the Allwinner H616, while not introducing any new issues on other tested
    Allwinner SoCs.  Thus, let's fix it that way.
    
    According to the USB 3.0 specification, resetting a USB 3.0 port is required
    when an attached USB device transitions between different states, such as
    when it resumes from suspend.  Though, the Linux kernel performs additional
    USB 3.0 port resets upon initial USB device attachment, as visible in commit
    07194ab7be63 ("USB: Reset USB 3.0 devices on (re)discovery") in the kernel
    source, to ensure proper state of the USB 3.0 hub port and proper USB mode
    negotiation during the initial USB device attachment and enumeration.
    
    These additional types of USB port resets don't exist for USB 2.0 hubs,
    according the USB 2.0 specification.  The resets seem to be added to the USB
    3.0 specification as part of the port and device mode negotiation.
    
    The Linux kernel resets USB 3.0 (i.e. SuperSpeed) hubs only, as visible in
    commit 10d674a82e55 ("USB: When hot reset for USB3 fails, try warm reset.")
    in the kernel source.  The check for SuperSpeed hubs is performed in a way
    that also applies to newer SuperSpeed Plus (USB 3.1 or 3.2) hubs as well,
    which hopefully makes it future proof.
    
    Fixes: 33e06dcb ("common: usb-hub: Reset hub port before scanning")
    
    Link:
    https://lore.kernel.org/u-boot/20240207102327.35125-1-i@shantur.com/T/#u
    Link:
    https://lore.kernel.org/u-boot/20240201164604.13315fa6@donnerap.manchester.arm.com/T/#u
    
    
    
    Signed-off-by: default avatarShantur Rathore <i@shantur.com>
    Helped-by: default avatarDragan Simic <dsimic@manjaro.org>
    Tested-by: default avatarAndre Przywara <andre.przywara@arm.com>
    Reviewed-by: default avatarDragan Simic <dsimic@manjaro.org>
    Reviewed-by: default avatarMarek Vasut <marex@denx.de>
    08e2cd6c