pastebin

Paste #511198: Untitled ASCII paste by 90.88.35.205

Author: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
Date:   Tue Oct 9 17:12:47 2018 +0200

    usb: host: xhci: add NO_ASYNC_SUSPEND xhci quirk
    
    Some host controllers need to suspend in a synchronous way, otherwise
    suspend operations will fail (probably because of a register access
    once the clocks are disabled). Prevent asyncronous suspend for the
    mvebu xHCI HC by adding a NO_ASYNC_SUSPEND quirk.
    
    With this change, S2RAM works on the Espressobin (A3720) even with USB
    devices plugged into the USB host.
    
    Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>

diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 60651a50770f..3af37eeb00f1 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -78,6 +78,13 @@ int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
+       /*
+        * Suspend must be done synchronously otherwise a race happens and the
+        * suspend hangs indefinitely (like if a register was accessed after
+        * disabling the clocks).
+        */
+       xhci->quirks |= XHCI_NO_ASYNC_SUSPEND;
+
        /* Without reset on resume, the HC won't work at all */
        xhci->quirks |= XHCI_RESET_ON_RESUME;
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 9eaefd9b3217..f58b74d9be56 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -326,7 +326,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
        if (ret)
                goto dealloc_usb2_hcd;
 
-       device_enable_async_suspend(&pdev->dev);
+       if (!(xhci->quirks & XHCI_NO_ASYNC_SUSPEND))
+               device_enable_async_suspend(&pdev->dev);
+
        pm_runtime_put_noidle(&pdev->dev);
 
        /*
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index bf0b3692dc9a..89e9cfd6cac8 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1849,6 +1849,7 @@ struct xhci_hcd {
 #define XHCI_INTEL_USB_ROLE_SW BIT_ULL(31)
 #define XHCI_ZERO_64B_REGS     BIT_ULL(32)
 #define XHCI_DEFAULT_PM_RUNTIME_ALLOW  BIT_ULL(33)
+#define XHCI_NO_ASYNC_SUSPEND  BIT_ULL(34)
 
        unsigned int            num_active_eps;
        unsigned int            limit_active_eps;

Private
Wrap long lines

1 + 4 =