MCPM/TC2 support for CPU powerdown synchronisation
Subsystems (3)
cover MCPM/TC2 support for CPU powerdown synchronisation
This series adds MCPM support for detecting when a CPU is safely powered down, and provides an implementation for TC2.
This is sufficient to for working kexec with real power management on TC2. To test it, you'll also need:
* CONFIG_KEXEC=y
* CONFIG_PROC_DEVICE_TREE=y
* CONFIG_MCPM=y
* CONFIG_ARCH_VEXPRESS_TC2_PM=y
* sufficiently new kexec-tools
(git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
v2.0.4 worked for me)To prevent CPUs from running off into the weeds across kexec, this series requires Lorenzo's patch
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/200917.html
(arm: vexpress: tc2: fix hotplug/idle/kexec race on cluster power down).
Dave Martin (3):
ARM: mcpm: Factor out logical-to-physical CPU translation
ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
ARM: vexpress/TC2: Implement MCPM power_down_finish()
arch/arm/common/mcpm_entry.c | 5 ++++ arch/arm/common/mcpm_platsmp.c | 27 +++++++++++++++--- arch/arm/include/asm/mcpm.h | 31 ++++++++++++++++++++ arch/arm/mach-vexpress/spc.c | 39 +++++++++++++++++++++++++ arch/arm/mach-vexpress/spc.h | 1 + arch/arm/mach-vexpress/tc2_pm.c | 60 +++++++++++++++++++++++++++++++++++---- 6 files changed, 154 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.9.5
RFC PATCH 1/3 ARM: mcpm: Factor out logical-to-physical CPU translation
This patch factors the logical-to-physical CPU translation out of mcpm_boot_secondary(), so that it can be reused elsewhere.
--- arch/arm/common/mcpm_platsmp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
arch/arm/common/mcpm_platsmp.c +13 -4
@@ -19,14 +19,23 @@#include <asm/smp.h> #include <asm/smp_plat.h> +static void cpu_to_pcpu (unsigned int cpu, +unsigned int *pcpu,unsigned int *pcluster) +{ +unsigned int mpidr; + + mpidr =cpu_logical_map (cpu); + *pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); + *pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +} +static int mcpm_boot_secondary (unsigned int cpu,struct task_struct *idle) { -unsigned int mpidr, pcpu, pcluster, ret; +unsigned int pcpu, pcluster, ret;extern void secondary_startup (void ); - mpidr =cpu_logical_map (cpu); - pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); - pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +cpu_to_pcpu (cpu, &pcpu, &pcluster); +pr_debug ("%s: logical CPU %d is physical CPU %d cluster %d\n" , __func__, cpu, pcpu, pcluster);
Signature · 1 line
1.7.9.5
RFC PATCH 1/3 ARM: mcpm: Factor out logical-to-physical CPU translation
Quoted 4 lines · Dave Martin
This patch factors the logical-to-physical CPU translation out of
mcpm_boot_secondary(), so that it can be reused elsewhere.Signed-off-by Dave Martin <[email protected]>
Quoted 39 lines
--- arch/arm/common/mcpm_platsmp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)arch/arm/common/mcpm_platsmp.c +13
-4@@ -19,14 +19,23 @@#include <asm/smp.h> #include <asm/smp_plat.h> +static void cpu_to_pcpu (unsigned int cpu, +unsigned int *pcpu,unsigned int *pcluster) +{ +unsigned int mpidr; + + mpidr =cpu_logical_map (cpu); + *pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); + *pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +} +static int mcpm_boot_secondary (unsigned int cpu,struct task_struct *idle) { -unsigned int mpidr, pcpu, pcluster, ret; +unsigned int pcpu, pcluster, ret;extern void secondary_startup (void ); - mpidr =cpu_logical_map (cpu); - pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); - pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +cpu_to_pcpu (cpu, &pcpu, &pcluster); +pr_debug ("%s: logical CPU %d is physical CPU %d cluster %d\n" , __func__, cpu, pcpu, pcluster);Signature · 1 line
1.7.9.5
RFC PATCH 2/3 ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
In reply to Dave MartinCPU hotplug and kexec rely on smp_ops.cpu_kill(), which is supposed to wait for the CPU to park or power down, and perform the last rites (such as disabling clocks etc., where the platform doesn't do this automatically).
kexec in particular is unsafe without performing this synchronisation to park secondaries. Without it, the secondaries might not be parked when kexec trashes the kernel.
There is no generic way to do this synchronisation, so a new mcpm platform_ops method power_down_finish() is added by this patch.
The new method is mandatory. A platform which provides no way to detect when CPUs are parked is likely broken.
--- arch/arm/common/mcpm_entry.c | 5 +++++ arch/arm/common/mcpm_platsmp.c | 10 ++++++++++ arch/arm/include/asm/mcpm.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)
arch/arm/common/mcpm_entry.c +5 -0
@@ -89,6 +89,11 @@ void mcpm_cpu_power_down(void)BUG (); } +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster) +{ +return platform_ops->power_down_finish (cpu, cluster); +} +void mcpm_cpu_suspend (u64 expected_residency) {phys_reset_t phys_reset;
arch/arm/common/mcpm_platsmp.c +10 -0
@@ -56,6 +56,15 @@ static void mcpm_secondary_init(unsigned int cpu)#ifdef CONFIG_HOTPLUG_CPU +static int mcpm_cpu_kill (unsigned int cpu) +{ +unsigned int pcpu, pcluster; + +cpu_to_pcpu (cpu, &pcpu, &pcluster); + +return mcpm_cpu_power_down_finish (pcpu, pcluster); +} +static int mcpm_cpu_disable (unsigned int cpu) {/*
@@ -82,6 +91,7 @@ static struct smp_operations __initdata mcpm_smp_ops = { .smp_boot_secondary = mcpm_boot_secondary, .smp_secondary_init = mcpm_secondary_init, #ifdef CONFIG_HOTPLUG_CPU + .cpu_kill = mcpm_cpu_kill, .cpu_disable = mcpm_cpu_disable, .cpu_die = mcpm_cpu_die, #endif
arch/arm/include/asm/mcpm.h +31 -0
@@ -78,10 +78,40 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster);* * This does not return. Re-entry in the kernel is expected via * mcpm_entry_point. +* +* The CPU is not necessarily truly halted until +* mcpu_cpu_power_down_finish() subsequently returns non-zero for the +* specified cpu. Until then, other CPUs should make sure they do not +* trash memory the target CPU might be executing/accessing. */ void mcpm_cpu_power_down (void );/** +* mcpm_cpu_power_down_finish - wait for a specified CPU to halt, and +* make sure it is powered off +* +* @cpu: CPU number within given cluster +* @cluster: cluster number for the CPU +* +* Call this function to ensure that a pending powerdown has taken +* effect and the CPU is safely parked before performing non-mcpm +* operations that may affect the CPU (such as kexec trashing the +* kernel text). +* +* It is *not* necessary to call this function if you only need to +* serialise a pending powerdown with mcpu_cpu_power_up() or a wakeup +* event. +* +* Do not call this function unless the specified CPU has already +* called mcpu_cpu_power_down() or has committed to doing so. +* +* @return: +* - zero if the CPU is in a safely parked state +* - nonzero otherwise (e.g., timeout) +*/ +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster); + +/** * mcpm_cpu_suspend - bring the calling CPU in a suspended state * * @expected_residency: duration in microseconds the CPU is expected
@@ -120,6 +150,7 @@ int mcpm_cpu_powered_up(void);struct mcpm_platform_ops {int (*power_up)(unsigned int cpu,unsigned int cluster);void (*power_down)(void ); +int (*power_down_finish)(unsigned int cpu,unsigned int cluster);void (*suspend)(u64 );void (*powered_up)(void ); };
Signature · 1 line
1.7.9.5
RFC PATCH 2/3 ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
Quoted 27 lines · Dave Martin
CPU hotplug and kexec rely on
smp_ops.cpu_kill(), which is supposed to wait for the CPU to park or power down, and perform the last rites (such as disabling clocks etc., where the platform doesn't do this automatically).kexec in particular is unsafe without performing this synchronisation to park secondaries. Without it, the secondaries might not be parked when kexec trashes the kernel.
There is no generic way to do this synchronisation, so a new mcpm
platform_opsmethodpower_down_finish()is added by this patch.The new method is mandatory. A platform which provides no way to detect when CPUs are parked is likely broken.
Signed-off-by Dave Martin <[email protected]>--- arch/arm/common/mcpm_entry.c | 5 +++++ arch/arm/common/mcpm_platsmp.c | 10 ++++++++++ arch/arm/include/asm/mcpm.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)arch/arm/common/mcpm_entry.c +0
-0
arch/arm/common/mcpm_entry.c void mcpm_cpu_power_down(void) · line 95
Quoted 7 lines
arch/arm/common/mcpm_entry.c +4
-0@@ -89,6 +89,11 @@ void mcpm_cpu_power_down(void)BUG (); } +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster) +{ +return platform_ops->power_down_finish (cpu, cluster); +}
Please make it return an error (non-zero return value) if platform_ops or platform_ops->power_down_finish is NULL. Otherwise this would oops the kernel.
There is a patch already handling the other cases in RMK's patch system.
Quoted 37 lines
arch/arm/common/mcpm_entry.c +1
-0+void mcpm_cpu_suspend (u64 expected_residency) {phys_reset_t phys_reset;arch/arm/common/mcpm_platsmp.c +10
-0@@ -56,6 +56,15 @@ static void mcpm_secondary_init(unsigned int cpu)#ifdef CONFIG_HOTPLUG_CPU +static int mcpm_cpu_kill (unsigned int cpu) +{ +unsigned int pcpu, pcluster; + +cpu_to_pcpu (cpu, &pcpu, &pcluster); + +return mcpm_cpu_power_down_finish (pcpu, pcluster); +} +static int mcpm_cpu_disable (unsigned int cpu) {/* @@ -82,6 +91,7 @@ static struct smp_operations __initdata mcpm_smp_ops = { .smp_boot_secondary = mcpm_boot_secondary, .smp_secondary_init = mcpm_secondary_init, #ifdef CONFIG_HOTPLUG_CPU + .cpu_kill = mcpm_cpu_kill, .cpu_disable = mcpm_cpu_disable, .cpu_die = mcpm_cpu_die, #endifarch/arm/include/asm/mcpm.h +0
-0
arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 83
Quoted 6 lines
arch/arm/include/asm/mcpm.h +3
-0@@ -78,10 +78,40 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster);* * This does not return. Re-entry in the kernel is expected via * mcpm_entry_point. +* +* The CPU is not necessarily truly halted until +* mcpu_cpu_power_down_finish() subsequently returns non-zero for the
s/mcpu/mcpm/
Quoted 9 lines
arch/arm/include/asm/mcpm.h +5
-0+* specified cpu. Until then, other CPUs should make sure they do not +* trash memory the target CPU might be executing/accessing. */ void mcpm_cpu_power_down (void );/** +* mcpm_cpu_power_down_finish - wait for a specified CPU to halt, and +* make sure it is powered off +*
arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 102
Quoted 10 lines
arch/arm/include/asm/mcpm.h +10
-0+* @cpu: CPU number within given cluster +* @cluster: cluster number for the CPU +* +* Call this function to ensure that a pending powerdown has taken +* effect and the CPU is safely parked before performing non-mcpm +* operations that may affect the CPU (such as kexec trashing the +* kernel text). +* +* It is *not* necessary to call this function if you only need to +* serialise a pending powerdown with mcpu_cpu_power_up() or a wakeup
Ditto.
arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 106
Quoted 4 lines
arch/arm/include/asm/mcpm.h +4
-0+* event. +* +* Do not call this function unless the specified CPU has already +* called mcpu_cpu_power_down() or has committed to doing so.
Ditto.
Quoted 22 lines
arch/arm/include/asm/mcpm.h +9
-0+* +* @return: +* - zero if the CPU is in a safely parked state +* - nonzero otherwise (e.g., timeout) +*/ +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster); + +/** * mcpm_cpu_suspend - bring the calling CPU in a suspended state * * @expected_residency: duration in microseconds the CPU is expected @@ -120,6 +150,7 @@ int mcpm_cpu_powered_up(void);struct mcpm_platform_ops {int (*power_up)(unsigned int cpu,unsigned int cluster);void (*power_down)(void ); +int (*power_down_finish)(unsigned int cpu,unsigned int cluster);void (*suspend)(u64 );void (*powered_up)(void ); };Signature · 1 line
1.7.9.5
RFC PATCH 2/3 ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
Quoted 41 lines · Nicolas Pitre
Quoted 27 lines · Dave Martin
CPU hotplug and kexec rely on
smp_ops.cpu_kill(), which is supposed to wait for the CPU to park or power down, and perform the last rites (such as disabling clocks etc., where the platform doesn't do this automatically).kexec in particular is unsafe without performing this synchronisation to park secondaries. Without it, the secondaries might not be parked when kexec trashes the kernel.
There is no generic way to do this synchronisation, so a new mcpm
platform_opsmethodpower_down_finish()is added by this patch.The new method is mandatory. A platform which provides no way to detect when CPUs are parked is likely broken.
Signed-off-by Dave Martin <[email protected]>--- arch/arm/common/mcpm_entry.c | 5 +++++ arch/arm/common/mcpm_platsmp.c | 10 ++++++++++ arch/arm/include/asm/mcpm.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)arch/arm/common/mcpm_entry.c +0
-0arch/arm/common/mcpm_entry.c void mcpm_cpu_power_down(void) · line 95
Quoted 7 lines
arch/arm/common/mcpm_entry.c +4
-0@@ -89,6 +89,11 @@ void mcpm_cpu_power_down(void)BUG (); } +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster) +{ +return platform_ops->power_down_finish (cpu, cluster); +}Please make it return an error (non-zero return value) if
platform_opsorplatform_ops->power_down_finishis NULL. Otherwise this would oops the kernel.
Quoted 1 line
There is a patch already handling the other cases in RMK's patch system.
OK -- I didn't pay enough attention as that went past.
I'll grab that patch and rebase onto it.
Do you have concerns about the mandatoriness of the new call? The alternative would be to check for it at registration time and set smp_ops.cpu_kill to NULL if the backend method isn't there.
But I really wouldn't want to encourage that until someone comes up with a good reason.
[...]
Quoted 34 lines
arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 83
Quoted 11 lines
arch/arm/include/asm/mcpm.h +3
-0@@ -78,10 +78,40 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster);* * This does not return. Re-entry in the kernel is expected via * mcpm_entry_point. +* +* The CPU is not necessarily truly halted until +* mcpu_cpu_power_down_finish() subsequently returns non-zero for the s/mcpu/mcpm/
Quoted 9 lines
arch/arm/include/asm/mcpm.h +5
-0+* specified cpu. Until then, other CPUs should make sure they do not +* trash memory the target CPU might be executing/accessing. */ void mcpm_cpu_power_down (void );/** +* mcpm_cpu_power_down_finish - wait for a specified CPU to halt, and +* make sure it is powered off +* arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 102
Quoted 10 lines
arch/arm/include/asm/mcpm.h +10
-0+* @cpu: CPU number within given cluster +* @cluster: cluster number for the CPU +* +* Call this function to ensure that a pending powerdown has taken +* effect and the CPU is safely parked before performing non-mcpm +* operations that may affect the CPU (such as kexec trashing the +* kernel text). +* +* It is *not* necessary to call this function if you only need to +* serialise a pending powerdown with mcpu_cpu_power_up() or a wakeup
Quoted 8 lines
Ditto.
arch/arm/include/asm/mcpm.h int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); · line 106
Quoted 4 lines
arch/arm/include/asm/mcpm.h +4
-0+* event. +* +* Do not call this function unless the specified CPU has already +* called mcpu_cpu_power_down() or has committed to doing so. Ditto.
Ummm, duh. Fixed -- thanks.
[...]
Cheers
---Dave
RFC PATCH 2/3 ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
Quoted 46 lines · Dave Martin
Quoted 41 lines · Nicolas Pitre
Quoted 27 lines · Dave Martin
CPU hotplug and kexec rely on
smp_ops.cpu_kill(), which is supposed to wait for the CPU to park or power down, and perform the last rites (such as disabling clocks etc., where the platform doesn't do this automatically).kexec in particular is unsafe without performing this synchronisation to park secondaries. Without it, the secondaries might not be parked when kexec trashes the kernel.
There is no generic way to do this synchronisation, so a new mcpm
platform_opsmethodpower_down_finish()is added by this patch.The new method is mandatory. A platform which provides no way to detect when CPUs are parked is likely broken.
Signed-off-by Dave Martin <[email protected]>--- arch/arm/common/mcpm_entry.c | 5 +++++ arch/arm/common/mcpm_platsmp.c | 10 ++++++++++ arch/arm/include/asm/mcpm.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)arch/arm/common/mcpm_entry.c +0
-0arch/arm/common/mcpm_entry.c void mcpm_cpu_power_down(void) · line 95
Quoted 7 lines
arch/arm/common/mcpm_entry.c +4
-0@@ -89,6 +89,11 @@ void mcpm_cpu_power_down(void)BUG (); } +int mcpm_cpu_power_down_finish (unsigned int cpu,unsigned int cluster) +{ +return platform_ops->power_down_finish (cpu, cluster); +}Please make it return an error (non-zero return value) if
platform_opsorplatform_ops->power_down_finishis NULL. Otherwise this would oops the kernel.Quoted 1 line
There is a patch already handling the other cases in RMK's patch system.
OK -- I didn't pay enough attention as that went past.
Quoted 8 lines
I'll grab that patch and rebase onto it.
Do you have concerns about the mandatoriness of the new call? The alternative would be to check for it at registration time and set smp_ops.cpu_kill to NULL if the backend method isn't there. But I really wouldn't want to encourage that until someone comes up with a good reason.
Agreed. If for some reasons this method is unneeded on some platform then the backend just needs to return success unconditionally, ideally with a comment explaining why it is so.
Nicolas
RFC PATCH 3/3 ARM: vexpress/TC2: Implement MCPM power_down_finish()
In reply to Dave MartinThis patch implements the power_down_finish() method for TC2, to enable the kernel to confirm when CPUs are safely powered down.
The information required for determining when a CPU is parked cannot be obtained from any single place, so a few sources of information must be combined:
* mcpm_cpu_power_down() must be pending for the CPU, so that we don't get confused by false STANDBYWFI positives arising from CPUidle. This is detected by waiting for the tc2_pm use count for the target CPU to reach 0.
* Either the SPC must report that the CPU has asserted STANDBYWFI, or the TC2 tile's reset control logic must be holding the CPU in reset.
Just checking for STANDBYWFI is not sufficient, because this signal is not latched when the the cluster is clamped off and powered down: the relevant status bits just drop to zero. This means that STANDBYWFI status cannot be used for reliable detection of the last CPU in a cluster reaching WFI.
This patch is required in order for kexec to work with MCPM on TC2.
---
The mdelay(1) in tc2_pm_power_down_finish() is arbitrary. The power controller can show millisecond response times in the worst case, and CPU hotplug is not expected to be performance-critical.
It may be wise to add a timeout to this function, but that's open to discussion.
arch/arm/mach-vexpress/spc.c | 39 +++++++++++++++++++++++++ arch/arm/mach-vexpress/spc.h | 1 + arch/arm/mach-vexpress/tc2_pm.c | 60 +++++++++++++++++++++++++++++++++++---- 3 files changed, 95 insertions(+), 5 deletions(-)
arch/arm/mach-vexpress/spc.c +39 -0
@@ -35,6 +35,10 @@/* SPC per-CPU mailboxes */ #define A15_BX_ADDR0 0x68#define A7_BX_ADDR0 0x78 +/* SPC CPU/cluster reset statue */ +#define STANDBYWFI_STAT 0x3c +#define STANDBYWFI_STAT_A15_CPU_MASK (cpu) (1 << (cpu)) +#define STANDBYWFI_STAT_A7_CPU_MASK (cpu) (1 << (3 + (cpu)))/* wake-up interrupt masks */ #define GBL_WAKEUP_INT_MSK (0x3 << 10)
@@ -157,6 +161,41 @@ void ve_spc_powerdown(u32 cluster, bool enable)writel_relaxed (enable, info->baseaddr + pwdrn_reg); } +static u32 standbywfi_cpu_mask (u32 cpu,u32 cluster) +{ +return cluster_is_a15 (cluster) ? +STANDBYWFI_STAT_A15_CPU_MASK (cpu) + :STANDBYWFI_STAT_A7_CPU_MASK (cpu); +} + +/** +* ve_spc_cpu_in_wfi(u32 cpu, u32 cluster) +* +* @cpu: mpidr[7:0] bitfield describing CPU affinity level within cluster +* @cluster: mpidr[15:8] bitfield describing cluster affinity level +* +* @return: non-zero if and only if the specified CPU is in WFI +* +* Take care when interpreting the result of this function: a CPU might +* be in WFI temporarily due to idle, and is not necessarily safely +* parked. +*/ +int ve_spc_cpu_in_wfi (u32 cpu,u32 cluster) +{ +int ret; +u32 mask =standbywfi_cpu_mask (cpu, cluster); + +if (cluster >=MAX_CLUSTERS ) +return 1 ; + + ret =readl_relaxed (info->baseaddr +STANDBYWFI_STAT ); + +pr_debug ("%s: PCFGREG[0x%X] = 0x%08X, mask = 0x%X\n" , + __func__,STANDBYWFI_STAT , ret, mask); + +return ret & mask; +} +int __init ve_spc_init (void __iomem *baseaddr,u32 a15_clusid) { info =kzalloc (sizeof (*info),GFP_KERNEL );
arch/arm/mach-vexpress/spc.h +1 -0
@@ -20,5 +20,6 @@ void ve_spc_global_wakeup_irq(bool set);void ve_spc_cpu_wakeup_irq (u32 cluster,u32 cpu,bool set);void ve_spc_set_resume_addr (u32 cluster,u32 cpu,u32 addr);void ve_spc_powerdown (u32 cluster,bool enable); +int ve_spc_cpu_in_wfi (u32 cpu,u32 cluster);#endif
arch/arm/mach-vexpress/tc2_pm.c +55 -5
95 lines not on this page · raw message
Signature · 1 line
1.7.9.5
RFC PATCH 3/3 ARM: vexpress/TC2: Implement MCPM power_down_finish()
Quoted 25 lines · Dave Martin
This patch implements the
power_down_finish()method for TC2, to enable the kernel to confirm when CPUs are safely powered down.The information required for determining when a CPU is parked cannot be obtained from any single place, so a few sources of information must be combined:
*
mcpm_cpu_power_down()must be pending for the CPU, so that we don't get confused by false STANDBYWFI positives arising from CPUidle. This is detected by waiting for thetc2_pmuse count for the target CPU to reach 0.* Either the SPC must report that the CPU has asserted STANDBYWFI, or the TC2 tile's reset control logic must be holding the CPU in reset.
Just checking for STANDBYWFI is not sufficient, because this signal is not latched when the the cluster is clamped off and powered down: the relevant status bits just drop to zero. This means that STANDBYWFI status cannot be used for reliable detection of the last CPU in a cluster reaching WFI.
This patch is required in order for kexec to work with MCPM on TC2.
Signed-off-by Dave Martin <[email protected]>
Quoted 8 lines
---
The mdelay(1) in
tc2_pm_power_down_finish()is arbitrary. The power controller can show millisecond response times in the worst case, and CPU hotplug is not expected to be performance-critical.It may be wise to add a timeout to this function, but that's open to discussion.
That would be a good idea. I'd suggest you reduce the polling loop to
something like 10 ms and bail out after one second. We've been
affected by funny STANDBYWFI
behaviors before.
Nicolas
RFC PATCH 3/3 ARM: vexpress/TC2: Implement MCPM power_down_finish()
Quoted 33 lines · Nicolas Pitre
Quoted 31 lines · Dave Martin
This patch implements the
power_down_finish()method for TC2, to enable the kernel to confirm when CPUs are safely powered down.The information required for determining when a CPU is parked cannot be obtained from any single place, so a few sources of information must be combined:
*
mcpm_cpu_power_down()must be pending for the CPU, so that we don't get confused by false STANDBYWFI positives arising from CPUidle. This is detected by waiting for thetc2_pmuse count for the target CPU to reach 0.* Either the SPC must report that the CPU has asserted STANDBYWFI, or the TC2 tile's reset control logic must be holding the CPU in reset.
Just checking for STANDBYWFI is not sufficient, because this signal is not latched when the the cluster is clamped off and powered down: the relevant status bits just drop to zero. This means that STANDBYWFI status cannot be used for reliable detection of the last CPU in a cluster reaching WFI.
This patch is required in order for kexec to work with MCPM on TC2.
Signed-off-by Dave Martin <[email protected]>---
The mdelay(1) in
tc2_pm_power_down_finish()is arbitrary. The power controller can show millisecond response times in the worst case, and CPU hotplug is not expected to be performance-critical.
Quoted 7 lines
Quoted 2 lines
It may be wise to add a timeout to this function, but that's open to discussion.
That would be a good idea. I'd suggest you reduce the polling loop to
something like 10 ms and bail out after one second. We've been
affected by funny STANDBYWFI
behaviors before.
OK, I'm happy to do that. I don't have a strong opinion on the correct answer here -- the main thing is to avoid thrashing the bus and wasting power, so even quite a short delay will help considerably.
I'll just loop 100 times and then give up and return 0.
So far as I've seen, it's very unlikely in practice that repeated polling is needed. The most likely cause is that cluster powerdown involves a lengthy drain of L2 within the blackout period.
Cheers
---Dave