From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Mark A. Greer" <mgreer@mvista.com>
Cc: linuxppc-dev <Linuxppc-dev@ozlabs.org>
Subject: Re: [PATCH 4/7] powerpc: Rework the machine_[restart|power_off|halt] routines
Date: Tue, 04 Dec 2007 18:20:36 +1100 [thread overview]
Message-ID: <1196752836.13230.262.camel@pasglop> (raw)
In-Reply-To: <20071204054718.GE27862@mag.az.mvista.com>
On Mon, 2007-12-03 at 22:47 -0700, Mark A. Greer wrote:
> From: Mark A. Greer <mgreer@mvista.com>
>
> Factor out common code from the machine_xxx routines and make them better
> handle a ppc_md hook that doesn't exist or fails better. In particular,
> have machine_power_off() try ppc_md.halt if ppc_md.power_off is NULL or fails,
> and have machine_halt() try to power off when ppc_md.halt is NULL or fails.
>
> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
Quick glance... looks fine.
> ---
> arch/powerpc/kernel/setup-common.c | 40 ++++++++++++++-------------
> 1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index 6adb5a1..1f8f9aa 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -105,17 +105,23 @@ void machine_shutdown(void)
> ppc_md.machine_shutdown();
> }
>
> -void machine_restart(char *cmd)
> +static void default_halt(const char *s)
> {
> - machine_shutdown();
> - if (ppc_md.restart)
> - ppc_md.restart(cmd);
> #ifdef CONFIG_SMP
> smp_send_stop();
> #endif
> - printk(KERN_EMERG "System Halted, OK to turn off power\n");
> + printk(KERN_EMERG "%s", s);
> local_irq_disable();
> - while (1) ;
> + while (1);
> +}
> +
> +void machine_restart(char *cmd)
> +{
> + machine_shutdown();
> + if (ppc_md.restart)
> + ppc_md.restart(cmd);
> + default_halt("System not restarted; halting instead.\n"
> + "OK to turn off power\n");
> }
>
> void machine_power_off(void)
> @@ -123,12 +129,10 @@ void machine_power_off(void)
> machine_shutdown();
> if (ppc_md.power_off)
> ppc_md.power_off();
> -#ifdef CONFIG_SMP
> - smp_send_stop();
> -#endif
> - printk(KERN_EMERG "System Halted, OK to turn off power\n");
> - local_irq_disable();
> - while (1) ;
> + printk(KERN_EMERG "System not powered off; halting instead.\n");
> + if (ppc_md.halt)
> + ppc_md.halt();
> + default_halt("OK to turn off power\n");
> }
> /* Used by the G5 thermal driver */
> EXPORT_SYMBOL_GPL(machine_power_off);
> @@ -141,12 +145,12 @@ void machine_halt(void)
> machine_shutdown();
> if (ppc_md.halt)
> ppc_md.halt();
> -#ifdef CONFIG_SMP
> - smp_send_stop();
> -#endif
> - printk(KERN_EMERG "System Halted, OK to turn off power\n");
> - local_irq_disable();
> - while (1) ;
> + if (ppc_md.power_off) {
> + printk(KERN_EMERG "System not halted; powering off instead.\n");
> + ppc_md.power_off();
> + printk(KERN_EMERG "Poweroff failed.\n");
> + }
> + default_halt("OK to turn off power\n");
> }
>
>
next prev parent reply other threads:[~2007-12-04 7:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 5:37 [RFC 0/7] powerpc: Rework pm_power_off & machine_[restart|power_off|halt] Mark A. Greer
2007-12-04 5:43 ` [PATCH 1/7] powerpc: Drivers should call machine_power_off not pm_power_off Mark A. Greer
2007-12-04 5:44 ` [PATCH 2/7] powerpc: xmon should call machine_xxx not ppc_md.xxx directly Mark A. Greer
2007-12-04 5:45 ` [PATCH 3/7] powerpc: ras.c should call machine_power_off() Mark A. Greer
2007-12-04 5:47 ` [PATCH 4/7] powerpc: Rework the machine_[restart|power_off|halt] routines Mark A. Greer
2007-12-04 7:20 ` Benjamin Herrenschmidt [this message]
2007-12-04 5:48 ` [PATCH 5/7] powerpc: Replace ppc_md.power_off with pm_power_off Mark A. Greer
2007-12-04 7:23 ` Benjamin Herrenschmidt
2007-12-04 18:01 ` Mark A. Greer
2007-12-04 19:55 ` Benjamin Herrenschmidt
2007-12-04 20:05 ` Grant Likely
2007-12-04 20:24 ` Benjamin Herrenschmidt
2007-12-05 0:07 ` Mark A. Greer
2007-12-04 5:49 ` [PATCH 6/7] powerpc: Remove redundant power_off and halt routines Mark A. Greer
2007-12-04 5:50 ` [PATCH 7/7] powerpc: Remove incorrect panic() calls Mark A. Greer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1196752836.13230.262.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=Linuxppc-dev@ozlabs.org \
--cc=mgreer@mvista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).