From patchwork Tue Jan 5 12:30:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Hofstaedtler X-Patchwork-Id: 70999 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o05CmoKN025516 for ; Tue, 5 Jan 2010 12:49:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640Ab0AEMst (ORCPT ); Tue, 5 Jan 2010 07:48:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753551Ab0AEMst (ORCPT ); Tue, 5 Jan 2010 07:48:49 -0500 Received: from percival.namespace.at ([77.244.242.130]:58707 "EHLO percival.namespace.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753480Ab0AEMss (ORCPT ); Tue, 5 Jan 2010 07:48:48 -0500 X-Greylist: delayed 1030 seconds by postgrey-1.27 at vger.kernel.org; Tue, 05 Jan 2010 07:48:48 EST Received: from 83-64-115-202.static.xdsl-line.inode.at ([83.64.115.202]:56845 helo=localhost.localdomain) by percival.namespace.at with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NS8Yb-0003Pq-9i; Tue, 05 Jan 2010 13:30:41 +0100 From: Christian Hofstaedtler 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 Subject: [PATCH] Default to ACPI reboots on newish X86 hardware Date: Tue, 5 Jan 2010 13:30:29 +0100 Message-Id: <1262694629-7068-1-git-send-email-ch@zeha.at> X-Mailer: git-send-email 1.6.4.4 In-Reply-To: <4B42B3FD.7000608@zytor.com> References: <4B42B3FD.7000608@zytor.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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..2768416 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,59 @@ 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; + + /* Doesn't exist? Likely an old system */ + if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) { + return 0; + } + /* 0? Likely a buggy new BIOS */ + if (year == 0) { + printk(KERN_ERR "reboot: DMI BIOS year==0, " + "assuming ACPI-reboot-capable machine\n"); + return 1; + } + /* 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) +{ + 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) {