Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Provide fallback reboot/poweroff/halt implementations

If a machine-specific hook is not implemented for restart, poweroff,
or halt, fall back to halting secondary CPUs, disabling interrupts,
and spinning. In the case of restart, attempt to restart the system
via do_kernel_restart() (which will call any registered restart
handlers) before halting.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Maciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/9600/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Andrew Bresticker and committed by
Ralf Baechle
f45e388f ea925a72

+25
+25
arch/mips/kernel/reset.c
··· 11 11 #include <linux/pm.h> 12 12 #include <linux/types.h> 13 13 #include <linux/reboot.h> 14 + #include <linux/delay.h> 14 15 15 16 #include <asm/reboot.h> 16 17 ··· 30 29 { 31 30 if (_machine_restart) 32 31 _machine_restart(command); 32 + 33 + #ifdef CONFIG_SMP 34 + preempt_disable(); 35 + smp_send_stop(); 36 + #endif 37 + do_kernel_restart(command); 38 + mdelay(1000); 39 + pr_emerg("Reboot failed -- System halted\n"); 40 + local_irq_disable(); 41 + while (1); 33 42 } 34 43 35 44 void machine_halt(void) 36 45 { 37 46 if (_machine_halt) 38 47 _machine_halt(); 48 + 49 + #ifdef CONFIG_SMP 50 + preempt_disable(); 51 + smp_send_stop(); 52 + #endif 53 + local_irq_disable(); 54 + while (1); 39 55 } 40 56 41 57 void machine_power_off(void) 42 58 { 43 59 if (pm_power_off) 44 60 pm_power_off(); 61 + 62 + #ifdef CONFIG_SMP 63 + preempt_disable(); 64 + smp_send_stop(); 65 + #endif 66 + local_irq_disable(); 67 + while (1); 45 68 }