]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
UBUNTU: SAUCE: USB: core: Attempt power cycle port when it's in eSS.Disabled state
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Thu, 5 Dec 2019 17:05:27 +0000 (01:05 +0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Tue, 2 Nov 2021 07:24:48 +0000 (08:24 +0100)
BugLink: https://bugs.launchpad.net/bugs/1855312
On Dell TB16, Realtek USB ethernet (r8152) connects to an SMSC hub which
then connects to ASMedia xHCI's root hub:

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/7p, 5000M
            |__ Port 2: Dev 3, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 002: ID 0424:5537 Standard Microsystems Corp. USB5537B
Bus 004 Device 003: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter

The SMSC hub may disconnect after system resume from suspend. When this
happens, the reset resume attempt fails, and the last resort to disable
the port and see something comes up later, also fails.

When the issue occurs, the link state stays in eSS.Disabled state
despite the warm reset attempts. Accoding to spec this can be caused by
invalid VBus, after some expiremets, the SMSC hub can be brought back
after a powercycle.

So let's power cycle the port at the end of reset resume attempt, if
it's in eSS.Disabled state.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/usb/core/hub.c

index f81654294460e558df0c01ad1859e78c388954e8..a9a04ea967019c7ce0819b8e0dcb54aacad7c5a1 100644 (file)
@@ -2829,6 +2829,18 @@ static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
                || link_state == USB_SS_PORT_LS_COMP_MOD;
 }
 
+static bool hub_port_power_cycle_required(struct usb_hub *hub, int port1,
+               u16 portstatus)
+{
+       u16 link_state;
+
+       if (!hub_is_superspeed(hub->hdev))
+               return false;
+
+       link_state = portstatus & USB_PORT_STAT_LINK_STATE;
+       return link_state == USB_SS_PORT_LS_SS_DISABLED;
+}
+
 static void hub_port_power_cycle(struct usb_hub *hub, int port1)
 {
        struct usb_port *port_dev = hub->ports[port1  - 1];
@@ -3721,6 +3733,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
        if (status < 0) {
                dev_dbg(&udev->dev, "can't resume, status %d\n", status);
                hub_port_logical_disconnect(hub, port1);
+               if (hub_port_power_cycle_required(hub, port1, portstatus)) {
+                       dev_dbg(&udev->dev, "device in disabled state, attempt power cycle\n");
+                       hub_port_power_cycle(hub, port1);
+               }
        } else  {
                /* Try to enable USB2 hardware LPM */
                usb_enable_usb2_hardware_lpm(udev);