From 980a25b5c2b74c9b104a228808f6789d5df0e6c2 Mon Sep 17 00:00:00 2001 From: Elson Roy Serrao Date: Tue, 27 Jul 2021 10:11:41 -0700 Subject: [PATCH] usb: dwc3: Dont release wakeup source during usb restart When changing USB speed via sysfs, the device might utilize the idle time between DISCONNECT and CONNECT events and enter suspend. As a result the pending CONNECT might get delayed thus pushing USB enumeration during the next resume. Avoid this by not releasing the wakeup source when usb restart is in progress. Change-Id: I754b76eb7b36923a2dcd4d58587101750d1cd83c Signed-off-by: Elson Roy Serrao --- drivers/usb/dwc3/dwc3-msm.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 3b439bf49bdf..aec1a72c7fa3 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -3374,17 +3374,19 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse, dwc3_msm_update_bus_bw(mdwc, BUS_VOTE_NONE); - /* - * release wakeup source with timeout to defer system suspend to - * handle case where on USB cable disconnect, SUSPEND and DISCONNECT - * event is received. - */ - if (mdwc->lpm_to_suspend_delay) { - dev_dbg(mdwc->dev, "defer suspend with %d(msecs)\n", - mdwc->lpm_to_suspend_delay); - pm_wakeup_event(mdwc->dev, mdwc->lpm_to_suspend_delay); - } else { - pm_relax(mdwc->dev); + if (!mdwc->in_restart) { + /* + * release wakeup source with timeout to defer system suspend to + * handle case where on USB cable disconnect, SUSPEND and DISCONNECT + * event is received. + */ + if (mdwc->lpm_to_suspend_delay) { + dev_dbg(mdwc->dev, "defer suspend with %d(msecs)\n", + mdwc->lpm_to_suspend_delay); + pm_wakeup_event(mdwc->dev, mdwc->lpm_to_suspend_delay); + } else { + pm_relax(mdwc->dev); + } } atomic_set(&dwc->in_lpm, 1);