From patchwork Sun Jun 1 16:33:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 4278731 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C2245BEEA7 for ; Sun, 1 Jun 2014 16:34:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA6C120253 for ; Sun, 1 Jun 2014 16:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B001C201C7 for ; Sun, 1 Jun 2014 16:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbaFAQeU (ORCPT ); Sun, 1 Jun 2014 12:34:20 -0400 Received: from cavan.codon.org.uk ([93.93.128.6]:59916 "EHLO cavan.codon.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752505AbaFAQeT (ORCPT ); Sun, 1 Jun 2014 12:34:19 -0400 Received: from 209-6-207-143.c3-0.smr-ubr2.sbo-smr.ma.cable.rcn.com ([209.6.207.143] helo=localhost.lan) by cavan.codon.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wr8hz-0005vY-BR; Sun, 01 Jun 2014 17:34:11 +0100 From: Matthew Garrett To: rjw@rjwysocki.net Cc: lenb@kernel.org, robert.moore@intel.com, lv.zheng@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, Matthew Garrett Date: Sun, 1 Jun 2014 12:33:53 -0400 Message-Id: <1401640436-1947-2-git-send-email-matthew.garrett@nebula.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1401640436-1947-1-git-send-email-matthew.garrett@nebula.com> References: <1401640436-1947-1-git-send-email-matthew.garrett@nebula.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 209.6.207.143 X-SA-Exim-Mail-From: matthew.garrett@nebula.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-ASN: Subject: [PATCH 1/4] ACPI: Support _OSI("Darwin") correctly X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:54:46 +0000) X-SA-Exim-Scanned: Yes (on cavan.codon.org.uk) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Apple hardware queries _OSI("Darwin") in order to determine whether the system is running OS X, and changes firmware behaviour based on the answer. The most obvious difference in behaviour is that Thunderbolt hardware is forcibly powered down unless the system is running OS X. The obvious solution would be to simply add Darwin to the list of supported _OSI strings, but this causes problems. Recent Apple hardware includes two separate methods for checking _OSI strings. The first will check whether Darwin is supported, and if so will exit. The second will check whether Darwin is supported, but will then continue to check for further operating systems. If a further operating system is found then later firmware code will assume that the OS is not OS X. This results in the unfortunate situation where the Thunderbolt controller is available at boot time but remains powered down after suspend. The easiest way to handle this is to special-case it in the Linux-specific OSI handling code. If we see Darwin, we should answer true and then disable all other _OSI vendor strings. Signed-off-by: Matthew Garrett --- drivers/acpi/acpica/utosi.c | 1 + drivers/acpi/osl.c | 10 ++++++++++ include/acpi/actypes.h | 25 +++++++++++++------------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c index 685766f..63b0a3b 100644 --- a/drivers/acpi/acpica/utosi.c +++ b/drivers/acpi/acpica/utosi.c @@ -87,6 +87,7 @@ ACPI_MODULE_NAME("utosi") static struct acpi_interface_info acpi_default_supported_interfaces[] = { /* Operating System Vendor Strings */ + {"Darwin", NULL, 0, ACPI_OSI_DARWIN}, /* OS X */ {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */ {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */ {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 6776c59..312ab5c 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -152,6 +152,16 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported) osi_linux.dmi ? " via DMI" : ""); } + if (!strcmp("Darwin", interface)) { + /* + * Apple firmware will behave poorly if it receives positive + * answers to "Darwin" and any other OS. Respond positively + * to Darwin and then disable all other vendor strings. + */ + acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); + supported = ACPI_UINT32_MAX; + } + return supported; } diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index e763565..1c2ef56 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -1210,17 +1210,18 @@ struct acpi_memory_list { #define ACPI_ENABLE_ALL_FEATURE_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_FEATURE_STRINGS) #define ACPI_ENABLE_ALL_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS) -#define ACPI_OSI_WIN_2000 0x01 -#define ACPI_OSI_WIN_XP 0x02 -#define ACPI_OSI_WIN_XP_SP1 0x03 -#define ACPI_OSI_WINSRV_2003 0x04 -#define ACPI_OSI_WIN_XP_SP2 0x05 -#define ACPI_OSI_WINSRV_2003_SP1 0x06 -#define ACPI_OSI_WIN_VISTA 0x07 -#define ACPI_OSI_WINSRV_2008 0x08 -#define ACPI_OSI_WIN_VISTA_SP1 0x09 -#define ACPI_OSI_WIN_VISTA_SP2 0x0A -#define ACPI_OSI_WIN_7 0x0B -#define ACPI_OSI_WIN_8 0x0C +#define ACPI_OSI_DARWIN 0x01 +#define ACPI_OSI_WIN_2000 0x02 +#define ACPI_OSI_WIN_XP 0x03 +#define ACPI_OSI_WIN_XP_SP1 0x04 +#define ACPI_OSI_WINSRV_2003 0x05 +#define ACPI_OSI_WIN_XP_SP2 0x06 +#define ACPI_OSI_WINSRV_2003_SP1 0x07 +#define ACPI_OSI_WIN_VISTA 0x08 +#define ACPI_OSI_WINSRV_2008 0x09 +#define ACPI_OSI_WIN_VISTA_SP1 0x0A +#define ACPI_OSI_WIN_VISTA_SP2 0x0B +#define ACPI_OSI_WIN_7 0x0C +#define ACPI_OSI_WIN_8 0x0D #endif /* __ACTYPES_H__ */