On Fri, Jul 12, 2024, Frank Li wrote: > From: Li Jun <jun.li@xxxxxxx> > > The runtime resume will happen before system resume if system wakeup by > device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice. What's the consequence of going through the resuming sequence twice? Will this cause any functional issue? Thanks, Thinh > > Reviewed-by: Peter Chen <peter.chen@xxxxxxx> > Signed-off-by: Li Jun <jun.li@xxxxxxx> > Signed-off-by: Frank Li <Frank.Li@xxxxxxx> > --- > drivers/usb/dwc3/core.c | 13 +++++++++++++ > drivers/usb/dwc3/core.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 734de2a8bd212..d60917fad8c52 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc) > dwc3_phy_exit(dwc); > dwc3_clk_disable(dwc); > reset_control_assert(dwc->reset); > + > + dwc->core_inited = false; > } > > static bool dwc3_core_is_valid(struct dwc3 *dwc) > @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc) > dwc3_writel(dwc->regs, DWC3_LLUCTL, reg); > } > > + dwc->core_inited = true; > + > return 0; > > err_power_off_phy: > @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) > > switch (dwc->current_dr_role) { > case DWC3_GCTL_PRTCAP_DEVICE: > + /* > + * system resume may come after runtime resume > + * e.g. rpm suspend -> pm suspend -> wakeup > + * -> rpm resume -> system resume, so if already > + * runtime resumed, system resume should skip it. > + */ > + if (dwc->core_inited) > + break; > + > ret = dwc3_core_init_for_resume(dwc); > if (ret) > return ret; > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > index 1e561fd8b86e2..8a4bfd9a25b19 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -1195,6 +1195,7 @@ struct dwc3 { > struct clk *utmi_clk; > struct clk *pipe_clk; > > + bool core_inited; > struct reset_control *reset; > > struct usb_phy *usb2_phy; > > -- > 2.34.1 >