aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2016-04-08 09:25:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-04-13 14:55:56 -0400
commit98d74f9ceaefc2b6c4a6440050163a83be0abede (patch)
treee7054f3f43ddbca44009d24fda16cf2481aa84c1
parent71504062a7c34838c3fccd92c447f399d3cb5797 (diff)
xhci: fix 10 second timeout on removal of PCI hotpluggable xhci controllers
PCI hotpluggable xhci controllers such as some Alpine Ridge solutions will remove the xhci controller from the PCI bus when the last USB device is disconnected. Add a flag to indicate that the host is being removed to avoid queueing configure_endpoint commands for the dropped endpoints. For PCI hotplugged controllers this will prevent 5 second command timeouts For static xhci controllers the configure_endpoint command is not needed in the removal case as everything will be returned, freed, and the controller is reset. For now the flag is only set for PCI connected host controllers. Cc: <stable@vger.kernel.org> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/xhci-pci.c1
-rw-r--r--drivers/usb/host/xhci-ring.c3
-rw-r--r--drivers/usb/host/xhci.c8
-rw-r--r--drivers/usb/host/xhci.h1
4 files changed, 9 insertions, 4 deletions
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 071b34ae9c4e..48672fac7ff3 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -304,6 +304,7 @@ static void xhci_pci_remove(struct pci_dev *dev)
304 struct xhci_hcd *xhci; 304 struct xhci_hcd *xhci;
305 305
306 xhci = hcd_to_xhci(pci_get_drvdata(dev)); 306 xhci = hcd_to_xhci(pci_get_drvdata(dev));
307 xhci->xhc_state |= XHCI_STATE_REMOVING;
307 if (xhci->shared_hcd) { 308 if (xhci->shared_hcd) {
308 usb_remove_hcd(xhci->shared_hcd); 309 usb_remove_hcd(xhci->shared_hcd);
309 usb_put_hcd(xhci->shared_hcd); 310 usb_put_hcd(xhci->shared_hcd);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7cf66212ceae..99b4ff42f7a0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -4004,7 +4004,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
4004 int reserved_trbs = xhci->cmd_ring_reserved_trbs; 4004 int reserved_trbs = xhci->cmd_ring_reserved_trbs;
4005 int ret; 4005 int ret;
4006 4006
4007 if (xhci->xhc_state) { 4007 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
4008 (xhci->xhc_state & XHCI_STATE_HALTED)) {
4008 xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n"); 4009 xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
4009 return -ESHUTDOWN; 4010 return -ESHUTDOWN;
4010 } 4011 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 9283d3331b59..9e71c96ad74a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -147,7 +147,8 @@ static int xhci_start(struct xhci_hcd *xhci)
147 "waited %u microseconds.\n", 147 "waited %u microseconds.\n",
148 XHCI_MAX_HALT_USEC); 148 XHCI_MAX_HALT_USEC);
149 if (!ret) 149 if (!ret)
150 xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING); 150 /* clear state flags. Including dying, halted or removing */
151 xhci->xhc_state = 0;
151 152
152 return ret; 153 return ret;
153} 154}
@@ -2773,7 +2774,8 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2773 if (ret <= 0) 2774 if (ret <= 0)
2774 return ret; 2775 return ret;
2775 xhci = hcd_to_xhci(hcd); 2776 xhci = hcd_to_xhci(hcd);
2776 if (xhci->xhc_state & XHCI_STATE_DYING) 2777 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
2778 (xhci->xhc_state & XHCI_STATE_REMOVING))
2777 return -ENODEV; 2779 return -ENODEV;
2778 2780
2779 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); 2781 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
@@ -3820,7 +3822,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3820 3822
3821 mutex_lock(&xhci->mutex); 3823 mutex_lock(&xhci->mutex);
3822 3824
3823 if (xhci->xhc_state) /* dying or halted */ 3825 if (xhci->xhc_state) /* dying, removing or halted */
3824 goto out; 3826 goto out;
3825 3827
3826 if (!udev->slot_id) { 3828 if (!udev->slot_id) {
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 70f215c20b2b..6c629c97f8ad 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1605,6 +1605,7 @@ struct xhci_hcd {
1605 */ 1605 */
1606#define XHCI_STATE_DYING (1 << 0) 1606#define XHCI_STATE_DYING (1 << 0)
1607#define XHCI_STATE_HALTED (1 << 1) 1607#define XHCI_STATE_HALTED (1 << 1)
1608#define XHCI_STATE_REMOVING (1 << 2)
1608 /* Statistics */ 1609 /* Statistics */
1609 int error_bitmask; 1610 int error_bitmask;
1610 unsigned int quirks; 1611 unsigned int quirks;