From 1f35d62f3cdbcbcdcd8142842611a7cb54701f3c Mon Sep 17 00:00:00 2001 From: William wu Date: Wed, 19 Oct 2016 19:53:53 +0800 Subject: [PATCH] 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 --- drivers/usb/host/xhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 56ee2884df25..7dea1fdde11e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -774,6 +774,9 @@ static 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.sysdev));