2 * osi.c - _OSI implementation
4 * Copyright (C) 2016 Intel Corporation
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 /* Uncomment next line to get verbose printout */
24 #define pr_fmt(fmt) "ACPI: " fmt
26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/acpi.h>
29 #include <linux/dmi.h>
34 #define OSI_STRING_LENGTH_MAX 64
35 #define OSI_STRING_ENTRIES_MAX 16
37 struct acpi_osi_entry {
38 char string[OSI_STRING_LENGTH_MAX];
42 static struct acpi_osi_config {
44 unsigned int linux_enable:1;
45 unsigned int linux_dmi:1;
46 unsigned int linux_cmdline:1;
47 unsigned int darwin_enable:1;
48 unsigned int darwin_dmi:1;
49 unsigned int darwin_cmdline:1;
52 static struct acpi_osi_config osi_config;
53 static struct acpi_osi_entry
54 osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
55 {"Module Device", true},
56 {"Processor Device", true},
57 {"3.0 _SCP Extensions", true},
58 {"Processor Aggregator Device", true},
61 static u32 acpi_osi_handler(acpi_string interface, u32 supported)
63 if (!strcmp("Linux", interface)) {
65 "BIOS _OSI(Linux) query %s%s\n",
66 osi_config.linux_enable ? "honored" : "ignored",
67 osi_config.linux_cmdline ? " via cmdline" :
68 osi_config.linux_dmi ? " via DMI" : "");
70 if (!strcmp("Darwin", interface)) {
72 "BIOS _OSI(Darwin) query %s%s\n",
73 osi_config.darwin_enable ? "honored" : "ignored",
74 osi_config.darwin_cmdline ? " via cmdline" :
75 osi_config.darwin_dmi ? " via DMI" : "");
81 void __init acpi_osi_setup(char *str)
83 struct acpi_osi_entry *osi;
87 if (!acpi_gbl_create_osi_method)
90 if (str == NULL || *str == '\0') {
91 pr_info("_OSI method disabled\n");
92 acpi_gbl_create_osi_method = FALSE;
99 /* Do not override acpi_osi=!* */
100 if (!osi_config.default_disabling)
101 osi_config.default_disabling =
102 ACPI_DISABLE_ALL_VENDOR_STRINGS;
104 } else if (*str == '*') {
105 osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS;
106 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
107 osi = &osi_setup_entries[i];
111 } else if (*str == '!') {
112 osi_config.default_disabling = 0;
118 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
119 osi = &osi_setup_entries[i];
120 if (!strcmp(osi->string, str)) {
121 osi->enable = enable;
123 } else if (osi->string[0] == '\0') {
124 osi->enable = enable;
125 strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
131 static void __init __acpi_osi_setup_darwin(bool enable)
133 osi_config.darwin_enable = !!enable;
136 acpi_osi_setup("Darwin");
138 acpi_osi_setup("!!");
139 acpi_osi_setup("!Darwin");
143 static void __init acpi_osi_setup_darwin(bool enable)
145 /* Override acpi_osi_dmi_blacklisted() */
146 osi_config.darwin_dmi = 0;
147 osi_config.darwin_cmdline = 1;
148 __acpi_osi_setup_darwin(enable);
152 * The story of _OSI(Linux)
154 * From pre-history through Linux-2.6.22, Linux responded TRUE upon a BIOS
157 * Unfortunately, reference BIOS writers got wind of this and put
158 * OSI(Linux) in their example code, quickly exposing this string as
159 * ill-conceived and opening the door to an un-bounded number of BIOS
162 * For example, OSI(Linux) was used on resume to re-POST a video card on
163 * one system, because Linux at that time could not do a speedy restore in
164 * its native driver. But then upon gaining quick native restore
165 * capability, Linux has no way to tell the BIOS to skip the time-consuming
166 * POST -- putting Linux at a permanent performance disadvantage. On
167 * another system, the BIOS writer used OSI(Linux) to infer native OS
168 * support for IPMI! On other systems, OSI(Linux) simply got in the way of
169 * Linux claiming to be compatible with other operating systems, exposing
170 * BIOS issues such as skipped device initialization.
172 * So "Linux" turned out to be a really poor chose of OSI string, and from
173 * Linux-2.6.23 onward we respond FALSE.
175 * BIOS writers should NOT query _OSI(Linux) on future systems. Linux will
176 * complain on the console when it sees it, and return FALSE. To get Linux
177 * to return TRUE for your system will require a kernel source update to
178 * add a DMI entry, or boot with "acpi_osi=Linux"
180 static void __init __acpi_osi_setup_linux(bool enable)
182 osi_config.linux_enable = !!enable;
184 acpi_osi_setup("Linux");
186 acpi_osi_setup("!Linux");
189 static void __init acpi_osi_setup_linux(bool enable)
191 /* Override acpi_osi_dmi_blacklisted() */
192 osi_config.linux_dmi = 0;
193 osi_config.linux_cmdline = 1;
194 __acpi_osi_setup_linux(enable);
198 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
200 * empty string disables _OSI
201 * string starting with '!' disables that string
202 * otherwise string is added to list, augmenting built-in strings
204 static void __init acpi_osi_setup_late(void)
206 struct acpi_osi_entry *osi;
211 if (osi_config.default_disabling) {
212 status = acpi_update_interfaces(osi_config.default_disabling);
213 if (ACPI_SUCCESS(status))
214 pr_info("Disabled all _OSI OS vendors%s\n",
215 osi_config.default_disabling ==
216 ACPI_DISABLE_ALL_STRINGS ?
217 " and feature groups" : "");
220 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
221 osi = &osi_setup_entries[i];
226 status = acpi_install_interface(str);
227 if (ACPI_SUCCESS(status))
228 pr_info("Added _OSI(%s)\n", str);
230 status = acpi_remove_interface(str);
231 if (ACPI_SUCCESS(status))
232 pr_info("Deleted _OSI(%s)\n", str);
237 static int __init osi_setup(char *str)
239 if (str && !strcmp("Linux", str))
240 acpi_osi_setup_linux(true);
241 else if (str && !strcmp("!Linux", str))
242 acpi_osi_setup_linux(false);
243 else if (str && !strcmp("Darwin", str))
244 acpi_osi_setup_darwin(true);
245 else if (str && !strcmp("!Darwin", str))
246 acpi_osi_setup_darwin(false);
252 __setup("acpi_osi=", osi_setup);
254 bool acpi_osi_is_win8(void)
256 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
258 EXPORT_SYMBOL(acpi_osi_is_win8);
260 static void __init acpi_osi_dmi_darwin(bool enable,
261 const struct dmi_system_id *d)
263 pr_notice("DMI detected to setup _OSI(\"Darwin\"): %s\n", d->ident);
264 osi_config.darwin_dmi = 1;
265 __acpi_osi_setup_darwin(enable);
268 void __init acpi_osi_dmi_linux(bool enable, const struct dmi_system_id *d)
270 pr_notice("DMI detected to setup _OSI(\"Linux\"): %s\n", d->ident);
271 osi_config.linux_dmi = 1;
272 __acpi_osi_setup_linux(enable);
275 static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d)
277 acpi_osi_dmi_darwin(true, d);
282 static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
284 acpi_osi_dmi_linux(true, d);
289 static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
291 pr_notice("DMI detected: %s\n", d->ident);
292 acpi_osi_setup("!Windows 2006");
293 acpi_osi_setup("!Windows 2006 SP1");
294 acpi_osi_setup("!Windows 2006 SP2");
299 static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
301 pr_notice("DMI detected: %s\n", d->ident);
302 acpi_osi_setup("!Windows 2009");
307 static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
309 pr_notice("DMI detected: %s\n", d->ident);
310 acpi_osi_setup("!Windows 2012");
316 * Linux default _OSI response behavior is determined by this DMI table.
318 * Note that _OSI("Linux")/_OSI("Darwin") determined here can be overridden
319 * by acpi_osi=!Linux/acpi_osi=!Darwin command line options.
321 static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
323 .callback = dmi_disable_osi_vista,
324 .ident = "Fujitsu Siemens",
326 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
327 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
332 * There have a NVIF method in MSI GX723 DSDT need call by Nvidia
333 * driver (e.g. nouveau) when user press brightness hotkey.
334 * Currently, nouveau driver didn't do the job and it causes there
335 * have a infinite while loop in DSDT when user press hotkey.
336 * We add MSI GX723's dmi information to this table for workaround
338 * Will remove MSI GX723 from the table after nouveau grows support.
340 .callback = dmi_disable_osi_vista,
341 .ident = "MSI GX723",
343 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
344 DMI_MATCH(DMI_PRODUCT_NAME, "GX723"),
348 .callback = dmi_disable_osi_vista,
349 .ident = "Sony VGN-NS10J_S",
351 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
352 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS10J_S"),
356 .callback = dmi_disable_osi_vista,
357 .ident = "Sony VGN-SR290J",
359 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
360 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR290J"),
364 .callback = dmi_disable_osi_vista,
365 .ident = "VGN-NS50B_L",
367 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
368 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS50B_L"),
372 .callback = dmi_disable_osi_vista,
373 .ident = "VGN-SR19XN",
375 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
376 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"),
380 .callback = dmi_disable_osi_vista,
381 .ident = "Toshiba Satellite L355",
383 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
384 DMI_MATCH(DMI_PRODUCT_VERSION, "Satellite L355"),
388 .callback = dmi_disable_osi_win7,
389 .ident = "ASUS K50IJ",
391 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
392 DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"),
396 .callback = dmi_disable_osi_vista,
397 .ident = "Toshiba P305D",
399 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
400 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P305D"),
404 .callback = dmi_disable_osi_vista,
405 .ident = "Toshiba NB100",
407 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
408 DMI_MATCH(DMI_PRODUCT_NAME, "NB100"),
413 * The wireless hotkey does not work on those machines when
414 * returning true for _OSI("Windows 2012")
417 .callback = dmi_disable_osi_win8,
418 .ident = "Dell Inspiron 7737",
420 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
421 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"),
425 .callback = dmi_disable_osi_win8,
426 .ident = "Dell Inspiron 7537",
428 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
429 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"),
433 .callback = dmi_disable_osi_win8,
434 .ident = "Dell Inspiron 5437",
436 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
437 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5437"),
441 .callback = dmi_disable_osi_win8,
442 .ident = "Dell Inspiron 3437",
444 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
445 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3437"),
449 .callback = dmi_disable_osi_win8,
450 .ident = "Dell Vostro 3446",
452 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
453 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"),
457 .callback = dmi_disable_osi_win8,
458 .ident = "Dell Vostro 3546",
460 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
461 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3546"),
466 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
467 * Linux ignores it, except for the machines enumerated below.
471 * Without this this EEEpc exports a non working WMI interface, with
472 * this it exports a working "good old" eeepc_laptop interface, fixing
473 * both brightness control, and rfkill not working.
476 .callback = dmi_enable_osi_linux,
477 .ident = "Asus EEE PC 1015PX",
479 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
480 DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"),
485 * Enable _OSI("Darwin") for all apple platforms.
488 .callback = dmi_enable_osi_darwin,
489 .ident = "Apple hardware",
491 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
495 .callback = dmi_enable_osi_darwin,
496 .ident = "Apple hardware",
498 DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
504 static __init void acpi_osi_dmi_blacklisted(void)
506 dmi_check_system(acpi_osi_dmi_table);
509 int __init early_acpi_osi_init(void)
511 acpi_osi_dmi_blacklisted();
516 int __init acpi_osi_init(void)
518 acpi_install_interface_handler(acpi_osi_handler);
519 acpi_osi_setup_late();