diff mbox

[U-Boot,v8,7/8] armv8: fsl-layerscape: Add support for efi_loader RTS reset

Message ID 1479340982-209521-8-git-send-email-agraf@suse.de
State Accepted
Delegated to: Alexander Graf
Headers show

Commit Message

Alexander Graf Nov. 17, 2016, 12:03 a.m. UTC
When implementing efi loader support, we can expose runtime services
for payloads. One such service is CPU reset.

This patch implements RTS CPU reset support for layerscape systems.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: York Sun <york.sun@nxp.com>

---

v4 -> v5:

  - Use __efi_runtime tags
---
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Comments

Alexander Graf Nov. 17, 2016, 12:12 p.m. UTC | #1
> When implementing efi loader support, we can expose runtime services
> for payloads. One such service is CPU reset.
> 
> This patch implements RTS CPU reset support for layerscape systems.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Reviewed-by: York Sun <york.sun@nxp.com>

Thanks, applied to efi-next

Alex
York Sun Nov. 17, 2016, 4:41 p.m. UTC | #2
On 11/16/2016 04:02 PM, Alexander Graf wrote:
> When implementing efi loader support, we can expose runtime services
> for payloads. One such service is CPU reset.
>
> This patch implements RTS CPU reset support for layerscape systems.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Reviewed-by: York Sun <york.sun@nxp.com>
>
> ---
>
> v4 -> v5:
>
>   - Use __efi_runtime tags
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> index b7a2e0c..0b516e3 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> @@ -17,6 +17,7 @@
>  #ifdef CONFIG_MP
>  #include <asm/arch/mp.h>
>  #endif
> +#include <efi_loader.h>
>  #include <fm_eth.h>
>  #include <fsl-mc/fsl_mc.h>
>  #ifdef CONFIG_FSL_ESDHC
> @@ -462,9 +463,10 @@ int timer_init(void)
>  	return 0;
>  }
>
> -void reset_cpu(ulong addr)
> +__efi_runtime_data u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
> +
> +void __efi_runtime reset_cpu(ulong addr)
>  {
> -	u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
>  	u32 val;
>
>  	/* Raise RESET_REQ_B */
> @@ -473,6 +475,33 @@ void reset_cpu(ulong addr)
>  	scfg_out32(rstcr, val);
>  }
>
> +#ifdef CONFIG_EFI_LOADER
> +
> +void __efi_runtime EFIAPI efi_reset_system(
> +		       enum efi_reset_type reset_type,
> +		       efi_status_t reset_status,
> +		       unsigned long data_size, void *reset_data)
> +{
> +	switch (reset_type) {
> +	case EFI_RESET_COLD:
> +	case EFI_RESET_WARM:
> +		reset_cpu(0);
> +		break;
> +	case EFI_RESET_SHUTDOWN:
> +		/* Nothing we can do */
> +		break;
> +	}
> +
> +	while (1) { }
> +}
> +
> +void efi_reset_system_init(void)
> +{
> +       efi_add_runtime_mmio(&rstcr, sizeof(*rstcr));
> +}
> +
> +#endif
> +
>  phys_size_t board_reserve_ram_top(phys_size_t ram_size)
>  {
>  	phys_size_t ram_top = ram_size;
>

I still have this compiling error

21: armv8: fsl-layerscape: Add support for efi_loader RTS reset
    aarch64:  +   ls1043aqds ls1043aqds_qspi ls1043aqds_nand 
ls1043aqds_lpuart ls1043aqds_sdcard_qspi ls1043aqds_nor_ddr3 
ls1043aqds_sdcard_ifc
+(ls1043aqds,ls1043aqds_qspi,ls1043aqds_nand,ls1043aqds_lpuart,ls1043aqds_sdcard_qspi,ls1043aqds_nor_ddr3,ls1043aqds_sdcard_ifc) 
arch/arm/cpu/armv8/fsl-layerscape/built-in.o: In function 
`efi_reset_system':
+(ls1043aqds,ls1043aqds_qspi,ls1043aqds_nand,ls1043aqds_lpuart,ls1043aqds_sdcard_qspi,ls1043aqds_nor_ddr3,ls1043aqds_sdcard_ifc) 
build/../arch/arm/cpu/armv8/fsl-layerscape/cpu.c:484: multiple 
definition of `efi_reset_system'
+(ls1043aqds,ls1043aqds_qspi,ls1043aqds_nand,ls1043aqds_lpuart,ls1043aqds_sdcard_qspi,ls1043aqds_nor_ddr3,ls1043aqds_sdcard_ifc) 
arch/arm/cpu/armv8/fwcall.o:build/../arch/arm/cpu/armv8/fwcall.c:128: 
first defined here
+(ls1043aqds,ls1043aqds_qspi,ls1043aqds_nand,ls1043aqds_lpuart,ls1043aqds_sdcard_qspi,ls1043aqds_nor_ddr3,ls1043aqds_sdcard_ifc) 
make[2]: *** [arch/arm/cpu/armv8/built-in.o] Error 1
+(ls1043aqds,ls1043aqds_qspi,ls1043aqds_nand,ls1043aqds_lpuart,ls1043aqds_sdcard_qspi,ls1043aqds_nor_ddr3,ls1043aqds_sdcard_ifc) 
make[1]: *** [arch/arm/cpu/armv8] Error 2
22: ls2080ardb: Convert to distro boot
+ exit 128

York
Alexander Graf Nov. 17, 2016, 4:43 p.m. UTC | #3
On 17/11/2016 17:41, york sun wrote:
> On 11/16/2016 04:02 PM, Alexander Graf wrote:
>> When implementing efi loader support, we can expose runtime services
>> for payloads. One such service is CPU reset.
>>
>> This patch implements RTS CPU reset support for layerscape systems.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> Reviewed-by: York Sun <york.sun@nxp.com>
>>
>> ---
>>
>> v4 -> v5:
>>
>>   - Use __efi_runtime tags
>> ---
>>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 33 +++++++++++++++++++++++++++++++--
>>  1 file changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
>> index b7a2e0c..0b516e3 100644
>> --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
>> +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
>> @@ -17,6 +17,7 @@
>>  #ifdef CONFIG_MP
>>  #include <asm/arch/mp.h>
>>  #endif
>> +#include <efi_loader.h>
>>  #include <fm_eth.h>
>>  #include <fsl-mc/fsl_mc.h>
>>  #ifdef CONFIG_FSL_ESDHC
>> @@ -462,9 +463,10 @@ int timer_init(void)
>>  	return 0;
>>  }
>>
>> -void reset_cpu(ulong addr)
>> +__efi_runtime_data u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
>> +
>> +void __efi_runtime reset_cpu(ulong addr)
>>  {
>> -	u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
>>  	u32 val;
>>
>>  	/* Raise RESET_REQ_B */
>> @@ -473,6 +475,33 @@ void reset_cpu(ulong addr)
>>  	scfg_out32(rstcr, val);
>>  }
>>
>> +#ifdef CONFIG_EFI_LOADER
>> +
>> +void __efi_runtime EFIAPI efi_reset_system(
>> +		       enum efi_reset_type reset_type,
>> +		       efi_status_t reset_status,
>> +		       unsigned long data_size, void *reset_data)
>> +{
>> +	switch (reset_type) {
>> +	case EFI_RESET_COLD:
>> +	case EFI_RESET_WARM:
>> +		reset_cpu(0);
>> +		break;
>> +	case EFI_RESET_SHUTDOWN:
>> +		/* Nothing we can do */
>> +		break;
>> +	}
>> +
>> +	while (1) { }
>> +}
>> +
>> +void efi_reset_system_init(void)
>> +{
>> +       efi_add_runtime_mmio(&rstcr, sizeof(*rstcr));
>> +}
>> +
>> +#endif
>> +
>>  phys_size_t board_reserve_ram_top(phys_size_t ram_size)
>>  {
>>  	phys_size_t ram_top = ram_size;
>>
>
> I still have this compiling error

Can you please try my efi-next branch? It should hopefully be properly 
fixed in there.


Alex
York Sun Nov. 17, 2016, 4:48 p.m. UTC | #4
On 11/17/2016 08:43 AM, Alexander Graf wrote:
>>>
>>
>> I still have this compiling error
>
> Can you please try my efi-next branch? It should hopefully be properly
> fixed in there.
>

I will try to find some time to. My server is busy these days. Don't you 
have the setup to run buildman?

For this patch, it adds efi_reset_system(). You already have it in 
arch/arm/cpu/armv8/fwcall.c.

York
Alexander Graf Nov. 17, 2016, 5 p.m. UTC | #5
On 17/11/2016 17:48, york sun wrote:
> On 11/17/2016 08:43 AM, Alexander Graf wrote:
>>>>
>>>
>>> I still have this compiling error
>>
>> Can you please try my efi-next branch? It should hopefully be properly
>> fixed in there.
>>
>
> I will try to find some time to. My server is busy these days. Don't you
> have the setup to run buildman?

I'm moving to a travis based workflow. Unfortunately travis is quite 
slow ;).

But yes, I've seen that problem and fixed it in efi-next.

> For this patch, it adds efi_reset_system(). You already have it in
> arch/arm/cpu/armv8/fwcall.c.

The problem is that those systems are not using PSCI. If they were, we 
could just use the generic PSCI based reset implementation. So instead 
we need to stub it out for FSL systems right now.

I'm still hoping we'll get to a point one day where all FSL systems 
simply have a working PSCI implementation and we can drop the special 
quirks :).


Alex
York Sun Nov. 17, 2016, 5:02 p.m. UTC | #6
On 11/17/2016 09:01 AM, Alexander Graf wrote:
>
>
> On 17/11/2016 17:48, york sun wrote:
>> On 11/17/2016 08:43 AM, Alexander Graf wrote:
>>>>>
>>>>
>>>> I still have this compiling error
>>>
>>> Can you please try my efi-next branch? It should hopefully be properly
>>> fixed in there.
>>>
>>
>> I will try to find some time to. My server is busy these days. Don't you
>> have the setup to run buildman?
>
> I'm moving to a travis based workflow. Unfortunately travis is quite
> slow ;).
>
> But yes, I've seen that problem and fixed it in efi-next.
>
>> For this patch, it adds efi_reset_system(). You already have it in
>> arch/arm/cpu/armv8/fwcall.c.
>
> The problem is that those systems are not using PSCI. If they were, we
> could just use the generic PSCI based reset implementation. So instead
> we need to stub it out for FSL systems right now.
>
> I'm still hoping we'll get to a point one day where all FSL systems
> simply have a working PSCI implementation and we can drop the special
> quirks :).
>

We are marching toward that direction. You can see some PSCI related 
patches and some PPA (our implementation of trusted-firmware) related 
patches.

York
Alexander Graf Nov. 17, 2016, 5:13 p.m. UTC | #7
On 17/11/2016 18:02, york sun wrote:
> On 11/17/2016 09:01 AM, Alexander Graf wrote:
>>
>>
>> On 17/11/2016 17:48, york sun wrote:
>>> On 11/17/2016 08:43 AM, Alexander Graf wrote:
>>>>>>
>>>>>
>>>>> I still have this compiling error
>>>>
>>>> Can you please try my efi-next branch? It should hopefully be properly
>>>> fixed in there.
>>>>
>>>
>>> I will try to find some time to. My server is busy these days. Don't you
>>> have the setup to run buildman?
>>
>> I'm moving to a travis based workflow. Unfortunately travis is quite
>> slow ;).
>>
>> But yes, I've seen that problem and fixed it in efi-next.
>>
>>> For this patch, it adds efi_reset_system(). You already have it in
>>> arch/arm/cpu/armv8/fwcall.c.
>>
>> The problem is that those systems are not using PSCI. If they were, we
>> could just use the generic PSCI based reset implementation. So instead
>> we need to stub it out for FSL systems right now.
>>
>> I'm still hoping we'll get to a point one day where all FSL systems
>> simply have a working PSCI implementation and we can drop the special
>> quirks :).
>>
>
> We are marching toward that direction. You can see some PSCI related
> patches and some PPA (our implementation of trusted-firmware) related
> patches.

So every time a system gets converted to PSCI, we can exclude it from 
the special efi_reset_system() implementation towards the generic PSCI one.

I'd appreciate if you could also be the second pair of eyes on patches 
to make sure we're moving them over when that moment comes.


Alex
diff mbox

Patch

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index b7a2e0c..0b516e3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -17,6 +17,7 @@ 
 #ifdef CONFIG_MP
 #include <asm/arch/mp.h>
 #endif
+#include <efi_loader.h>
 #include <fm_eth.h>
 #include <fsl-mc/fsl_mc.h>
 #ifdef CONFIG_FSL_ESDHC
@@ -462,9 +463,10 @@  int timer_init(void)
 	return 0;
 }
 
-void reset_cpu(ulong addr)
+__efi_runtime_data u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
+
+void __efi_runtime reset_cpu(ulong addr)
 {
-	u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;
 	u32 val;
 
 	/* Raise RESET_REQ_B */
@@ -473,6 +475,33 @@  void reset_cpu(ulong addr)
 	scfg_out32(rstcr, val);
 }
 
+#ifdef CONFIG_EFI_LOADER
+
+void __efi_runtime EFIAPI efi_reset_system(
+		       enum efi_reset_type reset_type,
+		       efi_status_t reset_status,
+		       unsigned long data_size, void *reset_data)
+{
+	switch (reset_type) {
+	case EFI_RESET_COLD:
+	case EFI_RESET_WARM:
+		reset_cpu(0);
+		break;
+	case EFI_RESET_SHUTDOWN:
+		/* Nothing we can do */
+		break;
+	}
+
+	while (1) { }
+}
+
+void efi_reset_system_init(void)
+{
+       efi_add_runtime_mmio(&rstcr, sizeof(*rstcr));
+}
+
+#endif
+
 phys_size_t board_reserve_ram_top(phys_size_t ram_size)
 {
 	phys_size_t ram_top = ram_size;