lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZrZC8AFtmR3Zn1c9@lizhi-Precision-Tower-5810>
Date: Fri, 9 Aug 2024 12:25:20 -0400
From: Frank Li <Frank.li@....com>
To: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
Cc: Mathias Nyman <mathias.nyman@...el.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>,
	"linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>,
	"jun.li@....com" <jun.li@....com>, Peter Chen <peter.chen@....com>
Subject: Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device
 mode resume

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@....com>
> >
> > 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.

So clk will be always ON at next suspend.

Frank Li

>
> Thanks,
> Thinh
>
> >
> > Reviewed-by: Peter Chen <peter.chen@....com>
> > Signed-off-by: Li Jun <jun.li@....com>
> > Signed-off-by: Frank Li <Frank.Li@....com>
> > ---
> >  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
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ