浏览代码

ARM: call machine_shutdown() from machine_halt(), etc

x86 calls machine_shutdown() from the various machine_*() calls which
take the machine down ready for halting, restarting, etc, and uses
this to bring the system safely to a point where those actions can be
performed.  Such actions are stopping the secondary CPUs.

So, change the ARM implementation of these to reflect what x86 does.

This solves kexec problems on ARM SMP platforms, where the secondary
CPUs were left running across the kexec call.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Russell King 15 年之前
父节点
当前提交
3d3f78d752
共有 3 个文件被更改,包括 18 次插入9 次删除
  1. 0 4
      arch/arm/kernel/machine_kexec.c
  2. 11 1
      arch/arm/kernel/process.c
  3. 7 4
      arch/arm/kernel/smp.c

+ 0 - 4
arch/arm/kernel/machine_kexec.c

@@ -37,10 +37,6 @@ void machine_kexec_cleanup(struct kimage *image)
 {
 {
 }
 }
 
 
-void machine_shutdown(void)
-{
-}
-
 void machine_crash_shutdown(struct pt_regs *regs)
 void machine_crash_shutdown(struct pt_regs *regs)
 {
 {
 }
 }

+ 11 - 1
arch/arm/kernel/process.c

@@ -198,19 +198,29 @@ int __init reboot_setup(char *str)
 
 
 __setup("reboot=", reboot_setup);
 __setup("reboot=", reboot_setup);
 
 
-void machine_halt(void)
+void machine_shutdown(void)
 {
 {
+#ifdef CONFIG_SMP
+	smp_send_stop();
+#endif
 }
 }
 
 
+void machine_halt(void)
+{
+	machine_shutdown();
+	while (1);
+}
 
 
 void machine_power_off(void)
 void machine_power_off(void)
 {
 {
+	machine_shutdown();
 	if (pm_power_off)
 	if (pm_power_off)
 		pm_power_off();
 		pm_power_off();
 }
 }
 
 
 void machine_restart(char *cmd)
 void machine_restart(char *cmd)
 {
 {
+	machine_shutdown();
 	arm_pm_restart(reboot_mode, cmd);
 	arm_pm_restart(reboot_mode, cmd);
 }
 }
 
 

+ 7 - 4
arch/arm/kernel/smp.c

@@ -471,10 +471,13 @@ static DEFINE_SPINLOCK(stop_lock);
  */
  */
 static void ipi_cpu_stop(unsigned int cpu)
 static void ipi_cpu_stop(unsigned int cpu)
 {
 {
-	spin_lock(&stop_lock);
-	printk(KERN_CRIT "CPU%u: stopping\n", cpu);
-	dump_stack();
-	spin_unlock(&stop_lock);
+	if (system_state == SYSTEM_BOOTING ||
+	    system_state == SYSTEM_RUNNING) {
+		spin_lock(&stop_lock);
+		printk(KERN_CRIT "CPU%u: stopping\n", cpu);
+		dump_stack();
+		spin_unlock(&stop_lock);
+	}
 
 
 	set_cpu_online(cpu, false);
 	set_cpu_online(cpu, false);