All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Hofstaedtler <ch@zeha.at>
To: x86@kernel.org
Cc: hpa@zytor.com, lenb@kernel.org, tglx@linutronix.de,
	linux-acpi@vger.kernel.org, venkatesh.pallipadi@intel.com,
	arjan@infradead.org, bruce.w.allan@intel.com,
	Christian Hofstaedtler <ch@zeha.at>
Subject: [PATCH] Default to ACPI reboots on newish X86 hardware
Date: Thu,  7 Jan 2010 21:03:13 +0100	[thread overview]
Message-ID: <1262894593-25563-1-git-send-email-ch@zeha.at> (raw)
In-Reply-To: <alpine.LFD.2.00.1001061433260.4086@localhost.localdomain>

Newer hardware is assumed to no longer reboot succesfully using the
keyboard controller, but needs to use ACPI instead.
To not cause problems with older hardware, only hardware with a BIOS
date 2006 or newer is considered for this choice. Broken BIOSes
reporting a BIOS date of 0 are not specially considered, and therefore
get the KBD reboot behaviour.

Also unifiy reboot_type selection code.

Signed-off-by: Christian Hofstaedtler <ch@zeha.at>
---
 arch/x86/include/asm/emergency-restart.h |    1 +
 arch/x86/kernel/reboot.c                 |   65 ++++++++++++++++++++++++------
 2 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
index cc70c1c..72ee23a 100644
--- a/arch/x86/include/asm/emergency-restart.h
+++ b/arch/x86/include/asm/emergency-restart.h
@@ -2,6 +2,7 @@
 #define _ASM_X86_EMERGENCY_RESTART_H
 
 enum reboot_type {
+	BOOT_UNDECIDED = '?',
 	BOOT_TRIPLE = 't',
 	BOOT_KBD = 'k',
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 1545bc0..5e78483 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",
@@ -270,13 +274,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
@@ -427,7 +424,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",
@@ -455,12 +453,53 @@ 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)
+{
+        int year;
+
+	/* Doesn't exist? Likely an old system */
+	if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) {
+		return 0;
+	}
+        /* 2006 was decided as the cut-off year. */
+	if (year < 2006) {
+		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.
+ *
+ * In any case, don't override user decisions. (reboot=...)
+ */
+static int __init reboot_init(void)
 {
-	dmi_check_system(pci_reboot_dmi_table);
+	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)
 {
-- 
1.6.4.4


  reply	other threads:[~2010-01-07 20:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-03 20:23 Linux* is not supported on the Intel(R) Desktop Board DP55KG - Kernel still hangs upon reboot Christian Hofstaedtler
2010-01-03 21:40 ` Justin Piszcz
2010-01-03 23:03   ` Arjan van de Ven
2010-01-03 23:34     ` Christian Hofstaedtler
2010-01-04  5:47     ` Yuhong Bao
2010-01-04 15:16       ` David John
2010-06-11  2:16         ` Yuhong Bao
2010-01-04 16:21     ` [PATCH] Add DMI quirk for Intel DP55KG mainboard Christian Hofstaedtler
2010-01-04 17:15       ` Len Brown
2010-01-04 17:30         ` H. Peter Anvin
2010-01-04 22:03           ` Len Brown
2010-01-05  2:15             ` Robert Hancock
2010-01-05  3:37               ` H. Peter Anvin
2010-01-05 12:30                 ` [PATCH] Default to ACPI reboots on newish X86 hardware Christian Hofstaedtler
2010-01-05 17:04                   ` H. Peter Anvin
2010-01-05 18:26                     ` Christian Hofstaedtler
2010-01-06  6:06                       ` H. Peter Anvin
2010-01-06 19:38                       ` Len Brown
2010-01-07 20:03                         ` Christian Hofstaedtler [this message]
2010-01-07 20:05                           ` Christian Hofstaedtler
2010-01-07 23:05                           ` H. Peter Anvin
2010-01-20  5:21                           ` Len Brown
2010-01-21 17:18                             ` [PATCH 1/2] x86: Unify reboot_type selection Christian Hofstaedtler
2010-01-21 17:18                               ` [PATCH 2/2] Default to ACPI reboots on newish X86 hardware Christian Hofstaedtler
2010-01-23 19:57                                 ` Len Brown
2010-01-21 18:29                               ` [PATCH 1/2] x86: Unify reboot_type selection H. Peter Anvin
2010-01-21 17:24                             ` [PATCH] Default to ACPI reboots on newish X86 hardware Christian Hofstaedtler
2010-01-05  1:45           ` [PATCH] Add DMI quirk for Intel DP55KG mainboard Arjan van de Ven
2010-01-06 14:36             ` Matthew Garrett
2010-01-06 19:26               ` Len Brown
2010-01-06 19:36                 ` Matthew Garrett
2010-01-06 20:22                   ` Len Brown
2010-01-06 20:29                     ` Matthew Garrett
2010-01-06 21:26                     ` H. Peter Anvin
2010-01-20  5:06                       ` Len Brown
2010-01-07  1:15                     ` Robert Hancock
2010-01-06  7:41         ` Pavel Machek
2010-01-06 14:51           ` Alan Cox

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=1262894593-25563-1-git-send-email-ch@zeha.at \
    --to=ch@zeha.at \
    --cc=arjan@infradead.org \
    --cc=bruce.w.allan@intel.com \
    --cc=hpa@zytor.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=venkatesh.pallipadi@intel.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.