From patchwork Sat Sep 20 11:19:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Noever X-Patchwork-Id: 4941241 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CE50E9F2EC for ; Sat, 20 Sep 2014 11:20:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEFC1201F7 for ; Sat, 20 Sep 2014 11:20:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E0853201F4 for ; Sat, 20 Sep 2014 11:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755130AbaITLUW (ORCPT ); Sat, 20 Sep 2014 07:20:22 -0400 Received: from mail-qg0-f46.google.com ([209.85.192.46]:65501 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755170AbaITLUU (ORCPT ); Sat, 20 Sep 2014 07:20:20 -0400 Received: by mail-qg0-f46.google.com with SMTP id q108so1024021qgd.33 for ; Sat, 20 Sep 2014 04:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8KxDa1dBVeYe4reUh+hCkRGzDRU4w40cQrA/VfoVpRA=; b=dicluHfoq1mY9cY/HD5uekheMSHXPdAmHKBtBSsDgI7A7E7osGdzYk66ywWKGq+vwQ QIIs6jI5yMPID5cwU3mBFSjVjFUzvou1lOCo//KeYQynSEJBaJ2IjzoCtUiaoYK9Zzdu sXyxHl5UbIJEV9L4PCi3sIwiI01V+g+eZFIG9u8+FMx18BU4ex7AMLFrk5em9xmixsAG 4LVnrm0206u2k9y6iGSr+Tnd7C5Yqm3CrQEkwL72tY5SMmIX8qKZ/UqHAusVBLPEbuAM oCvRaShXTLFyKcF3SqoFWCDCBmeHLScULLzYrAzt2Bo199krKpfcKjpPlGKlurXuYnJu HdOQ== X-Received: by 10.224.172.198 with SMTP id m6mr8029973qaz.19.1411212019450; Sat, 20 Sep 2014 04:20:19 -0700 (PDT) Received: from linuxbook.fritz.box (HSI-KBW-095-208-100-070.hsi5.kabel-badenwuerttemberg.de. [95.208.100.70]) by mx.google.com with ESMTPSA id f17sm3445961qge.23.2014.09.20.04.20.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Sep 2014 04:20:18 -0700 (PDT) From: andreas.noever@gmail.com 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.or, linux-pci@vger.kernel.org, bhelgaas@google.com, matthew.garrett@nebula.com, Andreas Noever Subject: [PATCH v2 3/3] ACPI: Support _OSI("Darwin") correctly Date: Sat, 20 Sep 2014 13:19:47 +0200 Message-Id: X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Garrett From: Matthew Garrett 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. The next problem is that the Apple PCI _OSC method has the following code: if (LEqual (0x01, OSDW ())) if (LAnd (LEqual (Arg0, GUID), NEXP) (do stuff) else (fail) NEXP is a value in high memory and is presumably under the control of the firmware. No methods sets it. The methods that are called in the "do stuff" path are dummies. Unless there's some additional firmware call in early boot, there's no way for this call to succeed - and even if it does, it doesn't do anything. The easiest way to handle this is simply to ignore it. We know which flags would be set, so just set them by hand if the platform is running in Darwin mode. Signed-off-by: Matthew Garrett [andreas.noever@gmail.com: merged two patches, do not touch ACPICA] Signed-off-by: Andreas Noever --- drivers/acpi/osl.c | 10 ++++++++++ drivers/acpi/pci_root.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 3abe9b2..938b6ac 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/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index e6ae603..cd4de7e 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -35,6 +35,7 @@ #include #include #include +#include #include /* for acpi_hest_init() */ #include "internal.h" @@ -430,6 +431,19 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, acpi_handle handle = device->handle; /* + * Apple always return failure on _OSC calls when _OSI("Darwin") has + * been called successfully. We know the feature set supported by the + * platform, so avoid calling _OSC at all + */ + + if (dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) { + root->osc_control_set = ~OSC_PCI_EXPRESS_PME_CONTROL; + decode_osc_control(root, "OS assumes control of", + root->osc_control_set); + return; + } + + /* * All supported architectures that use ACPI have support for * PCI domains, so we indicate this in _OSC support capabilities. */