From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Peter Chen" <peter.chen@kernel.org>
Cc: "Pawel Laszczak" <pawell@cadence.com>,
"Roger Quadros" <rogerq@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Mathias Nyman" <mathias.nyman@intel.com>,
"Grégory Clement" <gregory.clement@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/5] usb: cdns3-ti: run HW init at resume() if HW was reset
Date: Mon, 16 Dec 2024 15:02:43 +0100 [thread overview]
Message-ID: <D6D6IL1RNGA8.3U3GIJQJX2L3J@bootlin.com> (raw)
In-Reply-To: <20241214084940.GA4102926@nchen-desktop>
On Sat Dec 14, 2024 at 9:49 AM CET, Peter Chen wrote:
> On 24-12-10 18:13:36, Théo Lebrun wrote:
> > At runtime_resume(), read the W1 (Wrapper Register 1) register to detect
> > if an hardware reset occurred. If it did, run the hardware init sequence.
> >
> > This callback will be called at system-wide resume. Previously, if a
> > reset occurred during suspend, we would crash. The wrapper config had
> > not been written, leading to invalid register accesses inside cdns3.
> >
> > Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
> > ---
> > drivers/usb/cdns3/cdns3-ti.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c
> > index d704eb39820ad08a8774be7f00aa473c3ff267c0..d35be7db7616ef5e5bed7dbd53b78a094809f7cc 100644
> > --- a/drivers/usb/cdns3/cdns3-ti.c
> > +++ b/drivers/usb/cdns3/cdns3-ti.c
> > @@ -188,6 +188,12 @@ static int cdns_ti_probe(struct platform_device *pdev)
> > data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider");
> > data->usb2_only = device_property_read_bool(dev, "ti,usb2-only");
> >
> > + /*
> > + * The call below to pm_runtime_get_sync() MIGHT reset hardware, if it
> > + * detects it as uninitialised. We want to enforce a reset at probe,
> > + * and so do it manually here. This means the first runtime_resume()
> > + * will be a no-op.
> > + */
> > cdns_ti_reset_and_init_hw(data);
> >
> > pm_runtime_enable(dev);
> > @@ -232,6 +238,24 @@ static void cdns_ti_remove(struct platform_device *pdev)
> > platform_set_drvdata(pdev, NULL);
> > }
> >
> > +static int cdns_ti_runtime_resume(struct device *dev)
> > +{
> > + const u32 mask = USBSS_W1_PWRUP_RST | USBSS_W1_MODESTRAP_SEL;
> > + struct cdns_ti *data = dev_get_drvdata(dev);
> > + u32 w1;
> > +
> > + w1 = cdns_ti_readl(data, USBSS_W1);
> > + if ((w1 & mask) != mask)
> > + cdns_ti_reset_and_init_hw(data);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct dev_pm_ops cdns_ti_pm_ops = {
> > + RUNTIME_PM_OPS(NULL, cdns_ti_runtime_resume, NULL)
>
> Why only runtime resume, but without runtime suspend?
I don't see any situation where we would want "runtime suspend" be
equivalent to "reset the cdns3 wrapper". It implies losing child
states, triggering rediscovery of all USB devices at resume. Is that a
desired property of runtime suspend on any discoverable bus?
Sidenote: also, in our implementation, we do the standard thing of using
pm_runtime_force_suspend|resume() as suspend callback implementations.
With that, if we did reset the wrapper at suspend, we would:
- always have to rediscover USB devices at resume and,
- break wakeup sources.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2024-12-16 14:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 17:13 [PATCH v6 0/5] Fix USB suspend on TI J7200 (cdns3-ti, cdns3, xhci) Théo Lebrun
2024-12-10 17:13 ` [PATCH v6 1/5] usb: cdns3-ti: move reg writes to separate function Théo Lebrun
2024-12-12 12:12 ` Roger Quadros
2024-12-10 17:13 ` [PATCH v6 2/5] usb: cdns3-ti: run HW init at resume() if HW was reset Théo Lebrun
2024-12-12 12:18 ` Roger Quadros
2024-12-13 15:28 ` Théo Lebrun
2024-12-17 21:13 ` Roger Quadros
2024-12-14 8:49 ` Peter Chen
2024-12-16 14:02 ` Théo Lebrun [this message]
2024-12-17 6:12 ` Peter Chen
2024-12-10 17:13 ` [PATCH v6 3/5] usb: cdns3: rename hibernated argument of role->resume() to lost_power Théo Lebrun
2024-12-14 8:51 ` Peter Chen
2024-12-10 17:13 ` [PATCH v6 4/5] xhci: introduce xhci->lost_power flag Théo Lebrun
2024-12-12 12:37 ` Roger Quadros
2024-12-13 16:03 ` Théo Lebrun
2024-12-17 21:00 ` Roger Quadros
2024-12-18 17:49 ` Théo Lebrun
2025-01-08 10:59 ` Théo Lebrun
2025-01-08 18:43 ` Mathias Nyman
2025-01-29 10:45 ` Théo Lebrun
2025-01-29 10:56 ` [PATCH 1/9] usb: host: xhci-plat: mvebu: use ->quirks instead of ->init_quirk() func Théo Lebrun
2025-01-29 10:56 ` [PATCH 2/9] usb: xhci: tegra: rename `runtime` boolean to `is_auto_runtime` Théo Lebrun
2025-01-29 10:56 ` [PATCH 3/9] usb: cdns3-ti: move reg writes to separate function Théo Lebrun
2025-01-29 10:56 ` [PATCH 4/9] usb: cdns3-ti: run HW init at resume() if HW was reset Théo Lebrun
2025-01-29 10:56 ` [PATCH 5/9] usb: cdns3: rename hibernated argument of role->resume() to lost_power Théo Lebrun
2025-01-29 10:56 ` [PATCH 6/9] usb: cdns3: call cdns_power_is_lost() only once in cdns_resume() Théo Lebrun
2025-01-29 10:56 ` [PATCH 7/9] usb: xhci: change xhci_resume() parameters to explicit the desired info Théo Lebrun
2025-01-29 10:56 ` [PATCH 8/9] usb: host: xhci-plat: allow upper layers to signal power loss Théo Lebrun
2025-01-29 10:56 ` [PATCH 9/9] usb: host: cdns3: forward lost power information to xhci Théo Lebrun
2024-12-10 17:13 ` [PATCH v6 5/5] usb: cdns3: host: transmit lost_power signal from wrapper to XHCI Théo Lebrun
2024-12-14 9:06 ` [PATCH v6 0/5] Fix USB suspend on TI J7200 (cdns3-ti, cdns3, xhci) Peter Chen
2024-12-16 14:09 ` Théo Lebrun
2024-12-17 6:17 ` Peter Chen
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=D6D6IL1RNGA8.3U3GIJQJX2L3J@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=rogerq@kernel.org \
--cc=thomas.petazzoni@bootlin.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