mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter
@ 2022-11-05 12:11 Ahmad Fatoum
  2022-11-05 12:11 ` [PATCH master v2 2/2] ARM: psci: client: don't hardcode method smc in fixup Ahmad Fatoum
  2022-11-07  7:48 ` [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-05 12:11 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We currently assume PSCI fixups to always be of method smc, but this is
not true when barebox fixes up the node while running under QEMU.

In preparation for handling QEMU boot properly when psci-client driver
is enabled, give of_psci_fixup an extra parameter.

No functional change.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
  - new patch
---
 arch/arm/cpu/psci-client.c     | 2 +-
 arch/arm/cpu/psci-of.c         | 5 +++--
 arch/arm/cpu/psci.c            | 2 +-
 arch/arm/include/asm/psci.h    | 3 ++-
 arch/arm/mach-layerscape/ppa.c | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/psci-client.c b/arch/arm/cpu/psci-client.c
index 7d5b3768b59e..613280ad3f23 100644
--- a/arch/arm/cpu/psci-client.c
+++ b/arch/arm/cpu/psci-client.c
@@ -110,7 +110,7 @@ static u32 invoke_psci_fn_smc(ulong function, ulong arg0, ulong arg1, ulong arg2
 
 static int of_psci_do_fixup(struct device_node *root, void *context)
 {
-	return of_psci_fixup(root, *(u32 *)context);
+	return of_psci_fixup(root, *(u32 *)context, "smc");
 }
 
 static int __init psci_probe(struct device_d *dev)
diff --git a/arch/arm/cpu/psci-of.c b/arch/arm/cpu/psci-of.c
index ef83b0edee69..be16b08617ec 100644
--- a/arch/arm/cpu/psci-of.c
+++ b/arch/arm/cpu/psci-of.c
@@ -7,7 +7,8 @@
 #include <asm/psci.h>
 #include <linux/arm-smccc.h>
 
-int of_psci_fixup(struct device_node *root, unsigned long psci_version)
+int of_psci_fixup(struct device_node *root, unsigned long psci_version,
+		  const char *method)
 {
 	struct device_node *psci;
 	int ret;
@@ -46,7 +47,7 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version)
 	if (ret)
 		return ret;
 
-	ret = of_property_write_string(psci, "method", "smc");
+	ret = of_property_write_string(psci, "method", method);
 	if (ret)
 		return ret;
 
diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index d1056e0659da..70c97e03a5ff 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -189,7 +189,7 @@ static int of_psci_do_fixup(struct device_node *root, void *unused)
 	if (bootm_arm_security_state() < ARM_STATE_NONSECURE)
 		return 0;
 
-	return of_psci_fixup(root, ARM_PSCI_VER_1_0);
+	return of_psci_fixup(root, ARM_PSCI_VER_1_0, "smc");
 }
 
 int psci_cpu_entry_c(void)
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index 3c1d046eb990..dbb9adfc3e43 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -144,6 +144,7 @@ static inline int psci_printf(const char *fmt, ...)
 
 int psci_get_cpu_id(void);
 
-int of_psci_fixup(struct device_node *root, unsigned long psci_version);
+int of_psci_fixup(struct device_node *root, unsigned long psci_version,
+		  const char *method);
 
 #endif /* __ARM_PSCI_H__ */
diff --git a/arch/arm/mach-layerscape/ppa.c b/arch/arm/mach-layerscape/ppa.c
index d962fba75105..144d0524754b 100644
--- a/arch/arm/mach-layerscape/ppa.c
+++ b/arch/arm/mach-layerscape/ppa.c
@@ -46,7 +46,7 @@ static int of_psci_do_fixup(struct device_node *root, void *unused)
 		break;
 	}
 
-	return of_psci_fixup(root, psci_version);
+	return of_psci_fixup(root, psci_version, "smc");
 }
 
 static int ppa_init(void *ppa, size_t ppa_size, void *sec_firmware_addr)
-- 
2.37.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master v2 2/2] ARM: psci: client: don't hardcode method smc in fixup
  2022-11-05 12:11 [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Ahmad Fatoum
@ 2022-11-05 12:11 ` Ahmad Fatoum
  2022-11-07  7:48 ` [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-05 12:11 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

When barebox is booted as QEMU -kernel, PSCI will have method = "hvc",
because QEMU will act as Hypervisor. barebox handles this correctly and
will use hvc instead of smc, but of_psci_fixup() always fixes up
method = "smc" thereby breaking kernel boot.

Fix this by forwarding the method read from barebox DT into the kernel
DT.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
  - instead of avoiding fixup, just do it with the method read from DT
  - Drop the other patches. There are nice to have, but can follow
    later
---
 arch/arm/cpu/psci-client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/psci-client.c b/arch/arm/cpu/psci-client.c
index 613280ad3f23..f9b1c684bfe5 100644
--- a/arch/arm/cpu/psci-client.c
+++ b/arch/arm/cpu/psci-client.c
@@ -108,9 +108,9 @@ static u32 invoke_psci_fn_smc(ulong function, ulong arg0, ulong arg1, ulong arg2
 	return res.a0;
 }
 
-static int of_psci_do_fixup(struct device_node *root, void *context)
+static int of_psci_do_fixup(struct device_node *root, void *method)
 {
-	return of_psci_fixup(root, *(u32 *)context, "smc");
+	return of_psci_fixup(root, version, (const void *)method);
 }
 
 static int __init psci_probe(struct device_d *dev)
@@ -156,7 +156,7 @@ static int __init psci_probe(struct device_d *dev)
 		 version >> 16, version & 0xffff);
 
 	if (actual_version != of_version)
-		of_register_fixup(of_psci_do_fixup, &version);
+		of_register_fixup(of_psci_do_fixup, (void *)method);
 
 	ret = poweroff_handler_register_fn(psci_poweroff);
 	if (ret)
-- 
2.37.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter
  2022-11-05 12:11 [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Ahmad Fatoum
  2022-11-05 12:11 ` [PATCH master v2 2/2] ARM: psci: client: don't hardcode method smc in fixup Ahmad Fatoum
@ 2022-11-07  7:48 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-11-07  7:48 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Sat, Nov 05, 2022 at 01:11:53PM +0100, Ahmad Fatoum wrote:
> We currently assume PSCI fixups to always be of method smc, but this is
> not true when barebox fixes up the node while running under QEMU.
> 
> In preparation for handling QEMU boot properly when psci-client driver
> is enabled, give of_psci_fixup an extra parameter.
> 
> No functional change.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> v1 -> v2:
>   - new patch
> ---
>  arch/arm/cpu/psci-client.c     | 2 +-
>  arch/arm/cpu/psci-of.c         | 5 +++--
>  arch/arm/cpu/psci.c            | 2 +-
>  arch/arm/include/asm/psci.h    | 3 ++-
>  arch/arm/mach-layerscape/ppa.c | 2 +-
>  5 files changed, 8 insertions(+), 6 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/cpu/psci-client.c b/arch/arm/cpu/psci-client.c
> index 7d5b3768b59e..613280ad3f23 100644
> --- a/arch/arm/cpu/psci-client.c
> +++ b/arch/arm/cpu/psci-client.c
> @@ -110,7 +110,7 @@ static u32 invoke_psci_fn_smc(ulong function, ulong arg0, ulong arg1, ulong arg2
>  
>  static int of_psci_do_fixup(struct device_node *root, void *context)
>  {
> -	return of_psci_fixup(root, *(u32 *)context);
> +	return of_psci_fixup(root, *(u32 *)context, "smc");
>  }
>  
>  static int __init psci_probe(struct device_d *dev)
> diff --git a/arch/arm/cpu/psci-of.c b/arch/arm/cpu/psci-of.c
> index ef83b0edee69..be16b08617ec 100644
> --- a/arch/arm/cpu/psci-of.c
> +++ b/arch/arm/cpu/psci-of.c
> @@ -7,7 +7,8 @@
>  #include <asm/psci.h>
>  #include <linux/arm-smccc.h>
>  
> -int of_psci_fixup(struct device_node *root, unsigned long psci_version)
> +int of_psci_fixup(struct device_node *root, unsigned long psci_version,
> +		  const char *method)
>  {
>  	struct device_node *psci;
>  	int ret;
> @@ -46,7 +47,7 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version)
>  	if (ret)
>  		return ret;
>  
> -	ret = of_property_write_string(psci, "method", "smc");
> +	ret = of_property_write_string(psci, "method", method);
>  	if (ret)
>  		return ret;
>  
> diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
> index d1056e0659da..70c97e03a5ff 100644
> --- a/arch/arm/cpu/psci.c
> +++ b/arch/arm/cpu/psci.c
> @@ -189,7 +189,7 @@ static int of_psci_do_fixup(struct device_node *root, void *unused)
>  	if (bootm_arm_security_state() < ARM_STATE_NONSECURE)
>  		return 0;
>  
> -	return of_psci_fixup(root, ARM_PSCI_VER_1_0);
> +	return of_psci_fixup(root, ARM_PSCI_VER_1_0, "smc");
>  }
>  
>  int psci_cpu_entry_c(void)
> diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
> index 3c1d046eb990..dbb9adfc3e43 100644
> --- a/arch/arm/include/asm/psci.h
> +++ b/arch/arm/include/asm/psci.h
> @@ -144,6 +144,7 @@ static inline int psci_printf(const char *fmt, ...)
>  
>  int psci_get_cpu_id(void);
>  
> -int of_psci_fixup(struct device_node *root, unsigned long psci_version);
> +int of_psci_fixup(struct device_node *root, unsigned long psci_version,
> +		  const char *method);
>  
>  #endif /* __ARM_PSCI_H__ */
> diff --git a/arch/arm/mach-layerscape/ppa.c b/arch/arm/mach-layerscape/ppa.c
> index d962fba75105..144d0524754b 100644
> --- a/arch/arm/mach-layerscape/ppa.c
> +++ b/arch/arm/mach-layerscape/ppa.c
> @@ -46,7 +46,7 @@ static int of_psci_do_fixup(struct device_node *root, void *unused)
>  		break;
>  	}
>  
> -	return of_psci_fixup(root, psci_version);
> +	return of_psci_fixup(root, psci_version, "smc");
>  }
>  
>  static int ppa_init(void *ppa, size_t ppa_size, void *sec_firmware_addr)
> -- 
> 2.37.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-07  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05 12:11 [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Ahmad Fatoum
2022-11-05 12:11 ` [PATCH master v2 2/2] ARM: psci: client: don't hardcode method smc in fixup Ahmad Fatoum
2022-11-07  7:48 ` [PATCH master v2 1/2] ARM: psci: make PSCI method a of_psci_fixup parameter Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox