From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Roger Quadros <rogerq@kernel.org>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nishanth Menon <nm@ti.com>, Tero Kristo <kristo@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
Dhruva Gole <d-gole@ti.com>, Vishal Mahaveer <vishalm@ti.com>,
"msp@baylibre.com" <msp@baylibre.com>, "srk@ti.com" <srk@ti.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: core: Fix system suspend on TI AM62 platforms
Date: Tue, 8 Oct 2024 20:53:17 +0000 [thread overview]
Message-ID: <20241008205315.64cxff22uckoich5@synopsys.com> (raw)
In-Reply-To: <85f1805b-e4c8-48c4-8e99-c36d20182a13@kernel.org>
Hi Roger,
On Tue, Oct 08, 2024, Roger Quadros wrote:
> Hi Thinh,
>
> On 05/10/2024 04:04, Thinh Nguyen wrote:
> > Hi,
> >
> > On Tue, Oct 01, 2024, Roger Quadros wrote:
> >> Since commit 6d735722063a ("usb: dwc3: core: Prevent phy suspend during init"),
> >> system suspend is broken on AM62 TI platforms.
> >>
> >> Before that commit, both DWC3_GUSB3PIPECTL_SUSPHY and DWC3_GUSB2PHYCFG_SUSPHY
> >> bits (hence forth called 2 SUSPHY bits) were being set during core
> >> initialization and even during core re-initialization after a system
> >> suspend/resume.
> >>
> >> These bits are required to be set for system suspend/resume to work correctly
> >> on AM62 platforms.
> >>
> >> Since that commit, the 2 SUSPHY bits are not set for DEVICE/OTG mode if gadget
> >> driver is not loaded and started.
> >> For Host mode, the 2 SUSPHY bits are set before the first system suspend but
> >> get cleared at system resume during core re-init and are never set again.
> >>
> >> This patch resovles these two issues by ensuring the 2 SUSPHY bits are set
> >> before system suspend and restored to the original state during system resume.
> >>
> >> Cc: stable@vger.kernel.org # v6.9+
> >> Fixes: 6d735722063a ("usb: dwc3: core: Prevent phy suspend during init")
> >> Link: https://urldefense.com/v3/__https://lore.kernel.org/all/1519dbe7-73b6-4afc-bfe3-23f4f75d772f@kernel.org/__;!!A4F2R9G_pg!ahChm4MaKd6VGYqbnM4X1_pY_jqavYDv5HvPFbmicKuhvFsBwlEFi1xO5itGuHmfjbRuUSzReJISf5-1gXpr$
> >> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> >> ---
> >> drivers/usb/dwc3/core.c | 16 ++++++++++++++++
> >> drivers/usb/dwc3/core.h | 2 ++
> >> 2 files changed, 18 insertions(+)
> >>
> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >> index 9eb085f359ce..1233922d4d54 100644
> >> --- a/drivers/usb/dwc3/core.c
> >> +++ b/drivers/usb/dwc3/core.c
> >> @@ -2336,6 +2336,9 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
> >> u32 reg;
> >> int i;
> >>
> >> + dwc->susphy_state = !!(dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
> >> + DWC3_GUSB2PHYCFG_SUSPHY);
> >> +
> >> switch (dwc->current_dr_role) {
> >> case DWC3_GCTL_PRTCAP_DEVICE:
> >> if (pm_runtime_suspended(dwc->dev))
> >> @@ -2387,6 +2390,11 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
> >> break;
> >> }
> >>
> >> + if (!PMSG_IS_AUTO(msg)) {
> >> + if (!dwc->susphy_state)
> >> + dwc3_enable_susphy(dwc, true);
> >> + }
> >> +
> >> return 0;
> >> }
> >>
> >> @@ -2454,6 +2462,14 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> >> break;
> >> }
> >>
> >> + if (!PMSG_IS_AUTO(msg)) {
> >> + /* dwc3_core_init_for_resume() disables SUSPHY so just handle
> >> + * the enable case
> >> + */
> >
> > Can we note that this is a particular behavior needed for AM62 here?
> > And can we use this comment style:
>
> Looking at this again, this fix is not specific to AM62 but for all platforms.
> e.g. if Host Role was already started when going to system suspend, SUSPHY bits
> were enabled, then after system resume SUSPHY bits are cleared at dwc3_core_init_for_resume().
>
> Host stop/start was not called so SUSPHY bits remain cleared. So here
> we deal with enabling SUSPHY.
>
It's true that we have a bug where the SUSPHY bits remain disabled after
suspend. However, the SUSPHY bits needing to be set during suspend is
unique to AM62. Let's add this note in the dwc3_suspend_common() check.
Thanks,
Thinh
next prev parent reply other threads:[~2024-10-08 21:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 15:12 [PATCH] usb: dwc3: core: Fix system suspend on TI AM62 platforms Roger Quadros
2024-10-05 1:04 ` Thinh Nguyen
2024-10-07 11:44 ` Roger Quadros
2024-10-08 20:57 ` Thinh Nguyen
2024-10-09 11:49 ` Roger Quadros
2024-10-08 15:19 ` Roger Quadros
2024-10-08 20:53 ` Thinh Nguyen [this message]
2024-10-09 11:50 ` Roger Quadros
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=20241008205315.64cxff22uckoich5@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=d-gole@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=kristo@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=msp@baylibre.com \
--cc=nm@ti.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=rogerq@kernel.org \
--cc=srk@ti.com \
--cc=ssantosh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vishalm@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).