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>
30 #include <linux/platform_data/x86/apple.h>
35 #define OSI_STRING_LENGTH_MAX 64
36 #define OSI_STRING_ENTRIES_MAX 16
38 struct acpi_osi_entry {
39 char string[OSI_STRING_LENGTH_MAX];
43 static struct acpi_osi_config {
45 unsigned int linux_enable:1;
46 unsigned int linux_dmi:1;
47 unsigned int linux_cmdline:1;
48 unsigned int darwin_enable:1;
49 unsigned int darwin_dmi:1;
50 unsigned int darwin_cmdline:1;
53 static struct acpi_osi_config osi_config;
54 static struct acpi_osi_entry
55 osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
56 {"Module Device", true},
57 {"Processor Device", true},
58 {"3.0 _SCP Extensions", true},
59 {"Processor Aggregator Device", true},
61 * Linux-Dell-Video is used by BIOS to disable RTD3 for NVidia graphics
62 * cards as RTD3 is not supported by drivers now. Systems with NVidia
63 * cards will hang without RTD3 disabled.
65 * Once NVidia drivers officially support RTD3, this _OSI strings can
66 * be removed if both new and old graphics cards are supported.
68 {"Linux-Dell-Video", true},
71 static u32 acpi_osi_handler(acpi_string interface, u32 supported)
73 if (!strcmp("Linux", interface)) {
75 "BIOS _OSI(Linux) query %s%s\n",
76 osi_config.linux_enable ? "honored" : "ignored",
77 osi_config.linux_cmdline ? " via cmdline" :
78 osi_config.linux_dmi ? " via DMI" : "");
80 if (!strcmp("Darwin", interface)) {
82 "BIOS _OSI(Darwin) query %s%s\n",
83 osi_config.darwin_enable ? "honored" : "ignored",
84 osi_config.darwin_cmdline ? " via cmdline" :
85 osi_config.darwin_dmi ? " via DMI" : "");
91 void __init acpi_osi_setup(char *str)
93 struct acpi_osi_entry *osi;
97 if (!acpi_gbl_create_osi_method)
100 if (str == NULL || *str == '\0') {
101 pr_info("_OSI method disabled\n");
102 acpi_gbl_create_osi_method = FALSE;
109 /* Do not override acpi_osi=!* */
110 if (!osi_config.default_disabling)
111 osi_config.default_disabling =
112 ACPI_DISABLE_ALL_VENDOR_STRINGS;
114 } else if (*str == '*') {
115 osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS;
116 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
117 osi = &osi_setup_entries[i];
121 } else if (*str == '!') {
122 osi_config.default_disabling = 0;
128 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
129 osi = &osi_setup_entries[i];
130 if (!strcmp(osi->string, str)) {
131 osi->enable = enable;
133 } else if (osi->string[0] == '\0') {
134 osi->enable = enable;
135 strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
141 static void __init __acpi_osi_setup_darwin(bool enable)
143 osi_config.darwin_enable = !!enable;
146 acpi_osi_setup("Darwin");
148 acpi_osi_setup("!!");
149 acpi_osi_setup("!Darwin");
153 static void __init acpi_osi_setup_darwin(bool enable)
155 /* Override acpi_osi_dmi_blacklisted() */
156 osi_config.darwin_dmi = 0;
157 osi_config.darwin_cmdline = 1;
158 __acpi_osi_setup_darwin(enable);
162 * The story of _OSI(Linux)
164 * From pre-history through Linux-2.6.22, Linux responded TRUE upon a BIOS
167 * Unfortunately, reference BIOS writers got wind of this and put
168 * OSI(Linux) in their example code, quickly exposing this string as
169 * ill-conceived and opening the door to an un-bounded number of BIOS
172 * For example, OSI(Linux) was used on resume to re-POST a video card on
173 * one system, because Linux at that time could not do a speedy restore in
174 * its native driver. But then upon gaining quick native restore
175 * capability, Linux has no way to tell the BIOS to skip the time-consuming
176 * POST -- putting Linux at a permanent performance disadvantage. On
177 * another system, the BIOS writer used OSI(Linux) to infer native OS
178 * support for IPMI! On other systems, OSI(Linux) simply got in the way of
179 * Linux claiming to be compatible with other operating systems, exposing
180 * BIOS issues such as skipped device initialization.
182 * So "Linux" turned out to be a really poor chose of OSI string, and from
183 * Linux-2.6.23 onward we respond FALSE.
185 * BIOS writers should NOT query _OSI(Linux) on future systems. Linux will
186 * complain on the console when it sees it, and return FALSE. To get Linux
187 * to return TRUE for your system will require a kernel source update to
188 * add a DMI entry, or boot with "acpi_osi=Linux"
190 static void __init __acpi_osi_setup_linux(bool enable)
192 osi_config.linux_enable = !!enable;
194 acpi_osi_setup("Linux");
196 acpi_osi_setup("!Linux");
199 static void __init acpi_osi_setup_linux(bool enable)
201 /* Override acpi_osi_dmi_blacklisted() */
202 osi_config.linux_dmi = 0;
203 osi_config.linux_cmdline = 1;
204 __acpi_osi_setup_linux(enable);
208 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
210 * empty string disables _OSI
211 * string starting with '!' disables that string
212 * otherwise string is added to list, augmenting built-in strings
214 static void __init acpi_osi_setup_late(void)
216 struct acpi_osi_entry *osi;
221 if (osi_config.default_disabling) {
222 status = acpi_update_interfaces(osi_config.default_disabling);
223 if (ACPI_SUCCESS(status))
224 pr_info("Disabled all _OSI OS vendors%s\n",
225 osi_config.default_disabling ==
226 ACPI_DISABLE_ALL_STRINGS ?
227 " and feature groups" : "");
230 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
231 osi = &osi_setup_entries[i];
236 status = acpi_install_interface(str);
237 if (ACPI_SUCCESS(status))
238 pr_info("Added _OSI(%s)\n", str);
240 status = acpi_remove_interface(str);
241 if (ACPI_SUCCESS(status))
242 pr_info("Deleted _OSI(%s)\n", str);
247 static int __init osi_setup(char *str)
249 if (str && !strcmp("Linux", str))
250 acpi_osi_setup_linux(true);
251 else if (str && !strcmp("!Linux", str))
252 acpi_osi_setup_linux(false);
253 else if (str && !strcmp("Darwin", str))
254 acpi_osi_setup_darwin(true);
255 else if (str && !strcmp("!Darwin", str))
256 acpi_osi_setup_darwin(false);
262 __setup("acpi_osi=", osi_setup);
264 bool acpi_osi_is_win8(void)
266 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
268 EXPORT_SYMBOL(acpi_osi_is_win8);
270 static void __init acpi_osi_dmi_darwin(void)
272 pr_notice("DMI detected to setup _OSI(\"Darwin\"): Apple hardware\n");
273 osi_config.darwin_dmi = 1;
274 __acpi_osi_setup_darwin(true);
277 static void __init acpi_osi_dmi_linux(bool enable,
278 const struct dmi_system_id *d)
280 pr_notice("DMI detected to setup _OSI(\"Linux\"): %s\n", d->ident);
281 osi_config.linux_dmi = 1;
282 __acpi_osi_setup_linux(enable);
285 static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
287 acpi_osi_dmi_linux(true, d);
292 static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
294 pr_notice("DMI detected: %s\n", d->ident);
295 acpi_osi_setup("!Windows 2006");
296 acpi_osi_setup("!Windows 2006 SP1");
297 acpi_osi_setup("!Windows 2006 SP2");
302 static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
304 pr_notice("DMI detected: %s\n", d->ident);
305 acpi_osi_setup("!Windows 2009");
310 static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
312 pr_notice("DMI detected: %s\n", d->ident);
313 acpi_osi_setup("!Windows 2012");
319 * Linux default _OSI response behavior is determined by this DMI table.
321 * Note that _OSI("Linux")/_OSI("Darwin") determined here can be overridden
322 * by acpi_osi=!Linux/acpi_osi=!Darwin command line options.
324 static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
326 .callback = dmi_disable_osi_vista,
327 .ident = "Fujitsu Siemens",
329 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
330 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
335 * There have a NVIF method in MSI GX723 DSDT need call by Nvidia
336 * driver (e.g. nouveau) when user press brightness hotkey.
337 * Currently, nouveau driver didn't do the job and it causes there
338 * have a infinite while loop in DSDT when user press hotkey.
339 * We add MSI GX723's dmi information to this table for workaround
341 * Will remove MSI GX723 from the table after nouveau grows support.
343 .callback = dmi_disable_osi_vista,
344 .ident = "MSI GX723",
346 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
347 DMI_MATCH(DMI_PRODUCT_NAME, "GX723"),
351 .callback = dmi_disable_osi_vista,
352 .ident = "Sony VGN-NS10J_S",
354 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
355 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS10J_S"),
359 .callback = dmi_disable_osi_vista,
360 .ident = "Sony VGN-SR290J",
362 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
363 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR290J"),
367 .callback = dmi_disable_osi_vista,
368 .ident = "VGN-NS50B_L",
370 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
371 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS50B_L"),
375 .callback = dmi_disable_osi_vista,
376 .ident = "VGN-SR19XN",
378 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
379 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"),
383 .callback = dmi_disable_osi_vista,
384 .ident = "Toshiba Satellite L355",
386 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
387 DMI_MATCH(DMI_PRODUCT_VERSION, "Satellite L355"),
391 .callback = dmi_disable_osi_win7,
392 .ident = "ASUS K50IJ",
394 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"),
399 .callback = dmi_disable_osi_vista,
400 .ident = "Toshiba P305D",
402 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
403 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P305D"),
407 .callback = dmi_disable_osi_vista,
408 .ident = "Toshiba NB100",
410 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
411 DMI_MATCH(DMI_PRODUCT_NAME, "NB100"),
416 * The wireless hotkey does not work on those machines when
417 * returning true for _OSI("Windows 2012")
420 .callback = dmi_disable_osi_win8,
421 .ident = "Dell Inspiron 7737",
423 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
424 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"),
428 .callback = dmi_disable_osi_win8,
429 .ident = "Dell Inspiron 7537",
431 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
432 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"),
436 .callback = dmi_disable_osi_win8,
437 .ident = "Dell Inspiron 5437",
439 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
440 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5437"),
444 .callback = dmi_disable_osi_win8,
445 .ident = "Dell Inspiron 3437",
447 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
448 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3437"),
452 .callback = dmi_disable_osi_win8,
453 .ident = "Dell Vostro 3446",
455 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
456 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"),
460 .callback = dmi_disable_osi_win8,
461 .ident = "Dell Vostro 3546",
463 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
464 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3546"),
469 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
470 * Linux ignores it, except for the machines enumerated below.
474 * Without this this EEEpc exports a non working WMI interface, with
475 * this it exports a working "good old" eeepc_laptop interface, fixing
476 * both brightness control, and rfkill not working.
479 .callback = dmi_enable_osi_linux,
480 .ident = "Asus EEE PC 1015PX",
482 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
483 DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"),
489 static __init void acpi_osi_dmi_blacklisted(void)
491 dmi_check_system(acpi_osi_dmi_table);
493 /* Enable _OSI("Darwin") for Apple platforms. */
494 if (x86_apple_machine)
495 acpi_osi_dmi_darwin();
498 int __init early_acpi_osi_init(void)
500 acpi_osi_dmi_blacklisted();
505 int __init acpi_osi_init(void)
507 acpi_install_interface_handler(acpi_osi_handler);
508 acpi_osi_setup_late();