summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/reboot.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2010-03-30 12:39:01 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2010-03-30 12:39:04 +1100
commit240805ce395ee0dc9603b452d78c088b6f1f1490 (patch)
treee05a4ac64ce39731bc94dd47ab12903d0561d286 /arch/x86/kernel/reboot.c
parente9adec72504655387b3c854cae4968d1b1d4712a (diff)
parent22ef99c516ec973955bc36174cb534558ded3b72 (diff)
Merge remote branch 'acpi/test'
Diffstat (limited to 'arch/x86/kernel/reboot.c')
-rw-r--r--arch/x86/kernel/reboot.c71
1 files changed, 58 insertions, 13 deletions
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 8e1aac86b50c..0e3dfec01156 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -34,7 +34,7 @@ EXPORT_SYMBOL(pm_power_off);
static const struct desc_ptr no_idt = {};
static int reboot_mode;
-enum reboot_type reboot_type = BOOT_KBD;
+enum reboot_type reboot_type = BOOT_UNDECIDED;
int reboot_force;
#if defined(CONFIG_X86_32) && defined(CONFIG_SMP)
@@ -134,7 +134,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
return 0;
}
-static struct dmi_system_id __initdata reboot_dmi_table[] = {
+/*
+ * This table only gets used on x86_32, so only use with
+ * set_bios_reboot.
+ */
+static struct dmi_system_id __initdata reboot_dmi_table_x86_32[] = {
{ /* Handle problems with rebooting on Dell E520's */
.callback = set_bios_reboot,
.ident = "Dell E520",
@@ -279,13 +283,6 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
{ }
};
-static int __init reboot_init(void)
-{
- dmi_check_system(reboot_dmi_table);
- return 0;
-}
-core_initcall(reboot_init);
-
/* The following code and data reboots the machine by switching to real
mode and jumping to the BIOS reset entry point, as if the CPU has
really been reset. The previous version asked the keyboard
@@ -436,7 +433,8 @@ static int __init set_pci_reboot(const struct dmi_system_id *d)
return 0;
}
-static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
+/* This table gets used on x86_32 AND x86_64. */
+static struct dmi_system_id __initdata reboot_dmi_table_all[] = {
{ /* Handle problems with rebooting on Apple MacBook5 */
.callback = set_pci_reboot,
.ident = "Apple MacBook5",
@@ -472,12 +470,58 @@ static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
{ }
};
-static int __init pci_reboot_init(void)
+/* See if the Hardware is new enough to support ACPI reboots. */
+static int __init reboot_acpi_likey_supported(void)
{
- dmi_check_system(pci_reboot_dmi_table);
+ int year;
+
+ /* No BIOS date? We can safely say "Yes" here, because ACPI-reboot
+ * will only work when acpi=force was specified, else it falls back
+ * to KBD-reboots anyway. */
+ if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) {
+ return 1;
+ }
+ if (year == 0) {
+ return 1;
+ }
+
+ /* 2003 was decided as the cut-off year. */
+ if (year < 2003) {
+ return 0;
+ }
+ return 1;
+}
+
+/* Decide how we will reboot:
+ * - Check the X86_32-only quirks table.
+ * - Check the generic quirks table.
+ * - Check if we could use ACPI-based reboot.
+ * - Fall back to old-style Keyboard Controller reboot.
+ */
+static int __init reboot_init(void)
+{
+ /* don't override user decisions (reboot=...) */
+ if (reboot_type != BOOT_UNDECIDED)
+ return 0;
+
+#ifdef CONFIG_X86_32
+ dmi_check_system(reboot_dmi_table_x86_32);
+#endif /* CONFIG_X86_32 */
+ dmi_check_system(reboot_dmi_table_all);
+
+ if (reboot_type != BOOT_UNDECIDED)
+ return 0;
+
+ if (reboot_acpi_likey_supported()) {
+ reboot_type = BOOT_ACPI;
+ } else {
+ printk(KERN_INFO "Selecting old-style reboot for older hardware\n");
+ reboot_type = BOOT_KBD;
+ }
+
return 0;
}
-core_initcall(pci_reboot_init);
+core_initcall(reboot_init);
static inline void kb_wait(void)
{
@@ -551,6 +595,7 @@ static void native_machine_emergency_restart(void)
for (;;) {
/* Could also try the reset bit in the Hammer NB */
switch (reboot_type) {
+ case BOOT_UNDECIDED:
case BOOT_KBD:
mach_reboot_fixups(); /* for board specific fixups */