When we are removing HCD, the xhci_configure_endpoint may be timeout. To get rid of timeout, we'd better return before issue command. The related log message when removing HCD like below: [66.736633] usb 3-1: USB disconnect, device number 2 [66.737003] hub 3-1:1.0: hub_ext_port_status failed (err = -71) [66.737054] usb 3-1.1: USB disconnect, device number 3 [66.759910] xhci-hcd xhci-hcd.1.auto: remove, state 4 [66.765043] usb usb4: USB disconnect, device number 1 [66.770169] usb 4-1: USB disconnect, device number 2 [74.008294] xhci-hcd xhci-hcd.1.auto: Timeout while waiting for configure endpoint command [74.018737] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered [74.024446] xhci-hcd xhci-hcd.1.auto: remove, state 1 [74.029594] usb usb3: USB disconnect, device number 1 [74.062310] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered Signed-off-by: Peter Chen <peter.chen@xxxxxxx> --- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0420eefa647a..3113938063fd 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -2698,7 +2698,8 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, spin_lock_irqsave(&xhci->lock, flags); - if (xhci->xhc_state & XHCI_STATE_DYING) { + if (xhci->xhc_state & XHCI_STATE_DYING || + xhci->xhc_state & XHCI_STATE_REMOVING) { spin_unlock_irqrestore(&xhci->lock, flags); return -ESHUTDOWN; } -- 2.14.1