CHROMIUM: xhci: do shutdown only hcd is registered
authorWilliam wu <wulf@rock-chips.com>
Wed, 19 Oct 2016 11:53:53 +0000 (19:53 +0800)
committerWu Liang feng <wulf@rock-chips.com>
Tue, 1 Nov 2016 03:32:35 +0000 (11:32 +0800)
On some sepcial platforms (e.g. rk3399 platform), they will call
usb_remove_hcd() to remove xhci hcd if no device connected, and
also call xhci_stop() to halt and reset xhci. So we don't need to
do the same thing in shutdown if hcd has been unregistered.

In addition to remove hcd, rk3399 platform will disable xhci power
domain in runtime suspend, if we try to access xhci registers in
shutdown, it might cause kernel crash or unexpected behavior.

BUG=chrome-os-partner:59111
TEST=reboot the system

Change-Id: I7ecfce068211ff1c4a884fc4a8a54ca5b84c1c09
Signed-off-by: William wu <wulf@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/401120
Commit-Ready: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
drivers/usb/host/xhci.c

index 4019b7335aacea101964776ee82fb7a65ec34e72..0b48f7d97ddf433aba70912fe766b1d93d7809e1 100644 (file)
@@ -741,6 +741,9 @@ void xhci_shutdown(struct usb_hcd *hcd)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
+       if (!hcd->rh_registered)
+               return;
+
        if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
                usb_disable_xhci_ports(to_pci_dev(hcd->self.controller));