From 3cb01862db8935d16089d45acb47bc4847363237 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Fri, 20 Mar 2020 21:01:58 +0530 Subject: [PATCH] usb: dwc3-msm: Enable pwr_evt_irq for wakeup after LPM is done Platforms using Synopsys SS phy are enabling pwr_evt_irq for wakeup events in host mode as a part of dwc3_msm_suspend, but before all the resources have been relinquished. So it is possible that an IRQ is fired before dwc->in_lpm could be set to 1. Because of this, the pwr_event_handler will try to read STAT_REG without issuing resume_work leading to unclocked access. Fix this by enabling pwr_evt_irq only after in_lpm flag is set to 1, hence ensuring resume when the irq is fired. Change-Id: I9772f427ecd10c2922c998cf0d57734362413051 Signed-off-by: Ajay Agarwal --- drivers/usb/dwc3/dwc3-msm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 77afbed72763..b13bb0d2c1a7 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -3308,7 +3308,6 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse, mdwc->lpm_flags |= MDWC3_SS_PHY_SUSPEND; } else if (mdwc->use_pwr_event_for_wakeup) { dwc3_msm_set_ss_pwr_events(mdwc, true); - enable_irq(mdwc->wakeup_irq[PWR_EVNT_IRQ].irq); } /* make sure above writes are completed before turning off clocks */ @@ -3376,6 +3375,10 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse, mdwc->lpm_flags |= MDWC3_ASYNC_IRQ_WAKE_CAPABILITY; } + if (mdwc->use_pwr_event_for_wakeup && + !(mdwc->lpm_flags & MDWC3_SS_PHY_SUSPEND)) + enable_irq(mdwc->wakeup_irq[PWR_EVNT_IRQ].irq); + dev_info(mdwc->dev, "DWC3 in low power mode\n"); dbg_event(0xFF, "Ctl Sus", atomic_read(&dwc->in_lpm));