Skip to content

Commit e10cfdc

Browse files
yu-chen-surfrafaeljw
authored andcommitted
ACPI / osi: Fix default _OSI(Darwin) support
The following commit always reports positive value when Apple hardware queries _OSI("Darwin"): Commit: 7bc5a2b Subject: ACPI: Support _OSI("Darwin") correctly However since this implementation places the judgement in runtime, it breaks acpi_osi=!Darwin and cannot return unsupported for _OSI("WinXXX") invoked before invoking _OSI("Darwin"). This patch fixes the issues by reverting the wrong support and implementing the default behavior of _OSI("Darwin")/_OSI("WinXXX") on Apple hardware via DMI matching. Fixes: 7bc5a2b (ACPI: Support _OSI("Darwin") correctly) Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111 Reported-and-tested-by: Lukas Wunner <[email protected]> Signed-off-by: Chen Yu <[email protected]> Signed-off-by: Lv Zheng <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a707ede commit e10cfdc

File tree

3 files changed

+75
-7
lines changed

3 files changed

+75
-7
lines changed

drivers/acpi/blacklist.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ int __init acpi_blacklisted(void)
133133
return blacklisted;
134134
}
135135
#ifdef CONFIG_DMI
136+
static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d)
137+
{
138+
acpi_dmi_osi_darwin(1, d); /* enable */
139+
return 0;
140+
}
136141
static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
137142
{
138143
acpi_dmi_osi_linux(1, d); /* enable */
@@ -331,6 +336,24 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
331336
},
332337
},
333338

339+
/*
340+
* Enable _OSI("Darwin") for all apple platforms.
341+
*/
342+
{
343+
.callback = dmi_enable_osi_darwin,
344+
.ident = "Apple hardware",
345+
.matches = {
346+
DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
347+
},
348+
},
349+
{
350+
.callback = dmi_enable_osi_darwin,
351+
.ident = "Apple hardware",
352+
.matches = {
353+
DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
354+
},
355+
},
356+
334357
#ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE
335358
/*
336359
* DELL XPS 13 (2015) switches sound between HDA and I2S

drivers/acpi/osl.c

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ static struct acpi_osi_config {
135135
unsigned int linux_enable:1;
136136
unsigned int linux_dmi:1;
137137
unsigned int linux_cmdline:1;
138+
unsigned int darwin_enable:1;
139+
unsigned int darwin_dmi:1;
140+
unsigned int darwin_cmdline:1;
138141
u8 default_disabling;
139142
} osi_config = {0, 0, 0, 0};
140143

@@ -150,13 +153,12 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported)
150153
}
151154

152155
if (!strcmp("Darwin", interface)) {
153-
/*
154-
* Apple firmware will behave poorly if it receives positive
155-
* answers to "Darwin" and any other OS. Respond positively
156-
* to Darwin and then disable all other vendor strings.
157-
*/
158-
acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
159-
supported = ACPI_UINT32_MAX;
156+
157+
printk_once(KERN_NOTICE PREFIX
158+
"BIOS _OSI(Darwin) query %s%s\n",
159+
osi_config.darwin_enable ? "honored" : "ignored",
160+
osi_config.darwin_cmdline ? " via cmdline" :
161+
osi_config.darwin_dmi ? " via DMI" : "");
160162
}
161163

162164
return supported;
@@ -1783,6 +1785,44 @@ void __init acpi_osi_setup(char *str)
17831785
}
17841786
}
17851787

1788+
static void __init set_osi_darwin(unsigned int enable)
1789+
{
1790+
if (osi_config.darwin_enable != enable)
1791+
osi_config.darwin_enable = enable;
1792+
1793+
if (enable) {
1794+
acpi_osi_setup("!");
1795+
acpi_osi_setup("Darwin");
1796+
} else {
1797+
acpi_osi_setup("!!");
1798+
acpi_osi_setup("!Darwin");
1799+
}
1800+
}
1801+
1802+
static void __init acpi_cmdline_osi_darwin(unsigned int enable)
1803+
{
1804+
/* cmdline set the default and override DMI */
1805+
osi_config.darwin_cmdline = 1;
1806+
osi_config.darwin_dmi = 0;
1807+
set_osi_darwin(enable);
1808+
1809+
return;
1810+
}
1811+
1812+
void __init acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d)
1813+
{
1814+
printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
1815+
1816+
if (enable == -1)
1817+
return;
1818+
1819+
/* DMI knows that this box asks OSI(Darwin) */
1820+
osi_config.darwin_dmi = 1;
1821+
set_osi_darwin(enable);
1822+
1823+
return;
1824+
}
1825+
17861826
static void __init set_osi_linux(unsigned int enable)
17871827
{
17881828
if (osi_config.linux_enable != enable)
@@ -1870,6 +1910,10 @@ static int __init osi_setup(char *str)
18701910
acpi_cmdline_osi_linux(1);
18711911
else if (str && !strcmp("!Linux", str))
18721912
acpi_cmdline_osi_linux(0);
1913+
else if (str && !strcmp("Darwin", str))
1914+
acpi_cmdline_osi_darwin(1);
1915+
else if (str && !strcmp("!Darwin", str))
1916+
acpi_cmdline_osi_darwin(0);
18731917
else
18741918
acpi_osi_setup(str);
18751919

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ extern char acpi_video_backlight_string[];
360360
extern long acpi_is_video_device(acpi_handle handle);
361361
extern int acpi_blacklisted(void);
362362
extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
363+
extern void acpi_dmi_osi_darwin(int enable, const struct dmi_system_id *d);
363364
extern void acpi_osi_setup(char *str);
364365
extern bool acpi_osi_is_win8(void);
365366

0 commit comments

Comments
 (0)