From ca052f7924141f34998ab440bb4d908dc021a46b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 27 Mar 2008 11:38:31 +1100 Subject: [POWERPC] PS3: Save power in busy loops on halt PS3 save power on halt: - Replace infinite busy loops by smarter loops calling lv1_pause() to save power. - Add ps3_halt() and ps3_sys_manager_halt(). - Add __noreturn annotations. Signed-off-by: Geert Uytterhoeven Signed-off-by: Geoff Levand Signed-off-by: Paul Mackerras --- drivers/ps3/ps3-sys-manager.c | 30 ++++++++++++++++++++---------- drivers/ps3/sys-manager-core.c | 16 ++++++++++------ 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'drivers/ps3') diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c index d4f6f960dd1..1260b01a536 100644 --- a/drivers/ps3/ps3-sys-manager.c +++ b/drivers/ps3/ps3-sys-manager.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "vuart.h" @@ -581,6 +582,23 @@ fail_id: return -EIO; } +static void ps3_sys_manager_fin(struct ps3_system_bus_device *dev) +{ + ps3_sys_manager_send_request_shutdown(dev); + + pr_emerg("System Halted, OK to turn off power\n"); + + while (ps3_sys_manager_handle_msg(dev)) { + /* pause until next DEC interrupt */ + lv1_pause(0); + } + + while (1) { + /* pause, ignoring DEC interrupt */ + lv1_pause(1); + } +} + /** * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. * @@ -602,12 +620,8 @@ static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev) ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, PS3_SM_WAKE_DEFAULT); - ps3_sys_manager_send_request_shutdown(dev); - - pr_emerg("System Halted, OK to turn off power\n"); - while (1) - ps3_sys_manager_handle_msg(dev); + ps3_sys_manager_fin(dev); } /** @@ -639,12 +653,8 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev) ps3_sys_manager_send_attr(dev, 0); ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT, PS3_SM_WAKE_DEFAULT); - ps3_sys_manager_send_request_shutdown(dev); - - pr_emerg("System Halted, OK to turn off power\n"); - while (1) - ps3_sys_manager_handle_msg(dev); + ps3_sys_manager_fin(dev); } /** diff --git a/drivers/ps3/sys-manager-core.c b/drivers/ps3/sys-manager-core.c index 31648f7d9ae..474225852b6 100644 --- a/drivers/ps3/sys-manager-core.c +++ b/drivers/ps3/sys-manager-core.c @@ -19,6 +19,7 @@ */ #include +#include #include /** @@ -50,10 +51,7 @@ void ps3_sys_manager_power_off(void) if (ps3_sys_manager_ops.power_off) ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev); - printk(KERN_EMERG "System Halted, OK to turn off power\n"); - local_irq_disable(); - while (1) - (void)0; + ps3_sys_manager_halt(); } void ps3_sys_manager_restart(void) @@ -61,8 +59,14 @@ void ps3_sys_manager_restart(void) if (ps3_sys_manager_ops.restart) ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev); - printk(KERN_EMERG "System Halted, OK to turn off power\n"); + ps3_sys_manager_halt(); +} + +void ps3_sys_manager_halt(void) +{ + pr_emerg("System Halted, OK to turn off power\n"); local_irq_disable(); while (1) - (void)0; + lv1_pause(1); } + -- cgit v1.2.3