From a3310bbd3add738c2b40bb4e4dc966cdea9d6a04 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Wed, 1 Feb 2006 03:06:08 -0800 Subject: [PATCH] sh: machine_halt()/machine_power_off() cleanups machine_halt() managed to trigger the soft lockup detection due to not disabling interrupts before going to sleep, so correct that. machine_power_off() should be using pm_power_off, which lets us drop the board-specific hacks from here. Signed-off-by: Paul Mundt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/sh/kernel/process.c | 54 +++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'arch') diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index a4dc2b532e10..9fd1723e6219 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -15,21 +15,18 @@ #include #include #include -#include #include +#include +#include #include #include #include +#include #include #include #include #include -#if defined(CONFIG_SH_HS7751RVOIP) -#include -#elif defined(CONFIG_SH_RTS7751R2D) -#include -#endif static int hlt_counter=0; @@ -37,6 +34,11 @@ int ubc_usercnt = 0; #define HARD_IDLE_TIMEOUT (HZ / 3) +void (*pm_idle)(void); + +void (*pm_power_off)(void); +EXPORT_SYMBOL(pm_power_off); + void disable_hlt(void) { hlt_counter++; @@ -51,17 +53,25 @@ void enable_hlt(void) EXPORT_SYMBOL(enable_hlt); +void default_idle(void) +{ + if (!hlt_counter) + cpu_sleep(); + else + cpu_relax(); +} + void cpu_idle(void) { /* endless idle loop with no priority at all */ while (1) { - if (hlt_counter) { - while (!need_resched()) - cpu_relax(); - } else { - while (!need_resched()) - cpu_sleep(); - } + void (*idle)(void) = pm_idle; + + if (!idle) + idle = default_idle; + + while (!need_resched()) + idle(); preempt_enable_no_resched(); schedule(); @@ -88,28 +98,16 @@ void machine_restart(char * __unused) void machine_halt(void) { -#if defined(CONFIG_SH_HS7751RVOIP) - unsigned short value; + local_irq_disable(); - value = ctrl_inw(PA_OUTPORTR); - ctrl_outw((value & 0xffdf), PA_OUTPORTR); -#elif defined(CONFIG_SH_RTS7751R2D) - ctrl_outw(0x0001, PA_POWOFF); -#endif while (1) cpu_sleep(); } void machine_power_off(void) { -#if defined(CONFIG_SH_HS7751RVOIP) - unsigned short value; - - value = ctrl_inw(PA_OUTPORTR); - ctrl_outw((value & 0xffdf), PA_OUTPORTR); -#elif defined(CONFIG_SH_RTS7751R2D) - ctrl_outw(0x0001, PA_POWOFF); -#endif + if (pm_power_off) + pm_power_off(); } void show_regs(struct pt_regs * regs) -- cgit v1.2.2