From: Roger Quadros <rogerq@kernel.org>
To: "Théo Lebrun" <theo.lebrun@bootlin.com>,
"Peter Chen" <peter.chen@kernel.org>,
"Pawel Laszczak" <pawell@cadence.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Mathias Nyman" <mathias.nyman@intel.com>
Cc: "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: Thu, 12 Dec 2024 14:18:24 +0200 [thread overview]
Message-ID: <4e1eb8d2-c725-4572-8419-3027cac10c92@kernel.org> (raw)
In-Reply-To: <20241210-s2r-cdns-v6-2-28a17f9715a2@bootlin.com>
On 10/12/2024 19:13, 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.
>
Did I understand right that the Controller reset can happen only at
system suspend and never at runtime suspend?
If so do you really need the runtime suspend/resume hooks?
you should have different system suspend/resume hooks than runtime suspend/resume
hooks and deal with the re-initialization in system resume hook.
> 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.
> + */
Separate system sleep hooks will also prevent this kind of behavior.
> 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)
> + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> +};
> +
> static const struct of_device_id cdns_ti_of_match[] = {
> { .compatible = "ti,j721e-usb", },
> { .compatible = "ti,am64-usb", },
> @@ -245,6 +269,7 @@ static struct platform_driver cdns_ti_driver = {
> .driver = {
> .name = "cdns3-ti",
> .of_match_table = cdns_ti_of_match,
> + .pm = pm_ptr(&cdns_ti_pm_ops),
> },
> };
>
>
--
cheers,
-roger
next prev parent reply other threads:[~2024-12-12 12:18 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 [this message]
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
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=4e1eb8d2-c725-4572-8419-3027cac10c92@kernel.org \
--to=rogerq@kernel.org \
--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=theo.lebrun@bootlin.com \
--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