From patchwork Wed Feb 4 00:21:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 44317 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D13E21513 for ; Wed, 4 Feb 2015 00:22:06 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y19sf22770481wgg.2 for ; Tue, 03 Feb 2015 16:22:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=zLjyWXlhT3v1h31raESK3eKtbw2cbZrJuvWW27IXvLA=; b=SUi3aUGGsiA1HjcVsHycGEVGnjSDURY/fDPWURa0ab2MbjZDocrvCnNdJ9484bUcZu WnznlTmH2+AbFna0a9DGCfi1txopwwmcWnwexAOoXZ/PoMfTZonpEzdlMU+W16j4IbY4 zfYgTVxI6BFIVV+0ZapE1bDLiQVbtqWPxglgPLmJxosINbjoJOxAVIei5SDz3E/xy7pi paUwUwVahOlyshgeaI4OHwYlUpBF/50skY8fTX3+pfXpYLIPNOgyOwdzEasXQPn7oMGc aKOdLx92yKiuBp0ssaACOEhf8nWRt5iM1NpWM50Nn3rjBo29c/2iuqS7p2jpLQys5w1V ZnuQ== X-Gm-Message-State: ALoCoQn9tbORmmVY0WKsoqwUAvqLlU4LynBcDFma16CrYfsS3t71+c5UMbXEy12BE5+vGEwTaR16 X-Received: by 10.180.87.72 with SMTP id v8mr2326258wiz.3.1423009325522; Tue, 03 Feb 2015 16:22:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.137 with SMTP id t9ls763088lag.44.gmail; Tue, 03 Feb 2015 16:22:05 -0800 (PST) X-Received: by 10.112.54.167 with SMTP id k7mr27408127lbp.72.1423009325211; Tue, 03 Feb 2015 16:22:05 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id vp9si10148lbb.134.2015.02.03.16.22.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 16:22:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id z12so41581779lbi.7 for ; Tue, 03 Feb 2015 16:22:05 -0800 (PST) X-Received: by 10.152.44.228 with SMTP id h4mr22080653lam.31.1423009325043; Tue, 03 Feb 2015 16:22:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.35.133 with SMTP id h5csp166700lbj; Tue, 3 Feb 2015 16:22:04 -0800 (PST) X-Received: by 10.50.25.166 with SMTP id d6mr21232885igg.41.1423009321860; Tue, 03 Feb 2015 16:22:01 -0800 (PST) Received: from mail-ig0-f174.google.com (mail-ig0-f174.google.com. [209.85.213.174]) by mx.google.com with ESMTPS id u2si404660igm.55.2015.02.03.16.22.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Feb 2015 16:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 209.85.213.174 as permitted sender) client-ip=209.85.213.174; Received: by mail-ig0-f174.google.com with SMTP id b16so31107357igk.1 for ; Tue, 03 Feb 2015 16:22:01 -0800 (PST) X-Received: by 10.42.84.138 with SMTP id m10mr22052001icl.21.1423009321074; Tue, 03 Feb 2015 16:22:01 -0800 (PST) Received: from fidelio.ahs3.com (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by mx.google.com with ESMTPSA id d39sm73966ioj.26.2015.02.03.16.21.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Feb 2015 16:22:00 -0800 (PST) From: al.stone@linaro.org To: rjw@rjwysocki.net, lenb@kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, robert.moore@intel.com, tony.luck@intel.com, fenghua.yu@intel.com Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devel@acpica.org, linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org, linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH v2 2/5] ACPI: move _OSI support functions to allow arch-dependent implementation Date: Tue, 3 Feb 2015 17:21:41 -0700 Message-Id: <1423009304-5007-3-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423009304-5007-1-git-send-email-al.stone@linaro.org> References: <1423009304-5007-1-git-send-email-al.stone@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: al.stone@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Al Stone Having moved the _OSI callback function needed by ACPICA from drivers/acpi/osl.c to drivers/acpi/osi.c, we now move all the remaining _OSI support functions to osi.c. This patch is much larger than I had wanted it to be; several of the functions that implemented acpi_osi* command line options, or did the set up of the interfaces to be provided by _OSI, shared a static struct. Hence, I ended up moving a bunch of code at once rather than perhaps a function at a time. With this patch, all the _OSI-associated code has now been moved to osi.c, and we next change the build so that we can make the _OSI implementation arch-dependent. There is no functional change. Signed-off-by: Al Stone --- drivers/acpi/blacklist.c | 4 + drivers/acpi/osi.c | 157 +++++++++++++++++++++++++++++++++++++- drivers/acpi/osl.c | 193 ----------------------------------------------- include/linux/acpi.h | 3 - 4 files changed, 160 insertions(+), 197 deletions(-) diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 9b693d5..3931e19 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -34,6 +34,10 @@ #include "internal.h" +extern void __init acpi_dmi_osi_linux(int enable, + const struct dmi_system_id *d); +extern void __init acpi_osi_setup(char *str); + enum acpi_blacklist_predicates { all_versions, less_than_or_equal, diff --git a/drivers/acpi/osi.c b/drivers/acpi/osi.c index fff2b0c..761c29e 100644 --- a/drivers/acpi/osi.c +++ b/drivers/acpi/osi.c @@ -34,6 +34,8 @@ ACPI_MODULE_NAME("osl"); #define PREFIX "ACPI: " +static void __init acpi_osi_setup_late(void); + /* * The story of _OSI(Linux) * @@ -72,10 +74,14 @@ static struct osi_linux { unsigned int dmi:1; unsigned int cmdline:1; unsigned int default_disabling:1; -} osi_linux = {0, 0, 0, 0}; + unsigned int interfaces_added:1; +} osi_linux = {0, 0, 0, 0, 0}; u32 acpi_osi_handler(acpi_string interface, u32 supported) { + if (!osi_linux.interfaces_added) + acpi_osi_setup_late(); + if (!strcmp("Linux", interface)) { printk_once(KERN_NOTICE FW_BUG PREFIX @@ -98,3 +104,152 @@ u32 acpi_osi_handler(acpi_string interface, u32 supported) return supported; } +#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ +#define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */ + +struct osi_setup_entry { + char string[OSI_STRING_LENGTH_MAX]; + bool enable; +}; + +static struct osi_setup_entry + osi_setup_entries[OSI_STRING_ENTRIES_MAX] = { + {"Module Device", true}, + {"Processor Device", true}, + {"3.0 _SCP Extensions", true}, + {"Processor Aggregator Device", true}, +}; + +void __init acpi_osi_setup(char *str) +{ + struct osi_setup_entry *osi; + bool enable = true; + int i; + + if (!acpi_gbl_create_osi_method) + return; + + if (str == NULL || *str == '\0') { + printk(KERN_INFO PREFIX "_OSI method disabled\n"); + acpi_gbl_create_osi_method = FALSE; + return; + } + + if (*str == '!') { + str++; + if (*str == '\0') { + osi_linux.default_disabling = 1; + return; + } else if (*str == '*') { + acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS); + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + osi->enable = false; + } + return; + } + enable = false; + } + + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + if (!strcmp(osi->string, str)) { + osi->enable = enable; + break; + } else if (osi->string[0] == '\0') { + osi->enable = enable; + strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); + break; + } + } +} + +static void __init set_osi_linux(unsigned int enable) +{ + if (osi_linux.enable != enable) + osi_linux.enable = enable; + + if (osi_linux.enable) + acpi_osi_setup("Linux"); + else + acpi_osi_setup("!Linux"); + + return; +} + +static void __init acpi_cmdline_osi_linux(unsigned int enable) +{ + osi_linux.cmdline = 1; /* cmdline set the default and override DMI */ + osi_linux.dmi = 0; + set_osi_linux(enable); + + return; +} + +void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) +{ + printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); + + if (enable == -1) + return; + + osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ + set_osi_linux(enable); + + return; +} + +/* + * Modify the list of "OS Interfaces" reported to BIOS via _OSI + * + * empty string disables _OSI + * string starting with '!' disables that string + * otherwise string is added to list, augmenting built-in strings + */ +static void __init acpi_osi_setup_late(void) +{ + struct osi_setup_entry *osi; + char *str; + int i; + acpi_status status; + + if (osi_linux.default_disabling) { + status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); + + if (ACPI_SUCCESS(status)) + printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n"); + } + + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { + osi = &osi_setup_entries[i]; + str = osi->string; + + if (*str == '\0') + break; + if (osi->enable) { + status = acpi_install_interface(str); + + if (ACPI_SUCCESS(status)) + printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); + } else { + status = acpi_remove_interface(str); + + if (ACPI_SUCCESS(status)) + printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); + } + } +} + +static int __init osi_setup(char *str) +{ + if (str && !strcmp("Linux", str)) + acpi_cmdline_osi_linux(1); + else if (str && !strcmp("!Linux", str)) + acpi_cmdline_osi_linux(0); + else + acpi_osi_setup(str); + + return 1; +} + +__setup("acpi_osi=", osi_setup); diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index c7f1cd6..a0c9940 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -99,48 +99,6 @@ struct acpi_ioremap { static LIST_HEAD(acpi_ioremaps); static DEFINE_MUTEX(acpi_ioremap_lock); -static void __init acpi_osi_setup_late(void); - -/* - * The story of _OSI(Linux) - * - * From pre-history through Linux-2.6.22, - * Linux responded TRUE upon a BIOS OSI(Linux) query. - * - * Unfortunately, reference BIOS writers got wind of this - * and put OSI(Linux) in their example code, quickly exposing - * this string as ill-conceived and opening the door to - * an un-bounded number of BIOS incompatibilities. - * - * For example, OSI(Linux) was used on resume to re-POST a - * video card on one system, because Linux at that time - * could not do a speedy restore in its native driver. - * But then upon gaining quick native restore capability, - * Linux has no way to tell the BIOS to skip the time-consuming - * POST -- putting Linux at a permanent performance disadvantage. - * On another system, the BIOS writer used OSI(Linux) - * to infer native OS support for IPMI! On other systems, - * OSI(Linux) simply got in the way of Linux claiming to - * be compatible with other operating systems, exposing - * BIOS issues such as skipped device initialization. - * - * So "Linux" turned out to be a really poor chose of - * OSI string, and from Linux-2.6.23 onward we respond FALSE. - * - * BIOS writers should NOT query _OSI(Linux) on future systems. - * Linux will complain on the console when it sees it, and return FALSE. - * To get Linux to return TRUE for your system will require - * a kernel source update to add a DMI entry, - * or boot with "acpi_osi=Linux" - */ - -static struct osi_linux { - unsigned int enable:1; - unsigned int dmi:1; - unsigned int cmdline:1; - unsigned int default_disabling:1; -} osi_linux = {0, 0, 0, 0}; - static void __init acpi_request_region (struct acpi_generic_address *gas, unsigned int length, char *desc) { @@ -1394,156 +1352,6 @@ static int __init acpi_os_name_setup(char *str) __setup("acpi_os_name=", acpi_os_name_setup); -#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ -#define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */ - -struct osi_setup_entry { - char string[OSI_STRING_LENGTH_MAX]; - bool enable; -}; - -static struct osi_setup_entry - osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { - {"Module Device", true}, - {"Processor Device", true}, - {"3.0 _SCP Extensions", true}, - {"Processor Aggregator Device", true}, -}; - -void __init acpi_osi_setup(char *str) -{ - struct osi_setup_entry *osi; - bool enable = true; - int i; - - if (!acpi_gbl_create_osi_method) - return; - - if (str == NULL || *str == '\0') { - printk(KERN_INFO PREFIX "_OSI method disabled\n"); - acpi_gbl_create_osi_method = FALSE; - return; - } - - if (*str == '!') { - str++; - if (*str == '\0') { - osi_linux.default_disabling = 1; - return; - } else if (*str == '*') { - acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS); - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - osi->enable = false; - } - return; - } - enable = false; - } - - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - if (!strcmp(osi->string, str)) { - osi->enable = enable; - break; - } else if (osi->string[0] == '\0') { - osi->enable = enable; - strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); - break; - } - } -} - -static void __init set_osi_linux(unsigned int enable) -{ - if (osi_linux.enable != enable) - osi_linux.enable = enable; - - if (osi_linux.enable) - acpi_osi_setup("Linux"); - else - acpi_osi_setup("!Linux"); - - return; -} - -static void __init acpi_cmdline_osi_linux(unsigned int enable) -{ - osi_linux.cmdline = 1; /* cmdline set the default and override DMI */ - osi_linux.dmi = 0; - set_osi_linux(enable); - - return; -} - -void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) -{ - printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); - - if (enable == -1) - return; - - osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ - set_osi_linux(enable); - - return; -} - -/* - * Modify the list of "OS Interfaces" reported to BIOS via _OSI - * - * empty string disables _OSI - * string starting with '!' disables that string - * otherwise string is added to list, augmenting built-in strings - */ -static void __init acpi_osi_setup_late(void) -{ - struct osi_setup_entry *osi; - char *str; - int i; - acpi_status status; - - if (osi_linux.default_disabling) { - status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); - - if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n"); - } - - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - str = osi->string; - - if (*str == '\0') - break; - if (osi->enable) { - status = acpi_install_interface(str); - - if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); - } else { - status = acpi_remove_interface(str); - - if (ACPI_SUCCESS(status)) - printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); - } - } -} - -static int __init osi_setup(char *str) -{ - if (str && !strcmp("Linux", str)) - acpi_cmdline_osi_linux(1); - else if (str && !strcmp("!Linux", str)) - acpi_cmdline_osi_linux(0); - else - acpi_osi_setup(str); - - return 1; -} - -__setup("acpi_osi=", osi_setup); - /* * Disable the auto-serialization of named objects creation methods. * @@ -1828,7 +1636,6 @@ acpi_status __init acpi_os_initialize1(void) BUG_ON(!kacpi_notify_wq); BUG_ON(!kacpi_hotplug_wq); acpi_install_interface_handler(acpi_osi_handler); - acpi_osi_setup_late(); return AE_OK; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ec18ab0..b345015 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -268,9 +268,6 @@ static inline int acpi_video_display_switch_support(void) #endif /* defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) */ -extern int acpi_blacklisted(void); -extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); -extern void acpi_osi_setup(char *str); extern u32 acpi_osi_handler(acpi_string interface, u32 supported); #ifdef CONFIG_ACPI_NUMA