Skip to content

Commit

Permalink
[POWERPC] PS3: Save power in busy loops on halt
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Geoff Levand <[email protected]>
Signed-off-by: Paul Mackerras <[email protected]>
  • Loading branch information
Geert Uytterhoeven authored and paulusmack committed Apr 1, 2008
1 parent 5761eaa commit ca052f7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
12 changes: 11 additions & 1 deletion arch/powerpc/platforms/ps3/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ static void ps3_power_off(void)
ps3_sys_manager_power_off(); /* never returns */
}

static void ps3_halt(void)
{
DBG("%s:%d\n", __func__, __LINE__);

smp_send_stop();
ps3_sys_manager_halt(); /* never returns */
}

static void ps3_panic(char *str)
{
DBG("%s:%d %s\n", __func__, __LINE__, str);
Expand All @@ -105,7 +113,8 @@ static void ps3_panic(char *str)
printk(" Please press POWER button.\n");
printk("\n");

while(1);
while(1)
lv1_pause(1);
}

#if defined(CONFIG_FB_PS3) || defined(CONFIG_FB_PS3_MODULE) || \
Expand Down Expand Up @@ -266,6 +275,7 @@ define_machine(ps3) {
.progress = ps3_progress,
.restart = ps3_restart,
.power_off = ps3_power_off,
.halt = ps3_halt,
#if defined(CONFIG_KEXEC)
.kexec_cpu_down = ps3_kexec_cpu_down,
.machine_kexec = default_machine_kexec,
Expand Down
30 changes: 20 additions & 10 deletions drivers/ps3/ps3-sys-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/reboot.h>

#include <asm/firmware.h>
#include <asm/lv1call.h>
#include <asm/ps3.h>

#include "vuart.h"
Expand Down Expand Up @@ -581,6 +582,23 @@ static int ps3_sys_manager_handle_msg(struct ps3_system_bus_device *dev)
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.
*
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down
16 changes: 10 additions & 6 deletions drivers/ps3/sys-manager-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <linux/kernel.h>
#include <asm/lv1call.h>
#include <asm/ps3.h>

/**
Expand Down Expand Up @@ -50,19 +51,22 @@ 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)
{
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);
}

5 changes: 3 additions & 2 deletions include/asm-powerpc/ps3.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ struct ps3_sys_manager_ops {
};

void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
void ps3_sys_manager_power_off(void);
void ps3_sys_manager_restart(void);
void __noreturn ps3_sys_manager_power_off(void);
void __noreturn ps3_sys_manager_restart(void);
void __noreturn ps3_sys_manager_halt(void);

struct ps3_prealloc {
const char *name;
Expand Down

0 comments on commit ca052f7

Please sign in to comment.