From: ebiederm@xmission.com (Eric W. Biederman)
To: "Brown, Len" <len.brown@intel.com>
Cc: Pierre Ossman <drzeus-list@drzeus.cx>,
acpi-devel@lists.sourceforge.net, ncunningham@cyclades.com,
Pavel Machek <pavel@ucw.cz>, Meelis Roos <mroos@linux.ee>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: reboot vs poweroff
Date: Sat, 10 Sep 2005 15:07:29 -0600 [thread overview]
Message-ID: <m1d5ngk4xa.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <F7DC2337C7631D4386A2DF6E8FB22B30047B8DAF@hdsmsx401.amr.corp.intel.com> (Len Brown's message of "Thu, 1 Sep 2005 14:23:31 -0400")
"Brown, Len" <len.brown@intel.com> writes:
>
>>Patch tested and works fine here. You should probably make a
>>note in the bugzilla so we don't get a conflicting merge
>>from the ACPI folks.
>
> One might also consider that it would be a good idea to
> send patches that break ACPI files to the ACPI maintainer
> and acpi-devel@lists.sourceforge.net before sending them
> to Linus...
OK hopefully this is my final version of this bug fix.
Eric
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -59,6 +59,10 @@ extern void machine_crash_shutdown(struc
* Architecture independent implemenations of sys_reboot commands.
*/
+extern void kernel_restart_prepare(char *cmd);
+extern void kernel_halt_prepare(void);
+extern void kernel_power_off_prepare(void);
+
extern void kernel_restart(char *cmd);
extern void kernel_halt(void);
extern void kernel_power_off(void);
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -17,12 +17,12 @@
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/mount.h>
+#include <linux/pm.h>
#include "power.h"
extern suspend_disk_method_t pm_disk_mode;
-extern struct pm_ops * pm_ops;
extern int swsusp_suspend(void);
extern int swsusp_write(void);
@@ -49,13 +49,11 @@ dev_t swsusp_resume_device;
static void power_down(suspend_disk_method_t mode)
{
- unsigned long flags;
int error = 0;
- local_irq_save(flags);
switch(mode) {
case PM_DISK_PLATFORM:
- device_shutdown();
+ kernel_power_off_prepare();
error = pm_ops->enter(PM_SUSPEND_DISK);
break;
case PM_DISK_SHUTDOWN:
diff --git a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -361,17 +361,35 @@ out_unlock:
return retval;
}
+/**
+ * emergency_restart - reboot the system
+ *
+ * Without shutting down any hardware or taking any locks
+ * reboot the system. This is called when we know we are in
+ * trouble so this is our best effort to reboot. This is
+ * safe to call in interrupt context.
+ */
void emergency_restart(void)
{
machine_emergency_restart();
}
EXPORT_SYMBOL_GPL(emergency_restart);
-void kernel_restart(char *cmd)
+/**
+ * kernel_restart - reboot the system
+ *
+ * Shutdown everything and perform a clean reboot.
+ * This is not safe to call in interrupt context.
+ */
+void kernel_restart_prepare(char *cmd)
{
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
device_shutdown();
+}
+void kernel_restart(char *cmd)
+{
+ kernel_restart_prepare(cmd);
if (!cmd) {
printk(KERN_EMERG "Restarting system.\n");
} else {
@@ -382,6 +400,12 @@ void kernel_restart(char *cmd)
}
EXPORT_SYMBOL_GPL(kernel_restart);
+/**
+ * kernel_kexec - reboot the system
+ *
+ * Move into place and start executing a preloaded standalone
+ * executable. If nothing was preloaded return an error.
+ */
void kernel_kexec(void)
{
#ifdef CONFIG_KEXEC
@@ -390,9 +414,7 @@ void kernel_kexec(void)
if (!image) {
return;
}
- notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
- system_state = SYSTEM_RESTART;
- device_shutdown();
+ kernel_restart_prepare(NULL);
printk(KERN_EMERG "Starting new kernel\n");
machine_shutdown();
machine_kexec(image);
@@ -400,21 +422,39 @@ void kernel_kexec(void)
}
EXPORT_SYMBOL_GPL(kernel_kexec);
-void kernel_halt(void)
+/**
+ * kernel_halt - halt the system
+ *
+ * Shutdown everything and perform a clean system halt.
+ */
+void kernel_halt_prepare(void)
{
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
system_state = SYSTEM_HALT;
device_shutdown();
+}
+void kernel_halt(void)
+{
+ kernel_halt_prepare();
printk(KERN_EMERG "System halted.\n");
machine_halt();
}
EXPORT_SYMBOL_GPL(kernel_halt);
-void kernel_power_off(void)
+/**
+ * kernel_power_off - power_off the system
+ *
+ * Shutdown everything and perform a clean system power_off.
+ */
+void kernel_power_off_prepare(void)
{
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
system_state = SYSTEM_POWER_OFF;
device_shutdown();
+}
+void kernel_power_off(void)
+{
+ kernel_power_off_prepare();
printk(KERN_EMERG "Power down.\n");
machine_power_off();
}
next parent reply other threads:[~2005-09-10 21:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <F7DC2337C7631D4386A2DF6E8FB22B30047B8DAF@hdsmsx401.amr.corp.intel.com>
2005-09-10 21:07 ` Eric W. Biederman [this message]
[not found] ` <m1d5ngk4xa.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-11 8:43 ` reboot vs poweroff Meelis Roos
[not found] ` <Pine.SOC.4.61.0509111140550.9218-ptEonEWSGqKptlylMvRsHA@public.gmane.org>
2005-09-11 8:53 ` Eric W. Biederman
2005-09-20 17:42 ` [PATCH 1/2] reboot: Comment and factor the main reboot functions Eric W. Biederman
[not found] ` <m14q8fhc02.fsf_-_-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-20 17:49 ` [PATCH 2/2] suspend: Cleanup calling of power off methods Eric W. Biederman
2005-09-20 21:06 ` Pavel Machek
[not found] ` <20050920210617.GA1779-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2005-09-21 2:08 ` Eric W. Biederman
2005-09-21 10:18 ` Pavel Machek
2005-09-21 13:50 ` Eric W. Biederman
[not found] ` <20050921101855.GD25297-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2005-09-21 16:35 ` Linus Torvalds
2005-09-21 17:28 ` Eric W. Biederman
[not found] ` <m1slvycotk.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-21 18:02 ` Andrew Morton
2005-09-21 17:36 ` Alexander Nyberg
2005-09-21 18:15 ` Andrew Morton
[not found] ` <20050921111523.4b007281.akpm-3NddpPZAyC0@public.gmane.org>
2005-09-21 19:45 ` Hugh Dickins
2005-09-21 18:35 ` Diego Calleja
[not found] ` <20050921203505.32cc714d.diegocg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2005-09-21 18:49 ` Andrew Morton
2005-09-21 19:54 ` Martin J. Bligh
2005-09-26 12:09 ` Diego Calleja
[not found] ` <20050926140900.d070b604.diegocg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2005-09-26 13:47 ` Martin J. Bligh
2005-09-21 20:16 ` Diego Calleja
2005-09-21 19:43 ` Russell King
[not found] ` <20050921194306.GC13246-f404yB8NqCZvn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2005-09-21 20:10 ` Andrew Morton
2005-09-22 7:15 ` Pierre Ossman
2005-09-22 8:10 ` [ACPI] " Rafael J. Wysocki
[not found] ` <43325A02.90208-p3sGCRWkH8CeZLLa646FqQ@public.gmane.org>
2005-09-22 9:30 ` Eric W. Biederman
[not found] ` <m14q8dcuvm.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-22 9:38 ` Russell King
2005-09-22 10:54 ` Pierre Ossman
[not found] ` <Pine.LNX.4.58.0509210930410.2553-hNm40g4Ew95AfugRpC6u6w@public.gmane.org>
2005-09-21 17:46 ` Andrew Morton
[not found] ` <20050921104615.2e8dd7d5.akpm-3NddpPZAyC0@public.gmane.org>
2005-09-21 18:08 ` Eric W. Biederman
2005-09-21 18:24 ` Andrew Morton
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=m1d5ngk4xa.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=acpi-devel@lists.sourceforge.net \
--cc=drzeus-list@drzeus.cx \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mroos@linux.ee \
--cc=ncunningham@cyclades.com \
--cc=pavel@ucw.cz \
/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