usb: dwc3: Fix re-enumeration of connected peripherals

When the device exits suspend/deep sleep in host mode with
peripherals connected, the peripherals and root hub failed to
resume because the xhci stack has not resumed yet, leading to
the re-enumeration of the connected peripherals.

Fix this by resuming the glue driver, core and xhci plat driver
un-conditionally as part of suspend/deep sleep exit.

Change-Id: Ie1cbe174aec04ddde5779ad4fabdf075cffa955d
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
This commit is contained in:
Sriharsha Allenki 2020-10-12 14:14:57 +05:30 • committed by Gerrit - the friendly Code Review server
commit 4852b6f3dc
3 changed files with 26 additions and 4 deletions

View file

@ -2001,8 +2001,7 @@ static int dwc3_resume(struct device *dev)
* 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 &&
dwc->host_poweroff_in_pm_suspend)
if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
goto runtime_set_active;
return 0;

View file

@ -5303,7 +5303,7 @@ static int dwc3_msm_pm_resume(struct device *dev)
atomic_set(&mdwc->pm_suspended, 0);
if (!dwc->host_poweroff_in_pm_suspend || !mdwc->in_host_mode) {
if (!mdwc->in_host_mode) {
/* kick in otg state machine */
queue_work(mdwc->dwc3_wq, &mdwc->resume_work);

View file

@ -421,6 +421,29 @@ static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
return xhci_suspend(xhci, true);
}
static int xhci_plat_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int ret;
if (!xhci)
return 0;
dev_dbg(dev, "xhci-plat resume\n");
ret = xhci_priv_resume_quirk(hcd);
if (ret)
return ret;
ret = xhci_resume(xhci, false);
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return ret;
}
static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
@ -443,7 +466,7 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
}
static const struct dev_pm_ops xhci_plat_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(NULL, NULL)
SET_SYSTEM_SLEEP_PM_OPS(NULL, xhci_plat_resume)
SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
xhci_plat_runtime_resume,