* [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB
@ 2023-07-18 9:14 Haotien Hsu
2023-07-18 9:18 ` Oliver Neukum
2023-07-25 16:19 ` Greg Kroah-Hartman
0 siblings, 2 replies; 5+ messages in thread
From: Haotien Hsu @ 2023-07-18 9:14 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, linux-usb, linux-tegra, linux-kernel
Cc: Wayne Chang, JC Kuo, WK Tsai, Henry Lin, Haotien Hsu
From: Henry Lin <henryl@nvidia.com>
If memory accesses by the Tegra XUSB controller are translated through
the SMMU (System MMU), the hardware may continue accessing memory even
after the SMMU translations have been disabled during the shutdown
process and this can in turn cause unpredictable crashes.
Fix this by adding a shutdown implementation that ensures the hardware
is turned off during system reboot or shutdown.
Signed-off-by: Henry Lin <henryl@nvidia.com>
Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
---
V1 -> V2: Resend for the typo in the mailing list
---
drivers/usb/host/xhci-tegra.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index a56cc81b9404..6ef2eac9835d 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1925,6 +1925,15 @@ static int tegra_xusb_probe(struct platform_device *pdev)
return err;
}
+static void tegra_xusb_disable(struct tegra_xusb *tegra)
+{
+ tegra_xusb_powergate_partitions(tegra);
+ tegra_xusb_powerdomain_remove(tegra->dev, tegra);
+ tegra_xusb_phy_disable(tegra);
+ tegra_xusb_clk_disable(tegra);
+ regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
+}
+
static int tegra_xusb_remove(struct platform_device *pdev)
{
struct tegra_xusb *tegra = platform_get_drvdata(pdev);
@@ -1947,18 +1956,22 @@ static int tegra_xusb_remove(struct platform_device *pdev)
pm_runtime_put(&pdev->dev);
- tegra_xusb_powergate_partitions(tegra);
-
- tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
-
- tegra_xusb_phy_disable(tegra);
- tegra_xusb_clk_disable(tegra);
- regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
+ tegra_xusb_disable(tegra);
tegra_xusb_padctl_put(tegra->padctl);
return 0;
}
+static void tegra_xusb_shutdown(struct platform_device *pdev)
+{
+ struct tegra_xusb *tegra = platform_get_drvdata(pdev);
+
+ pm_runtime_get_sync(&pdev->dev);
+ disable_irq(tegra->xhci_irq);
+ xhci_shutdown(tegra->hcd);
+ tegra_xusb_disable(tegra);
+}
+
static bool xhci_hub_ports_suspended(struct xhci_hub *hub)
{
struct device *dev = hub->hcd->self.controller;
@@ -2666,6 +2679,7 @@ MODULE_DEVICE_TABLE(of, tegra_xusb_of_match);
static struct platform_driver tegra_xusb_driver = {
.probe = tegra_xusb_probe,
.remove = tegra_xusb_remove,
+ .shutdown = tegra_xusb_shutdown,
.driver = {
.name = "tegra-xusb",
.pm = &tegra_xusb_pm_ops,
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB
2023-07-18 9:14 [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB Haotien Hsu
@ 2023-07-18 9:18 ` Oliver Neukum
2023-07-18 11:35 ` Thierry Reding
2023-07-25 16:19 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: Oliver Neukum @ 2023-07-18 9:18 UTC (permalink / raw)
To: Haotien Hsu, Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, linux-usb, linux-tegra, linux-kernel
Cc: Wayne Chang, JC Kuo, WK Tsai, Henry Lin
On 18.07.23 11:14, Haotien Hsu wrote:
> From: Henry Lin <henryl@nvidia.com>
>
> If memory accesses by the Tegra XUSB controller are translated through
> the SMMU (System MMU), the hardware may continue accessing memory even
> after the SMMU translations have been disabled during the shutdown
> process and this can in turn cause unpredictable crashes.
> Fix this by adding a shutdown implementation that ensures the hardware
> is turned off during system reboot or shutdown.
>
> Signed-off-by: Henry Lin <henryl@nvidia.com>
> Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
> Acked-by: Thierry Reding <treding@nvidia.com>
>
> ---
> V1 -> V2: Resend for the typo in the mailing list
> ---
> drivers/usb/host/xhci-tegra.c | 28 +++++++++++++++++++++-------
> 1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index a56cc81b9404..6ef2eac9835d 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -1925,6 +1925,15 @@ static int tegra_xusb_probe(struct platform_device *pdev)
> return err;
> }
>
> +static void tegra_xusb_disable(struct tegra_xusb *tegra)
> +{
> + tegra_xusb_powergate_partitions(tegra);
> + tegra_xusb_powerdomain_remove(tegra->dev, tegra);
> + tegra_xusb_phy_disable(tegra);
> + tegra_xusb_clk_disable(tegra);
> + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> +}
> +
> static int tegra_xusb_remove(struct platform_device *pdev)
> {
> struct tegra_xusb *tegra = platform_get_drvdata(pdev);
> @@ -1947,18 +1956,22 @@ static int tegra_xusb_remove(struct platform_device *pdev)
>
> pm_runtime_put(&pdev->dev);
>
> - tegra_xusb_powergate_partitions(tegra);
> -
> - tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
> -
> - tegra_xusb_phy_disable(tegra);
> - tegra_xusb_clk_disable(tegra);
> - regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> + tegra_xusb_disable(tegra);
> tegra_xusb_padctl_put(tegra->padctl);
>
> return 0;
> }
>
> +static void tegra_xusb_shutdown(struct platform_device *pdev)
> +{
> + struct tegra_xusb *tegra = platform_get_drvdata(pdev);
> +
> + pm_runtime_get_sync(&pdev->dev);
Where is this balanced?
Regards
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB
2023-07-18 9:18 ` Oliver Neukum
@ 2023-07-18 11:35 ` Thierry Reding
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2023-07-18 11:35 UTC (permalink / raw)
To: Oliver Neukum
Cc: Haotien Hsu, Mathias Nyman, Greg Kroah-Hartman, Jonathan Hunter,
linux-usb, linux-tegra, linux-kernel, Wayne Chang, JC Kuo,
WK Tsai, Henry Lin
[-- Attachment #1: Type: text/plain, Size: 2715 bytes --]
On Tue, Jul 18, 2023 at 11:18:25AM +0200, Oliver Neukum wrote:
>
>
> On 18.07.23 11:14, Haotien Hsu wrote:
> > From: Henry Lin <henryl@nvidia.com>
> >
> > If memory accesses by the Tegra XUSB controller are translated through
> > the SMMU (System MMU), the hardware may continue accessing memory even
> > after the SMMU translations have been disabled during the shutdown
> > process and this can in turn cause unpredictable crashes.
> > Fix this by adding a shutdown implementation that ensures the hardware
> > is turned off during system reboot or shutdown.
> >
> > Signed-off-by: Henry Lin <henryl@nvidia.com>
> > Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
> > Acked-by: Thierry Reding <treding@nvidia.com>
> >
> > ---
> > V1 -> V2: Resend for the typo in the mailing list
> > ---
> > drivers/usb/host/xhci-tegra.c | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> > index a56cc81b9404..6ef2eac9835d 100644
> > --- a/drivers/usb/host/xhci-tegra.c
> > +++ b/drivers/usb/host/xhci-tegra.c
> > @@ -1925,6 +1925,15 @@ static int tegra_xusb_probe(struct platform_device *pdev)
> > return err;
> > }
> > +static void tegra_xusb_disable(struct tegra_xusb *tegra)
> > +{
> > + tegra_xusb_powergate_partitions(tegra);
> > + tegra_xusb_powerdomain_remove(tegra->dev, tegra);
> > + tegra_xusb_phy_disable(tegra);
> > + tegra_xusb_clk_disable(tegra);
> > + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> > +}
> > +
> > static int tegra_xusb_remove(struct platform_device *pdev)
> > {
> > struct tegra_xusb *tegra = platform_get_drvdata(pdev);
> > @@ -1947,18 +1956,22 @@ static int tegra_xusb_remove(struct platform_device *pdev)
> > pm_runtime_put(&pdev->dev);
> > - tegra_xusb_powergate_partitions(tegra);
> > -
> > - tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
> > -
> > - tegra_xusb_phy_disable(tegra);
> > - tegra_xusb_clk_disable(tegra);
> > - regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> > + tegra_xusb_disable(tegra);
> > tegra_xusb_padctl_put(tegra->padctl);
> > return 0;
> > }
> > +static void tegra_xusb_shutdown(struct platform_device *pdev)
> > +{
> > + struct tegra_xusb *tegra = platform_get_drvdata(pdev);
> > +
> > + pm_runtime_get_sync(&pdev->dev);
>
> Where is this balanced?
Well, I suppose we could add a pm_runtime_put() at the end of this
function, but since we expect the system to shut down after this, at
which point any runtime PM accounting is going to go bye-bye anyway,
do we really want to bother?
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB
2023-07-18 9:14 [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB Haotien Hsu
2023-07-18 9:18 ` Oliver Neukum
@ 2023-07-25 16:19 ` Greg Kroah-Hartman
2023-07-27 8:08 ` Haotien Hsu
1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-25 16:19 UTC (permalink / raw)
To: Haotien Hsu
Cc: Mathias Nyman, Thierry Reding, Jonathan Hunter, linux-usb,
linux-tegra, linux-kernel, Wayne Chang, JC Kuo, WK Tsai,
Henry Lin
On Tue, Jul 18, 2023 at 05:14:25PM +0800, Haotien Hsu wrote:
> From: Henry Lin <henryl@nvidia.com>
>
> If memory accesses by the Tegra XUSB controller are translated through
> the SMMU (System MMU), the hardware may continue accessing memory even
> after the SMMU translations have been disabled during the shutdown
> process and this can in turn cause unpredictable crashes.
> Fix this by adding a shutdown implementation that ensures the hardware
> is turned off during system reboot or shutdown.
>
> Signed-off-by: Henry Lin <henryl@nvidia.com>
> Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
> Acked-by: Thierry Reding <treding@nvidia.com>
>
> ---
> V1 -> V2: Resend for the typo in the mailing list
> ---
> drivers/usb/host/xhci-tegra.c | 28 +++++++++++++++++++++-------
> 1 file changed, 21 insertions(+), 7 deletions(-)
Does not apply against 6.5-rc4 at all :(
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB
2023-07-25 16:19 ` Greg Kroah-Hartman
@ 2023-07-27 8:08 ` Haotien Hsu
0 siblings, 0 replies; 5+ messages in thread
From: Haotien Hsu @ 2023-07-27 8:08 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: WK Tsai, linux-usb@vger.kernel.org, thierry.reding@gmail.com,
Jonathan Hunter, linux-tegra@vger.kernel.org, Wayne Chang,
linux-kernel@vger.kernel.org, mathias.nyman@intel.com,
Jui Chang Kuo, Henry Lin
On Tue, 2023-07-25 at 18:19 +0200, Greg Kroah-Hartman wrote:
> External email: Use caution opening links or attachments
>
>
> On Tue, Jul 18, 2023 at 05:14:25PM +0800, Haotien Hsu wrote:
> > From: Henry Lin <henryl@nvidia.com>
> >
> > If memory accesses by the Tegra XUSB controller are translated
> > through
> > the SMMU (System MMU), the hardware may continue accessing memory
> > even
> > after the SMMU translations have been disabled during the shutdown
> > process and this can in turn cause unpredictable crashes.
> > Fix this by adding a shutdown implementation that ensures the
> > hardware
> > is turned off during system reboot or shutdown.
> >
> > Signed-off-by: Henry Lin <henryl@nvidia.com>
> > Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
> > Acked-by: Thierry Reding <treding@nvidia.com>
> >
> > ---
> > V1 -> V2: Resend for the typo in the mailing list
> > ---
> > drivers/usb/host/xhci-tegra.c | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
>
> Does not apply against 6.5-rc4 at all :(
I rebased the patch and sent it again.
I am sorry about that.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-27 8:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 9:14 [PATCH v2] usb: xhci: tegra: Add shutdown callback for Tegra XUSB Haotien Hsu
2023-07-18 9:18 ` Oliver Neukum
2023-07-18 11:35 ` Thierry Reding
2023-07-25 16:19 ` Greg Kroah-Hartman
2023-07-27 8:08 ` Haotien Hsu
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).