@@ -20,6 +20,7 @@
#include <linux/gpio/machine.h>
#include <asm/bootinfo.h>
#include <asm/idle.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
@@ -65,14 +66,12 @@ static void gpr_reset(char *c)
alchemy_gpio_direction_output(1, 0);
udelay(1);
alchemy_gpio_set_value(1, 1);
- while (1)
- cpu_wait();
+ cpu_relax_forever();
}
static void gpr_power_off(void)
{
- while (1)
- cpu_wait();
+ cpu_relax_forever();
}
void __init board_setup(void)
@@ -18,6 +18,7 @@
#include <linux/mtd/physmap.h>
#include <mtd/mtd-abi.h>
#include <asm/bootinfo.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
@@ -60,11 +61,7 @@ static void mtx1_reset(char *c)
static void mtx1_power_off(void)
{
- while (1)
- asm volatile (
- " .set mips32 \n"
- " wait \n"
- " .set mips0 \n");
+ cpu_relax_forever();
}
void __init board_setup(void)
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <asm/bootinfo.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
@@ -56,11 +57,7 @@ static void xxs1500_reset(char *c)
static void xxs1500_power_off(void)
{
- while (1)
- asm volatile (
- " .set mips32 \n"
- " wait \n"
- " .set mips0 \n");
+ cpu_relax_forever();
}
void __init board_setup(void)
@@ -13,6 +13,7 @@
#include <asm/bootinfo.h>
#include <asm/idle.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
@@ -56,8 +57,7 @@ static void db1x_power_off(void)
{
bcsr_write(BCSR_RESETS, 0);
bcsr_write(BCSR_SYSTEM, BCSR_SYSTEM_PWROFF | BCSR_SYSTEM_RESET);
- while (1) /* sit and spin */
- cpu_wait();
+ cpu_relax_forever(); /* sit and spin */
}
static void db1x_reset(char *c)
@@ -8,6 +8,7 @@
#include <linux/pm.h>
#include <linux/time.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/mach-ar7/ar7.h>
#include <asm/mach-ar7/prom.h>
@@ -21,8 +22,7 @@ static void ar7_machine_restart(char *command)
static void ar7_machine_halt(void)
{
- while (1)
- ;
+ cpu_relax_forever();
}
static void ar7_machine_power_off(void)
@@ -24,6 +24,7 @@
#include <asm/time.h> /* for mips_hpt_frequency */
#include <asm/reboot.h> /* for _machine_{restart,halt} */
#include <asm/mips_machine.h>
+#include <asm/processor.h>
#include <asm/prom.h>
#include <asm/fw/fw.h>
@@ -39,15 +40,12 @@ static void ath79_restart(char *command)
{
local_irq_disable();
ath79_device_reset_set(AR71XX_RESET_FULL_CHIP);
- for (;;)
- if (cpu_wait)
- cpu_wait();
+ cpu_relax_forever();
}
static void ath79_halt(void)
{
- while (1)
- cpu_wait();
+ cpu_relax_forever();
}
static void __init ath79_detect_sys_type(void)
@@ -39,6 +39,7 @@
#include <linux/bcma/bcma_soc.h>
#include <asm/bootinfo.h>
#include <asm/idle.h>
+#include <asm/processor.h>
#include <asm/prom.h>
#include <asm/reboot.h>
#include <asm/time.h>
@@ -77,8 +78,8 @@ static void bcm47xx_machine_restart(char *command)
break;
#endif
}
- while (1)
- cpu_relax();
+
+ cpu_relax_forever();
}
static void bcm47xx_machine_halt(void)
@@ -97,8 +98,8 @@ static void bcm47xx_machine_halt(void)
break;
#endif
}
- while (1)
- cpu_relax();
+
+ cpu_relax_forever();
}
#ifdef CONFIG_BCM47XX_SSB
@@ -14,6 +14,7 @@
#include <linux/pm.h>
#include <asm/bootinfo.h>
#include <asm/time.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/cacheflush.h>
#include <bcm63xx_board.h>
@@ -25,8 +26,8 @@
void bcm63xx_machine_halt(void)
{
pr_info("System halted\n");
- while (1)
- ;
+
+ cpu_relax_forever();
}
static void bcm6348_a1_reboot(void)
@@ -58,8 +59,8 @@ static void bcm6348_a1_reboot(void)
"jr\t%0"
:
: "r" (0xbfc00000));
- while (1)
- ;
+
+ cpu_relax_forever();
}
void bcm63xx_machine_reboot(void)
@@ -118,8 +119,7 @@ void bcm63xx_machine_reboot(void)
reg |= SYS_PLL_SOFT_RESET;
bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG);
}
- while (1)
- ;
+ cpu_relax_forever();
}
static void __bcm63xx_machine_reboot(char *p)
@@ -13,6 +13,7 @@
#include <linux/libfdt.h>
#include <asm/addrspace.h>
+#include <asm/processor.h>
/*
* These two variables specify the free mem region
@@ -41,8 +42,7 @@ void error(char *x)
puts(x);
puts("\n\n -- System halted");
- while (1)
- ; /* Halt */
+ cpu_relax_forever(); /* Halt */
}
/* activate the code for pre-boot environment */
@@ -18,6 +18,7 @@
#include <linux/kexec.h>
#include <asm/mmu_context.h>
+#include <asm/processor.h>
#include <asm/time.h>
#include <asm/setup.h>
@@ -354,8 +355,7 @@ void play_dead(void)
mb();
- while (1) /* core will be reset here */
- ;
+ cpu_relax_forever(); /* core will be reset here */
}
static void start_after_reset(void)
@@ -37,10 +37,7 @@ void cobalt_machine_halt(void)
led_trigger_event(power_off_led_trigger, LED_FULL);
local_irq_disable();
- while (1) {
- if (cpu_wait)
- cpu_wait();
- }
+ cpu_relax_forever();
}
void cobalt_machine_restart(char *command)
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
+#include <asm/processor.h>
#include <asm/time.h>
#include <asm/reboot.h>
@@ -34,13 +35,13 @@ static void markeins_machine_halt(void)
{
printk("EMMA2RH Mark-eins halted.\n");
markeins_led("halted.");
- while (1) ;
+ cpu_relax_forever();
}
static void markeins_machine_power_off(void)
{
markeins_led("poweroff.");
- while (1) ;
+ cpu_relax_forever();
}
static unsigned long __initdata emma2rh_clock[4] = {
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <asm/bootinfo.h>
+#include <asm/processor.h>
#include <asm/sgialib.h>
#include <asm/smp-ops.h>
@@ -34,8 +35,7 @@ void __init prom_init(void)
if (pb->magic != 0x53435241) {
printk(KERN_CRIT "Aieee, bad prom vector magic %08lx\n",
(unsigned long) pb->magic);
- while(1)
- ;
+ cpu_relax_forever();
}
prom_init_cmdline();
@@ -405,6 +405,12 @@ unsigned long get_wchan(struct task_struct *p);
#define cpu_relax() barrier()
#endif
+static inline void __noreturn cpu_relax_forever(void)
+{
+ for (;;)
+ cpu_relax();
+}
+
/*
* Return_address is a replacement for __builtin_return_address(count)
* which on certain architectures cannot reasonably be implemented in GCC
@@ -3,19 +3,14 @@
* Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
*/
+#include <asm/processor.h>
#include <asm/reboot.h>
#include "reset.h"
static void jz4740_halt(void)
{
- while (1) {
- __asm__(".set push;\n"
- ".set mips3;\n"
- "wait;\n"
- ".set pop;\n"
- );
- }
+ cpu_relax_forever();
}
void jz4740_reset_init(void)
@@ -10,6 +10,7 @@
#include <linux/pm.h>
#include <asm/idle.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <loongson.h>
@@ -45,10 +46,7 @@ static void loongson_restart(char *command)
void (*fw_restart)(void) = (void *)loongson_sysconf.restart_addr;
fw_restart();
- while (1) {
- if (cpu_wait)
- cpu_wait();
- }
+ cpu_relax_forever();
#endif
}
@@ -66,20 +64,14 @@ static void loongson_poweroff(void)
void (*fw_poweroff)(void) = (void *)loongson_sysconf.poweroff_addr;
fw_poweroff();
- while (1) {
- if (cpu_wait)
- cpu_wait();
- }
+ cpu_relax_forever();
#endif
}
static void loongson_halt(void)
{
pr_notice("\n\n** You can safely turn off the power now **\n\n");
- while (1) {
- if (cpu_wait)
- cpu_wait();
- }
+ cpu_relax_forever();
}
static int __init mips_reboot_setup(void)
@@ -4,6 +4,7 @@
*/
#include <linux/sched.h>
#include <asm/mipsregs.h>
+#include <asm/processor.h>
#include <asm/sibyte/sb1250.h>
#include <asm/sibyte/sb1250_regs.h>
@@ -244,8 +245,7 @@ asmlinkage void sb1_cache_error(void)
* undesirable.
*/
#ifdef CONFIG_SB1_CERR_STALL
- while (1)
- ;
+ cpu_relax_forever();
#else
panic("unhandled cache error");
#endif
@@ -5,6 +5,7 @@
*/
#include <linux/init.h>
#include <linux/pm.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/mach-pic32/pic32.h>
@@ -12,13 +13,7 @@
static void pic32_halt(void)
{
- while (1) {
- __asm__(".set push;\n"
- ".set arch=r4000;\n"
- "wait;\n"
- ".set pop;\n"
- );
- }
+ cpu_relax_forever();
}
static void pic32_machine_restart(char *command)
@@ -10,6 +10,7 @@
* Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
*/
#include <linux/reboot.h>
+#include <asm/processor.h>
#include <pnx833x.h>
void pnx833x_machine_restart(char *command)
@@ -20,9 +21,7 @@ void pnx833x_machine_restart(char *command)
void pnx833x_machine_halt(void)
{
- while (1)
- __asm__ __volatile__ ("wait");
-
+ cpu_relax_forever();
}
void pnx833x_machine_power_off(void)
@@ -17,6 +17,7 @@
#include <asm/io.h>
#include <asm/irq.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/sgialib.h>
#include <asm/sgi/ioc.h>
@@ -72,7 +73,7 @@ static void __noreturn sgi_machine_restart(char *command)
if (machine_state & MACHINE_SHUTTING_DOWN)
sgi_machine_power_off();
sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINIT;
- while (1);
+ cpu_relax_forever();
}
static void __noreturn sgi_machine_halt(void)
@@ -14,6 +14,7 @@
#include <linux/sched/debug.h>
#include <linux/sched/signal.h>
+#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/sn/addrs.h>
#include <asm/sn/arch.h>
@@ -73,8 +74,7 @@ int ip27_be_handler(struct pt_regs *regs, int is_fixup)
dump_hub_information(errst0, errst1);
show_regs(regs);
dump_tlb_all();
- while(1);
- force_sig(SIGBUS);
+ cpu_relax_forever();
}
void __init ip27_be_init(void)
@@ -19,6 +19,7 @@
#include <asm/io.h>
#include <asm/irq.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/sgialib.h>
#include <asm/sn/addrs.h>
@@ -26,12 +27,6 @@
#include <asm/sn/gda.h>
#include <asm/sn/sn0/hub.h>
-void machine_restart(char *command) __noreturn;
-void machine_halt(void) __noreturn;
-void machine_power_off(void) __noreturn;
-
-#define noreturn while(1); /* Silence gcc. */
-
/* XXX How to pass the reboot command to the firmware??? */
static void ip27_machine_restart(char *command)
{
@@ -50,7 +45,7 @@ static void ip27_machine_restart(char *command)
#else
LOCAL_HUB_S(NI_PORT_RESET, NPR_PORTRESET | NPR_LOCALRESET);
#endif
- noreturn;
+ cpu_relax_forever();
}
static void ip27_machine_halt(void)
@@ -64,13 +59,13 @@ static void ip27_machine_halt(void)
REMOTE_HUB_S(COMPACT_TO_NASID_NODEID(i), PROMOP_REG,
PROMOP_RESTART);
LOCAL_HUB_S(NI_PORT_RESET, NPR_PORTRESET | NPR_LOCALRESET);
- noreturn;
+ cpu_relax_forever();
}
static void ip27_machine_power_off(void)
{
/* To do ... */
- noreturn;
+ cpu_relax_forever();
}
void ip27_reboot_setup(void)
@@ -15,6 +15,7 @@
#include <asm/traps.h>
#include <linux/uaccess.h>
#include <asm/addrspace.h>
+#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/tlbdebug.h>
@@ -28,8 +29,7 @@ static int ip32_be_handler(struct pt_regs *regs, int is_fixup)
printk("Got %cbe at 0x%lx\n", data ? 'd' : 'i', regs->cp0_epc);
show_regs(regs);
dump_tlb_all();
- while(1);
- force_sig(SIGBUS);
+ cpu_relax_forever();
}
void __init ip32_be_init(void)
@@ -22,6 +22,7 @@
#include <asm/irq_cpu.h>
#include <asm/mipsregs.h>
+#include <asm/processor.h>
#include <asm/signal.h>
#include <asm/time.h>
#include <asm/ip32/crime.h>
@@ -355,7 +356,7 @@ static void ip32_unknown_interrupt(void)
printk("Please mail this report to linux-mips@linux-mips.org\n");
printk("Spinning...");
- while(1) ;
+ cpu_relax_forever();
}
/* CRIME 1.1 appears to deliver all interrupts to this one pin. */
@@ -13,6 +13,7 @@
#include <linux/smp.h>
#include <asm/bootinfo.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/sibyte/board.h>
@@ -65,7 +66,7 @@ static void __noreturn cfe_linux_exit(void *arg)
cfe_exit(warm, 0);
printk("cfe_exit returned??\n");
}
- while (1);
+ cpu_relax_forever();
}
static void __noreturn cfe_linux_restart(char *command)
@@ -21,6 +21,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/map.h>
+#include <asm/processor.h>
#include <asm/reboot.h>
#include <asm/txx9/generic.h>
#include <asm/txx9/pci.h>
@@ -31,8 +32,7 @@ static void rbtx4939_machine_restart(char *command)
local_irq_disable();
writeb(1, rbtx4939_reseten_addr);
writeb(1, rbtx4939_softreset_addr);
- while (1)
- ;
+ cpu_relax_forever();
}
static void __init rbtx4939_time_init(void)
@@ -72,7 +72,7 @@ static void vr41xx_restart(char *command)
{
local_irq_disable();
software_reset();
- while (1) ;
+ cpu_relax_forever();
}
static void vr41xx_halt(void)
Using cpu_relax_forever() can lower processor energy consumption when halting indefinitely. Signed-off-by: Fredrik Noring <noring@nocrew.org> --- arch/mips/alchemy/board-gpr.c | 7 +++---- arch/mips/alchemy/board-mtx1.c | 7 ++----- arch/mips/alchemy/board-xxs1500.c | 7 ++----- arch/mips/alchemy/devboards/platform.c | 4 ++-- arch/mips/ar7/setup.c | 4 ++-- arch/mips/ath79/setup.c | 8 +++----- arch/mips/bcm47xx/setup.c | 9 +++++---- arch/mips/bcm63xx/setup.c | 12 ++++++------ arch/mips/boot/compressed/decompress.c | 4 ++-- arch/mips/cavium-octeon/smp.c | 4 ++-- arch/mips/cobalt/reset.c | 5 +---- arch/mips/emma/markeins/setup.c | 5 +++-- arch/mips/fw/arc/init.c | 4 ++-- arch/mips/include/asm/processor.h | 6 ++++++ arch/mips/jz4740/reset.c | 9 ++------- arch/mips/loongson64/common/reset.c | 16 ++++------------ arch/mips/mm/cerr-sb1.c | 4 ++-- arch/mips/pic32/common/reset.c | 9 ++------- arch/mips/pnx833x/common/reset.c | 5 ++--- arch/mips/sgi-ip22/ip22-reset.c | 3 ++- arch/mips/sgi-ip27/ip27-berr.c | 4 ++-- arch/mips/sgi-ip27/ip27-reset.c | 13 ++++--------- arch/mips/sgi-ip32/ip32-berr.c | 4 ++-- arch/mips/sgi-ip32/ip32-irq.c | 3 ++- arch/mips/sibyte/common/cfe.c | 3 ++- arch/mips/txx9/rbtx4939/setup.c | 4 ++-- arch/mips/vr41xx/common/pmu.c | 2 +- 27 files changed, 70 insertions(+), 95 deletions(-)