xhci: Rework how we handle unresponsive or hoptlug removed hosts
Introduce a new xhci_hc_died() function that takes care of handling pending commands and URBs if a host controller becomes unresponsive. This addresses issues on hotpluggable xhci controllers that disappear from the bus suddenly, often while the bus (PCI) remove function is still being processed. xhci_hc_died() sets a XHCI_STATUS_DYING flag to prevent new URBs and commands or to be queued. The flag also ensures xhci_hc_died() will give back pending commands and URBs once. Host is considered dead if register read returns 0xffffffff, or host fails to abort the command ring, or fails stopping an endpoint after trying for 5 seconds. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
fe190ed0d6
commit
d9f11ba9f1
@@ -1504,10 +1504,16 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
|
||||
if (!ep || !ep_ring)
|
||||
goto err_giveback;
|
||||
|
||||
/* If xHC is dead take it down and return ALL URBs in xhci_hc_died() */
|
||||
temp = readl(&xhci->op_regs->status);
|
||||
if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) {
|
||||
if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) {
|
||||
xhci_hc_died(xhci);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (xhci->xhc_state & XHCI_STATE_HALTED) {
|
||||
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
|
||||
"HW died, freeing TD.");
|
||||
"HC halted, freeing TD manually.");
|
||||
for (i = urb_priv->num_tds_done;
|
||||
i < urb_priv->num_tds;
|
||||
i++) {
|
||||
@@ -2598,6 +2604,12 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
|
||||
if (xhci->xhc_state & XHCI_STATE_DYING) {
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
return -ESHUTDOWN;
|
||||
}
|
||||
|
||||
virt_dev = xhci->devs[udev->slot_id];
|
||||
|
||||
ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
|
||||
|
Reference in New Issue
Block a user