]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xhci: Prevent runtime pm from autosuspending during initialization
authorMathias Nyman <mathias.nyman@linux.intel.com>
Mon, 3 Mar 2014 17:30:17 +0000 (19:30 +0200)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Thu, 6 Mar 2014 21:46:55 +0000 (13:46 -0800)
xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
to register its usb-2 bus, and then continue to manually register the
usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
might thus trigger a runtime suspend before the usb-3 bus is ready.

Prevent the runtime suspend by increasing the usage count in the
beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
ready.

xhci-platform driver is not using usb_hcd_pci_probe to set up
busses and should not need to have it's usage count increased during probe.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@vger.kernel.org
drivers/usb/host/xhci-pci.c

index cbf0c5cffc925cf3bae40e110616fe26b527b46d..47390e369cd402f776c20bbb35b4c37223f04057 100644 (file)
@@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        struct usb_hcd *hcd;
 
        driver = (struct hc_driver *)id->driver_data;
+
+       /* Prevent runtime suspending between USB-2 and USB-3 initialization */
+       pm_runtime_get_noresume(&dev->dev);
+
        /* Register the USB 2.0 roothub.
         * FIXME: USB core must know to register the USB 2.0 roothub first.
         * This is sort of silly, because we could just set the HCD driver flags
@@ -199,7 +203,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        retval = usb_hcd_pci_probe(dev, id);
 
        if (retval)
-               return retval;
+               goto put_runtime_pm;
 
        /* USB 2.0 roothub is stored in the PCI device now. */
        hcd = dev_get_drvdata(&dev->dev);
@@ -225,12 +229,17 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
                xhci->shared_hcd->can_do_streams = 1;
 
+       /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
+       pm_runtime_put_noidle(&dev->dev);
+
        return 0;
 
 put_usb3_hcd:
        usb_put_hcd(xhci->shared_hcd);
 dealloc_usb2_hcd:
        usb_hcd_pci_remove(dev);
+put_runtime_pm:
+       pm_runtime_put_noidle(&dev->dev);
        return retval;
 }