ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
PATCH v2 1/1 ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
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.
---
v2:
- Convert osi_setup_entries to non-initdata variable, to eliminate the warning from 0-DAY test infrastructure.
--- drivers/acpi/osl.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/acpi/osl.c +27 -3
@@ -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 ;
@@ -1688,13 +1691,34 @@ struct osi_setup_entry { };static struct osi_setup_entry - osi_setup_entries[OSI_STRING_ENTRIES_MAX ]__initdata = { + osi_setup_entries[OSI_STRING_ENTRIES_MAX ] = { {"Module Device" , true}, {"Processor Device" , true}, {"3.0 _SCP Extensions" , true}, {"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;
Signature · 1 line
1.8.4.2
Quoted 10 lines · Chen Yu
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.drivers/acpi/osl.c +1
-0+static bool acpi_osi_setup_disabled (char *str)
drivers/acpi/osl.c struct osi_setup_entry { · line 1711
Quoted 10 lines
drivers/acpi/osl.c +10
-0+{ +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)) {
Seems like we have one more user for
http://www.spinics.net/lists/kernel/msg2157535.html
drivers/acpi/osl.c struct osi_setup_entry { · line 1715
Quoted 4 lines
drivers/acpi/osl.c +4
-0+if (!osi->enable) +return true; +else +return false;
return !osi->enable;
Quoted 5 lines
drivers/acpi/osl.c +5
-0+ } + } + +return false; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Thanks Andy,
Quoted 19 lines
-----Original Message-----
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, February 01, 2016 4:54 PM
To: Chen, Yu C
Cc: [email protected]; [email protected]; Rafael J. Wysocki; Len Brown; [email protected]; Zhang, Rui
Subject: Re: [PATCH][v2] ACPI: Do not report_OSI("Darwin")when acpi_osi=!Darwin providedQuoted 7 lines · Chen Yu
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.
Quoted 13 lines
drivers/acpi/osl.c struct osi_setup_entry { · line 1711
Quoted 10 lines
drivers/acpi/osl.c +10
-0+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)) {Seems like we have one more user for
http://www.spinics.net/lists/kernel/msg2157535.html
[Yu] This is nice, I can convert this patch to use match_string, and may I add my patch into your patchset? I saw there are some modifications on drivers in your patchset above.
Quoted 7 lines
drivers/acpi/osl.c struct osi_setup_entry { · line 1715
Quoted 5 lines
drivers/acpi/osl.c +4
-0+if (!osi->enable) +return true; +else +return false;return !osi->enable;
[Yu] OK.
Quoted 7 lines
Quoted 6 lines
drivers/acpi/osl.c +5
-0+ } + } + +return false; +}
Quoted 13 lines · Yu C
Quoted 5 lines
Quoted 5 lines
drivers/acpi/osl.c +5
-0+static bool acpi_osi_setup_disabled (char *str) { +int i; +struct osi_setup_entry *osi; + +if (!str)Quoted 8 lines
drivers/acpi/osl.c struct osi_setup_entry { · line 1711
Quoted 5 lines
drivers/acpi/osl.c +5
-0+return false; + +for (i =0 ; i <OSI_STRING_ENTRIES_MAX ; i++) { + osi = &osi_setup_entries[i]; +if (!strcmp (osi->string, str)) {Seems like we have one more user for
http://www.spinics.net/lists/kernel/msg2157535.html
Quoted 3 lines
[Yu] This is nice, I can convert this patch to use
match_string, and may I add my patch into your patchset? I saw there are some modifications on drivers in your patchset above.
Actually it will not help in this case. Sorry.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 24 lines
-----Original Message-----
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, February 01, 2016 5:31 PM
To: Chen, Yu C
Cc: [email protected]; [email protected]; Rafael J. Wysocki; Len Brown; [email protected]; Zhang, Rui
Subject: Re: [PATCH][v2] ACPI: Do not report_OSI("Darwin")when acpi_osi=!Darwin providedQuoted 13 lines · Yu C
Quoted 13 lines
drivers/acpi/osl.c struct osi_setup_entry { · line 1711
Quoted 10 lines
drivers/acpi/osl.c +10
-0+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)) {Seems like we have one more user for
http://www.spinics.net/lists/kernel/msg2157535.html
Quoted 5 lines
Quoted 3 lines
[Yu] This is nice, I can convert this patch to use
match_string, and may I add my patch into your patchset? I saw there are some modifications on drivers in your patchset above.Actually it will not help in this case. Sorry.
Ah, osi_setup_entries is a array of structure rather than string.