From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Frank Li <Frank.li@nxp.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"jun.li@nxp.com" <jun.li@nxp.com>,
Peter Chen <peter.chen@nxp.com>
Subject: Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
Date: Fri, 9 Aug 2024 23:18:53 +0000 [thread overview]
Message-ID: <20240809231844.okzwndlds3zh75rh@synopsys.com> (raw)
In-Reply-To: <ZrZC8AFtmR3Zn1c9@lizhi-Precision-Tower-5810>
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@nxp.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.
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?
If the issue is only related to clk_enable(), perhaps just check that?
(minor nit: rename core_inited to core_initialized if you plan to do
that)
Thanks,
Thinh
> > >
> > > Reviewed-by: Peter Chen <peter.chen@nxp.com>
> > > Signed-off-by: Li Jun <jun.li@nxp.com>
> > > Signed-off-by: Frank Li <Frank.Li@nxp.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
> > >
next prev parent reply other threads:[~2024-08-09 23:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
2024-07-12 15:40 ` [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
2024-07-12 15:40 ` [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
2024-08-07 1:08 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Frank Li
2024-08-07 1:13 ` Thinh Nguyen
2024-08-09 16:25 ` Frank Li
2024-08-09 23:18 ` Thinh Nguyen [this message]
2024-08-13 16:57 ` Frank Li
2024-08-13 23:56 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
2024-08-07 1:20 ` Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240809231844.okzwndlds3zh75rh@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=Frank.li@nxp.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=peter.chen@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®