If OHCI is runtime suspended, we can currently get an "imprecise
external abort" on reboot with ohci-platform loaded when PM runtime
is implemented for the SoC.

Let's fix this by implementing ohci_platform_shutdown with PM runtime
calls clocking the hardware before calling hcd->driver->shutdown.

Fixes: 0aa0b93e7af6 ("usb: host: ohci-platform: Add basic runtime PM support")
Signed-off-by: Tony Lindgren <[email protected]>
---
 drivers/usb/host/ohci-platform.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -240,6 +240,22 @@ static int ohci_platform_probe(struct platform_device *dev)
        return err;
 }
 
+static void ohci_platform_shutdown(struct platform_device *pdev)
+{
+       struct usb_hcd *hcd = platform_get_drvdata(pdev);
+       int err;
+
+       err = pm_runtime_get_sync(&pdev->dev);
+       if (err < 0)
+               pm_runtime_put_noidle(&pdev->dev);
+
+       if (hcd->driver->shutdown)
+               hcd->driver->shutdown(hcd);
+
+       if (!err)
+               pm_runtime_put_sync(&pdev->dev);
+}
+
 static int ohci_platform_remove(struct platform_device *dev)
 {
        struct usb_hcd *hcd = platform_get_drvdata(dev);
@@ -326,7 +342,7 @@ static struct platform_driver ohci_platform_driver = {
        .id_table       = ohci_platform_table,
        .probe          = ohci_platform_probe,
        .remove         = ohci_platform_remove,
-       .shutdown       = usb_hcd_platform_shutdown,
+       .shutdown       = ohci_platform_shutdown,
        .driver         = {
                .name   = "ohci-platform",
                .pm     = &ohci_platform_pm_ops,
-- 
2.21.0

Reply via email to