]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
xhci: prevent bus suspend if a roothub port detected a over-current condition
authorMathias Nyman <mathias.nyman@linux.intel.com>
Tue, 21 Apr 2020 14:08:21 +0000 (17:08 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 14 May 2020 08:54:23 +0000 (10:54 +0200)
BugLink: https://bugs.launchpad.net/bugs/1877461
commit e9fb08d617bfae5471d902112667d0eeb9dee3c4 upstream.

Suspending the bus and host controller while a port is in a over-current
condition may halt the host.
Also keep the roothub running if over-current is active.

Cc: <stable@vger.kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200421140822.28233-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/host/xhci-hub.c

index 4ff65c2f17ba2a7d2340f841717ada11f0a2b75d..5b2fae5a5d8ec8206aff1dbd528a43abf686f93e 100644 (file)
@@ -1460,6 +1460,8 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
                }
                if ((temp & PORT_RC))
                        reset_change = true;
+               if (temp & PORT_OC)
+                       status = 1;
        }
        if (!status && !reset_change) {
                xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
@@ -1522,6 +1524,13 @@ retry:
                                 port_index);
                        goto retry;
                }
+               /* bail out if port detected a over-current condition */
+               if (t1 & PORT_OC) {
+                       bus_state->bus_suspended = 0;
+                       spin_unlock_irqrestore(&xhci->lock, flags);
+                       xhci_dbg(xhci, "Bus suspend bailout, port over-current detected\n");
+                       return -EBUSY;
+               }
                /* suspend ports in U0, or bail out for new connect changes */
                if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) {
                        if ((t1 & PORT_CSC) && wake_enabled) {