Skip to contentSkip to conversation

usb: host: ohci-platform: Implement ohci_platform_shutdown

PATCH Tony Lindgren 1 participant 1 message Mar 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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")
---
 drivers/usb/host/ohci-platform.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/usb/host/ohci-platform.c +17 -1
@@ -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,