From patchwork Sun Jan 31 14:51:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yu X-Patchwork-Id: 8174471 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA85D9F38B for ; Sun, 31 Jan 2016 14:47:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8B9320361 for ; Sun, 31 Jan 2016 14:47:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77EF02034E for ; Sun, 31 Jan 2016 14:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757282AbcAaOqK (ORCPT ); Sun, 31 Jan 2016 09:46:10 -0500 Received: from mga01.intel.com ([192.55.52.88]:22164 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757218AbcAaOqJ (ORCPT ); Sun, 31 Jan 2016 09:46:09 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 31 Jan 2016 06:46:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,375,1449561600"; d="scan'208";a="873338739" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.160.87]) by orsmga001.jf.intel.com with ESMTP; 31 Jan 2016 06:46:07 -0800 From: Chen Yu To: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, rjw@rjwysocki.net, lenb@kernel.org, matthew.garrett@nebula.com, rui.zhang@intel.com, Chen Yu Subject: [PATCH] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided Date: Sun, 31 Jan 2016 22:51:44 +0800 Message-Id: <1454251904-7514-1-git-send-email-yu.c.chen@intel.com> X-Mailer: git-send-email 1.8.4.2 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Commit 7bc5a2bad0b8 ("ACPI: Support _OSI("Darwin") correctly") always reports positive value when Apple hardware queries _OSI("Darwin"). But sometimes the users might want to tell the hardware they don't need the Darwin feature, for example, users may leverage the hardware to power off the Thunderbolt, by appending acpi_osi=!Darwin in command line, thus Apple hardware regards it as an incompatible OS X system, hence turns off the Thunderbolt. Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111 Signed-off-by: Chen Yu --- drivers/acpi/osl.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 67da6fb..f945d54 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -97,6 +97,7 @@ static LIST_HEAD(acpi_ioremaps); static DEFINE_MUTEX(acpi_ioremap_lock); static void __init acpi_osi_setup_late(void); +static bool acpi_osi_setup_disabled(char *str); /* * The story of _OSI(Linux) @@ -149,11 +150,13 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported) osi_linux.dmi ? " via DMI" : ""); } - if (!strcmp("Darwin", interface)) { + if (!strcmp("Darwin", interface) && + !acpi_osi_setup_disabled(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. + * to Darwin and then disable all other vendor strings if + * acpi_osi="!Darwin" is not appended in cmdline. */ acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); supported = ACPI_UINT32_MAX; @@ -1695,6 +1698,27 @@ static struct osi_setup_entry {"Processor Aggregator Device", true}, }; +static bool acpi_osi_setup_disabled(char *str) +{ + int i; + struct osi_setup_entry *osi; + + if (!str) + return false; + + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + if (!strcmp(osi->string, str)) { + if (!osi->enable) + return true; + else + return false; + } + } + + return false; +} + void __init acpi_osi_setup(char *str) { struct osi_setup_entry *osi;