diff mbox series

[1/2] firmware: PSCI: Fix PSCI support for OF live trees

Message ID 20200618115439.25100-1-jonathanh@nvidia.com
State Accepted
Commit fb264efbd2fef45ca96630c355cbe30957132f3f
Headers show
Series [1/2] firmware: PSCI: Fix PSCI support for OF live trees | expand

Commit Message

Jon Hunter June 18, 2020, 11:54 a.m. UTC
When CONFIG_OF_LIVE is enabled, dev_of_offset() cannot be used and
if used returns an invalid offset. This causes the call to
fdt_stringlist_get() in the psci_probe() to fail to read the 'method'
property from the PSCI node for the device and hence prevents PSCI
from working. Fix this by using the ofnode_read_string() API instead
of the fdt_stringlist_get() because this will handle reading the
property both when CONFIG_OF_LIVE is enabled or disabled.

Due to the above problem and since commit 81ea00838c68 ("efi_loader:
PSCI reset and shutdown") was added, the EFI system reset has been
broken for Tegra210 and Tegra196 platforms. This also fixes the EFI
system reset for these Tegra platforms.

Signed-off-by: Jon Hunter <jonathanh at nvidia.com>
---
 drivers/firmware/psci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Peter Robinson June 18, 2020, 3:44 p.m. UTC | #1
On Thu, Jun 18, 2020 at 12:55 PM Jon Hunter <jonathanh at nvidia.com> wrote:
>
> When CONFIG_OF_LIVE is enabled, dev_of_offset() cannot be used and
> if used returns an invalid offset. This causes the call to
> fdt_stringlist_get() in the psci_probe() to fail to read the 'method'
> property from the PSCI node for the device and hence prevents PSCI
> from working. Fix this by using the ofnode_read_string() API instead
> of the fdt_stringlist_get() because this will handle reading the
> property both when CONFIG_OF_LIVE is enabled or disabled.
>
> Due to the above problem and since commit 81ea00838c68 ("efi_loader:
> PSCI reset and shutdown") was added, the EFI system reset has been
> broken for Tegra210 and Tegra196 platforms. This also fixes the EFI
> system reset for these Tegra platforms.
>
> Signed-off-by: Jon Hunter <jonathanh at nvidia.com>
Tested-by: Peter Robinson <pbrobinson at gmail.com>

Tested on the Jetson Nano and it now reboots as expected.

> ---
>  drivers/firmware/psci.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index e0d66d74f54d..23cf807591c4 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -67,11 +67,9 @@ static int psci_bind(struct udevice *dev)
>
>  static int psci_probe(struct udevice *dev)
>  {
> -       DECLARE_GLOBAL_DATA_PTR;
>         const char *method;
>
> -       method = fdt_stringlist_get(gd->fdt_blob, dev_of_offset(dev), "method",
> -                                   0, NULL);
> +       method = ofnode_read_string(dev_ofnode(dev), "method");
>         if (!method) {
>                 pr_warn("missing \"method\" property\n");
>                 return -ENXIO;
> --
> 2.17.1
>
Jon Hunter June 18, 2020, 3:47 p.m. UTC | #2
On 18/06/2020 12:54, Jon Hunter wrote:
> When CONFIG_OF_LIVE is enabled, dev_of_offset() cannot be used and
> if used returns an invalid offset. This causes the call to
> fdt_stringlist_get() in the psci_probe() to fail to read the 'method'
> property from the PSCI node for the device and hence prevents PSCI
> from working. Fix this by using the ofnode_read_string() API instead
> of the fdt_stringlist_get() because this will handle reading the
> property both when CONFIG_OF_LIVE is enabled or disabled.
> 
> Due to the above problem and since commit 81ea00838c68 ("efi_loader:
> PSCI reset and shutdown") was added, the EFI system reset has been
> broken for Tegra210 and Tegra196 platforms. This also fixes the EFI
> system reset for these Tegra platforms.

Oops, just spotted the above typo. Should be Tegra186 and not Tegra196
(which does not exist!). I can correct that.

Jon
Tom Warren June 18, 2020, 4:19 p.m. UTC | #3
No worries, I can fix it when I add them to u-boot-tegra. I have some other patches to add & generate a PR, I'll get it out by EOW.  TomR - do you want me to take this patch as well as the ARM: tegra: patch in my PR, or do you want Jon's first patch to go thru a different repo?

Tom
--
nvpublic

-----Original Message-----
From: Jonathan Hunter <jonathanh at nvidia.com> 
Sent: Thursday, June 18, 2020 8:47 AM
To: Tom Rini <trini at konsulko.com>; Tom Warren <TWarren at nvidia.com>
Cc: Stephen Warren <swarren at nvidia.com>; Thierry Reding <treding at nvidia.com>; Peter Robinson <pbrobinson at redhat.com>; Heinrich Schuchardt <xypron.glpk at gmx.de>; u-boot at lists.denx.de
Subject: Re: [PATCH 1/2] firmware: PSCI: Fix PSCI support for OF live trees


On 18/06/2020 12:54, Jon Hunter wrote:
> When CONFIG_OF_LIVE is enabled, dev_of_offset() cannot be used and if 
> used returns an invalid offset. This causes the call to
> fdt_stringlist_get() in the psci_probe() to fail to read the 'method'
> property from the PSCI node for the device and hence prevents PSCI 
> from working. Fix this by using the ofnode_read_string() API instead 
> of the fdt_stringlist_get() because this will handle reading the 
> property both when CONFIG_OF_LIVE is enabled or disabled.
> 
> Due to the above problem and since commit 81ea00838c68 ("efi_loader:
> PSCI reset and shutdown") was added, the EFI system reset has been 
> broken for Tegra210 and Tegra196 platforms. This also fixes the EFI 
> system reset for these Tegra platforms.

Oops, just spotted the above typo. Should be Tegra186 and not Tegra196 (which does not exist!). I can correct that.

Jon

--
nvpublic
Tom Rini June 18, 2020, 4:27 p.m. UTC | #4
On Thu, Jun 18, 2020 at 04:19:51PM +0000, Tom Warren wrote:

> No worries, I can fix it when I add them to u-boot-tegra. I have some other patches to add & generate a PR, I'll get it out by EOW.  TomR - do you want me to take this patch as well as the ARM: tegra: patch in my PR, or do you want Jon's first patch to go thru a different repo?

You can take them all, thanks!

> 
> Tom
> --
> nvpublic
> 
> -----Original Message-----
> From: Jonathan Hunter <jonathanh at nvidia.com> 
> Sent: Thursday, June 18, 2020 8:47 AM
> To: Tom Rini <trini at konsulko.com>; Tom Warren <TWarren at nvidia.com>
> Cc: Stephen Warren <swarren at nvidia.com>; Thierry Reding <treding at nvidia.com>; Peter Robinson <pbrobinson at redhat.com>; Heinrich Schuchardt <xypron.glpk at gmx.de>; u-boot at lists.denx.de
> Subject: Re: [PATCH 1/2] firmware: PSCI: Fix PSCI support for OF live trees
> 
> 
> On 18/06/2020 12:54, Jon Hunter wrote:
> > When CONFIG_OF_LIVE is enabled, dev_of_offset() cannot be used and if 
> > used returns an invalid offset. This causes the call to
> > fdt_stringlist_get() in the psci_probe() to fail to read the 'method'
> > property from the PSCI node for the device and hence prevents PSCI 
> > from working. Fix this by using the ofnode_read_string() API instead 
> > of the fdt_stringlist_get() because this will handle reading the 
> > property both when CONFIG_OF_LIVE is enabled or disabled.
> > 
> > Due to the above problem and since commit 81ea00838c68 ("efi_loader:
> > PSCI reset and shutdown") was added, the EFI system reset has been 
> > broken for Tegra210 and Tegra196 platforms. This also fixes the EFI 
> > system reset for these Tegra platforms.
> 
> Oops, just spotted the above typo. Should be Tegra186 and not Tegra196 (which does not exist!). I can correct that.
> 
> Jon
> 
> --
> nvpublic
diff mbox series

Patch

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index e0d66d74f54d..23cf807591c4 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -67,11 +67,9 @@  static int psci_bind(struct udevice *dev)
 
 static int psci_probe(struct udevice *dev)
 {
-	DECLARE_GLOBAL_DATA_PTR;
 	const char *method;
 
-	method = fdt_stringlist_get(gd->fdt_blob, dev_of_offset(dev), "method",
-				    0, NULL);
+	method = ofnode_read_string(dev_ofnode(dev), "method");
 	if (!method) {
 		pr_warn("missing \"method\" property\n");
 		return -ENXIO;