From: William wu Date: Wed, 19 Oct 2016 11:53:53 +0000 (+0800) Subject: CHROMIUM: xhci: do shutdown only hcd is registered X-Git-Tag: firefly_0821_release~1337 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=33e3a9340d91b25fc9adc7493bce03d34b3ce9ac;p=firefly-linux-kernel-4.4.55.git CHROMIUM: xhci: do shutdown only hcd is registered 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 Reviewed-on: https://chromium-review.googlesource.com/401120 Commit-Ready: Guenter Roeck Tested-by: Guenter Roeck Reviewed-by: Guenter Roeck --- diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4019b7335aac..0b48f7d97ddf 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -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));