From 89e628cc400d36657bd36e3ed0c9e6bc811d7b91 Mon Sep 17 00:00:00 2001 From: Pratham Pratap Date: Wed, 4 Nov 2020 19:45:33 +0530 Subject: [PATCH] usb: dwc3: Resume parent before resuming child device while in host mode Consider a scenario where a peripheral connected to the host gets runtime suspended because of no bus activity. When the device tries to enter suspend/deep sleep from this state and if it fails to suspend PM framework calls pm_resume of the suspended device. Currently xhci_plat_resume will call xhci_resume but it will fail since the parent (dwc3) is not resumed. Fix this by resuming glue driver and core by performing pm_runtime_resume on xhci-plat device. Change-Id: I71349fa88bce65fa9ec9bceb7c42ef79db763a84 Signed-off-by: Pratham Pratap --- drivers/usb/dwc3/core.c | 14 +++++--------- drivers/usb/host/xhci-plat.c | 7 +++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 97477c3dc244..903c4fa20308 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1997,12 +1997,13 @@ static int dwc3_resume(struct device *dev) /* Check if platform glue driver handling PM, if not then handle here */ if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0)) { /* - * If the core was in host mode during suspend, then set the - * runtime PM state as active to reflect actual state of device - * which is now out of LPM. This allows runtime_suspend later. + * If the core was in host mode during suspend, then perform + * runtime resume which will do resume and set the runtime PM + * state as active to reflect actual state of device which + * is now out of LPM. This allows runtime_suspend later. */ if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) - goto runtime_set_active; + pm_runtime_resume(dev); return 0; } @@ -2013,11 +2014,6 @@ static int dwc3_resume(struct device *dev) if (ret) return ret; -runtime_set_active: - pm_runtime_disable(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - return 0; } #endif /* CONFIG_PM_SLEEP */ diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 575a31ec9600..83d088d5d457 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -436,10 +436,9 @@ static int xhci_plat_resume(struct device *dev) if (ret) return ret; - ret = xhci_resume(xhci, false); - pm_runtime_disable(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); + ret = pm_runtime_resume(dev); + if (ret) + dev_err(dev, "failed to resume xhci-plat (%d)\n", ret); return ret; }