[U-Boot] [PATCH v5 6/8] ARMv7: PSCI: ls102xa: check ALREADY_ON or ON_PENDING for CPU_ON

Chen-Yu Tsai wens at csie.org
Tue Jun 28 06:30:16 CEST 2016


On Tue, Jun 14, 2016 at 3:01 PM,  <macro.wave.z at gmail.com> wrote:
> From: Hongbo Zhang <hongbo.zhang at nxp.com>
>
> For the robustness of codes, while powering on a CPU, it is better to check
> if the target CPU is already on or in the process of power on, if yes the
> power on routine shouldn't be executed further and should return with the
> corresponding status immediately.
>
> Signed-off-by: Hongbo Zhang <hongbo.zhang at nxp.com>
> ---
>  arch/arm/cpu/armv7/ls102xa/psci.S | 29 +++++++++++++++++++++++++++++
>  arch/arm/include/asm/psci.h       |  5 +++++
>  2 files changed, 34 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/ls102xa/psci.S b/arch/arm/cpu/armv7/ls102xa/psci.S
> index a4482e4..0188ade 100644
> --- a/arch/arm/cpu/armv7/ls102xa/psci.S
> +++ b/arch/arm/cpu/armv7/ls102xa/psci.S
> @@ -66,6 +66,22 @@ psci_cpu_on:
>         beq     out_psci_cpu_on
>         mov     r1, r0
>
> +       bl      psci_get_cpu_stack_top
> +       sub     r0, r0, #PSCI_CPU_STATUS_OFFSET
> +       ldr     r5, [r0]
> +
> +       cmp     r5, #PSCI_CPU_STATUS_ON
> +       moveq   r0, #ARM_PSCI_RET_ALREADY_ON
> +       beq     out_psci_cpu_on
> +
> +       cmp     r5, #PSCI_CPU_STATUS_ON_PENDING
> +       moveq   r0, #ARM_PSCI_RET_ON_PENDING
> +       beq     out_psci_cpu_on
> +
> +       mov     r5, #PSCI_CPU_STATUS_ON_PENDING
> +       str     r5, [r0]
> +       dsb
> +
>         bl      psci_cpu_on_common
>
>         @ Get DCFG base address
> @@ -123,6 +139,12 @@ holdoff_release:
>         rev     r6, r6
>         str     r6, [r4, #DCFG_CCSR_SCRATCHRW1]
>
> +       mov     r0, r1
> +       bl      psci_get_cpu_stack_top
> +       sub     r0, r0, #PSCI_CPU_STATUS_OFFSET
> +       mov     r5, #PSCI_CPU_STATUS_ON
> +       str     r5, [r0]
> +
>         isb
>         dsb
>
> @@ -137,6 +159,13 @@ out_psci_cpu_on:
>  psci_cpu_off:
>         bl      psci_cpu_off_common
>
> +       bl      psci_get_cpu_id
> +       bl      psci_get_cpu_stack_top
> +       sub     r0, r0, #PSCI_CPU_STATUS_OFFSET
> +       mov     r5, #PSCI_CPU_STATUS_OFF
> +       str     r5, [r0]
> +       dsb

psci_cpu_off_common flushes and disables caches, and turns off SMP.
So the code you're adding might not work as expected? ARM folks
might know more.

The rest looks good, though I expect them to be pulled out into
common helpers and rewritten in C. :)

Regards
ChenYu

> +
>  1:     wfi
>         b       1b
>
> diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
> index bedcd30..89a1ba5 100644
> --- a/arch/arm/include/asm/psci.h
> +++ b/arch/arm/include/asm/psci.h
> @@ -67,6 +67,11 @@
>  #define PSCI_PERCPU_STACK_SIZE         0x400
>  #define PSCI_TARGET_PC_OFFSET          (PSCI_PERCPU_STACK_SIZE - 4)
>  #define PSCI_CONTEXT_ID_OFFSET         (PSCI_PERCPU_STACK_SIZE - 8)
> +#define PSCI_CPU_STATUS_OFFSET         (PSCI_PERCPU_STACK_SIZE - 12)
> +
> +#define PSCI_CPU_STATUS_OFF            0
> +#define PSCI_CPU_STATUS_ON             1
> +#define PSCI_CPU_STATUS_ON_PENDING     2
>
>  #ifndef __ASSEMBLY__
>  int psci_update_dt(void *fdt);
> --
> 2.1.4
>


More information about the U-Boot mailing list