Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 09, 2024 at 11:18:53PM +0000, Thinh Nguyen wrote:
> On Fri, Aug 09, 2024, Frank Li wrote:
> > On Wed, Aug 07, 2024 at 01:13:52AM +0000, Thinh Nguyen wrote:
> > > 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?
> >
> > static int dwc3_core_init_for_resume(struct dwc3 *dwc)
> > {
> >
> > 	...
> >         ret = dwc3_clk_enable(dwc);
> >         if (ret)
> >                 goto assert_reset;
> >
> > 	...
> > }
> >
> > clk will be enabled twice, the reference count in clk will be wrong because
> > clk_disable() only once at suspend.
>
> Please capture these info in the commit message.
>
> >
> > So clk will be always ON at next suspend.
> >
> > Frank Li
> >
>
> dwc3_clk_enable() happens in probe() and dwc3_core_init_for_resume(),
> but you're checking dwc->core_inited in dwc3_core_init(). Why?

I have not check dwc->core_inited in dwc3_core_init(). Just set init value
dwc->core_inited = true

Do you means dwc3_core_init() as dwc3_resume_common()?

>
> If the issue is only related to clk_enable(), perhaps just check that?

This should be major one. Any paired operator between suspend/resume should
have issue.

Frank

>
> (minor nit: rename core_inited to core_initialized if you plan to do
> that)
>
> 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
> > > >




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux