ARM: CPU hotplug: move cpu_killed completion to core code
PATCH 19/22 ARM: CPU hotplug: move cpu_killed completion to core code
Quoted 42 lines · On 3 December 2010 21:37, <[email protected]> wrote:
Date: Fri, 03 Dec 2010 20:25:22 +0000
From: Russell King - ARM Linux <[email protected]>
To: linux-arm-kernel at lists.infradead.org, ? ? ? Catalin Marinas ? ? ? ?<[email protected]>
Subject: [PATCH 19/22] ARM: CPU hotplug: movecpu_killedcompletion to ? ? ? ?core ? ?code
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"We always need to wait for the dying CPU to reach a safe state before taking it down, irrespective of the requirements of the platform. Move the completion code into the ARM SMP hotplug code rather than having each platform re-implement this.
Signed-off-by Russell King <[email protected]>---
?arch/arm/kernel/smp.c ? ? ? ? ? ? ?| ? 14 +++++++++++++- ?arch/arm/mach-omap2/omap-hotplug.c | ? ?8 ++------ ?arch/arm/mach-realview/hotplug.c ? | ? ?8 +------- ?arch/arm/mach-s5pv310/hotplug.c ? ?| ? ?8 +------- ?arch/arm/mach-tegra/hotplug.c ? ? ?| ? ?8 +------- ?arch/arm/mach-ux500/hotplug.c ? ? ?| ? ?8 +-------?6 files changed, 19 insertions(+), 35 deletions(-)
arch/arm/kernel/smp.c +0
-0@@ -24,6 +24,7 @@?#include <
linux/irq.h>
?#include <linux/percpu.h>
?#include <linux/clockchips.h>
+#include <linux/completion.h>?#include <
asm/atomic.h>
?#include <asm/cacheflush.h>arch/arm/kernel/smp.c +2
-0@@ -238,12 +239,20 @@ int __cpu_disable(void) ? ? ? ?return 0; ?} +static DECLARE_COMPLETION (cpu_died); +
Quoted 7 lines
?/*
?* called on the thread which is asking for a CPU to be shutdown - ?* waits until shutdown has completed, or it is timed out. ?*/
?void__cpu_die(unsigned int cpu)
?{
+ ? ? ? if (wait_for_completion_timeout(&cpu_died, 5000)) {
Shouldn't you test the opposite like with platform_cpu_kill below ?
Quoted 206 lines
+ ? ? ? ? ? ? ?
printk(KERN_ERR "CPU%u: cpu didn't die\n", cpu);
+ ? ? ? ? ? ? ? return;
+ ? ? ? }
+ ? ? ?printk(KERN_NOTICE "CPU%u: shutdown\n", cpu); +
? ? ? ?if (!platform_cpu_kill(cpu))
? ? ? ? ? ? ? ?printk("CPU%u: unable to kill\n", cpu); ?}arch/arm/kernel/smp.c +3
-0@@ -263,9 +272,12 @@ void __ref cpu_die(void) ? ? ? ?local_irq_disable(); ? ? ? ?idle_task_exit(); + ? ? ? /* Tell __cpu_die() that this CPU is now safe to dispose of */ + ? ? ? complete(&cpu_died); +? ? ? ?/*
? ? ? ? * actual CPU shutdown procedure is at least platform (if not
- ? ? ? ?* CPU) specific
+ ? ? ? ?* CPU) specific.
? ? ? ? */
? ? ? ?platform_cpu_die(cpu);arch/arm/mach-omap2/omap-hotplug.c +0
-0@@ -17,16 +17,13 @@?#include <
linux/kernel.h>
?#include <linux/errno.h>
?#include <linux/smp.h>
-#include <linux/completion.h>?#include <
asm/cacheflush.h>
?#include <mach/omap4-common.h>arch/arm/mach-omap2/omap-hotplug.c +0
-2-static DECLARE_COMPLETION (cpu_killed); -?int
platform_cpu_kill(unsigned int cpu)
?{
- ? ? ? returnwait_for_completion_timeout(&cpu_killed, 5000);
+ ? ? ? return 1;
?}?/*
arch/arm/mach-omap2/omap-hotplug.c +1
-2@@ -42,8 +39,7 @@ void platform_cpu_die(unsigned int cpu) ? ? ? ? ? ? ? ? ? ? ? ? ? this_cpu, cpu); ? ? ? ? ? ? ? ?BUG(); ? ? ? ?} - ? ? ? pr_notice("CPU%u: shutdown\n", cpu); - ? ? ? complete(&cpu_killed); + ? ? ? ?flush_cache_all(); ? ? ? ?dsb();arch/arm/mach-realview/hotplug.c +0
-0@@ -11,14 +11,11 @@?#include <
linux/kernel.h>
?#include <linux/errno.h>
?#include <linux/smp.h>
-#include <linux/completion.h>?#include <
asm/cacheflush.h>?extern volatile int
pen_release;arch/arm/mach-realview/hotplug.c +0
-2-static DECLARE_COMPLETION (cpu_killed); -?static inline void
cpu_enter_lowpower(void)
?{
? ? ? ?unsigned int v;arch/arm/mach-realview/hotplug.c +1
-1@@ -95,7 +92,7 @@ static inline void platform_do_lowpower(unsigned int cpu) ?int platform_cpu_kill(unsigned int cpu) ?{ - ? ? ? return wait_for_completion_timeout(&cpu_killed, 5000); + ? ? ? return 1; ?}?/*
arch/arm/mach-realview/hotplug.c +0
-0@@ -115,9 +112,6 @@ void platform_cpu_die(unsigned int cpu) ? ? ? ?}?#endif
- ? ? ?
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
- ? ? ?complete(&cpu_killed);
-
? ? ? ?/*
? ? ? ? * we're ready for shutdown now, so do it ? ? ? ? */arch/arm/mach-s5pv310/hotplug.c +0
-0@@ -13,14 +13,11 @@?#include <
linux/kernel.h>
?#include <linux/errno.h>
?#include <linux/smp.h>
-#include <linux/completion.h>?#include <
asm/cacheflush.h>?extern volatile int
pen_release;arch/arm/mach-s5pv310/hotplug.c +0
-2-static DECLARE_COMPLETION (cpu_killed); -?static inline void
cpu_enter_lowpower(void)
?{
? ? ? ?unsigned int v;arch/arm/mach-s5pv310/hotplug.c +1
-1@@ -98,7 +95,7 @@ static inline void platform_do_lowpower(unsigned int cpu) ?int platform_cpu_kill(unsigned int cpu) ?{ - ? ? ? return wait_for_completion_timeout(&cpu_killed, 5000); + ? ? ? return 1; ?}?/*
arch/arm/mach-s5pv310/hotplug.c +0
-0@@ -118,9 +115,6 @@ void platform_cpu_die(unsigned int cpu) ? ? ? ?}?#endif
- ? ? ?
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
- ? ? ?complete(&cpu_killed);
-
? ? ? ?/*
? ? ? ? * we're ready for shutdown now, so do it ? ? ? ? */arch/arm/mach-tegra/hotplug.c +0
-0@@ -11,12 +11,9 @@?#include <
linux/kernel.h>
?#include <linux/errno.h>
?#include <linux/smp.h>
-#include <linux/completion.h>?#include <
asm/cacheflush.h>arch/arm/mach-tegra/hotplug.c +0
-2-static DECLARE_COMPLETION (cpu_killed); -?static inline void
cpu_enter_lowpower(void)
?{
? ? ? ?unsigned int v;arch/arm/mach-tegra/hotplug.c +1
-1@@ -94,7 +91,7 @@ static inline void platform_do_lowpower(unsigned int cpu) ?int platform_cpu_kill(unsigned int cpu) ?{ - ? ? ? return wait_for_completion_timeout(&cpu_killed, 5000); + ? ? ? return 1; ?}?/*
arch/arm/mach-tegra/hotplug.c +0
-0@@ -114,9 +111,6 @@ void platform_cpu_die(unsigned int cpu) ? ? ? ?}?#endif
- ? ? ?
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
- ? ? ?complete(&cpu_killed);
-
? ? ? ?/*
? ? ? ? * we're ready for shutdown now, so do it ? ? ? ? */arch/arm/mach-ux500/hotplug.c +0
-0@@ -11,14 +11,11 @@?#include <
linux/kernel.h>
?#include <linux/errno.h>
?#include <linux/smp.h>
-#include <linux/completion.h>?#include <
asm/cacheflush.h>?extern volatile int
pen_release;arch/arm/mach-ux500/hotplug.c +0
-2-static DECLARE_COMPLETION (cpu_killed); -?static inline void
platform_do_lowpower(unsigned int cpu)?{
? ? ? ?flush_cache_all();arch/arm/mach-ux500/hotplug.c +1
-1@@ -38,7 +35,7 @@ static inline void platform_do_lowpower(unsigned int cpu) ?int platform_cpu_kill(unsigned int cpu) ?{ - ? ? ? return wait_for_completion_timeout(&cpu_killed, 5000); + ? ? ? return 1; ?}?/*
arch/arm/mach-ux500/hotplug.c +0
-0@@ -58,9 +55,6 @@ void platform_cpu_die(unsigned int cpu) ? ? ? ?}?#endif
- ? ? ?
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
- ? ? ?complete(&cpu_killed);
-
? ? ? ?/* directly enter low power state, skipping secure registers */ ? ? ? ?platform_do_lowpower(cpu);
?}
--
1.6.2.5
PATCH 19/22 ARM: CPU hotplug: move cpu_killed completion to core code
Quoted 10 lines · Vincent Guittot
Quoted 7 lines · On 3 December 2010 21:37, <[email protected]> wrote:
?/*
?* called on the thread which is asking for a CPU to be shutdown - ?* waits until shutdown has completed, or it is timed out. ?*/
?void__cpu_die(unsigned int cpu)
?{
+ ? ? ? if (wait_for_completion_timeout(&cpu_died, 5000)) {Shouldn't you test the opposite like with
platform_cpu_killbelow ?
Yes, I looked at that a number of times and couldn't make up my mind which way it was supposed to be. Oh the joys of half-missing documentation.