Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided

123 views
Skip to first unread message

Chen Yu

unread,
Jan 31, 2016, 9:47:02 AM1/31/16
to linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, rui....@intel.com, 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.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111
Signed-off-by: Chen Yu <yu.c...@intel.com>
---
drivers/acpi/osl.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 67da6fb..f945d54 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -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;
@@ -1695,6 +1698,27 @@ static struct osi_setup_entry
{"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;
--
1.8.4.2

Chen Yu

unread,
Jan 31, 2016, 9:21:20 PM1/31/16
to linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, rui....@intel.com, 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.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111
Signed-off-by: Chen Yu <yu.c...@intel.com>
---
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(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 67da6fb..738431a 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -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},

Andy Shevchenko

unread,
Feb 1, 2016, 3:54:34 AM2/1/16
to Chen Yu, linux...@vger.kernel.org, linux-...@vger.kernel.org, Rafael J. Wysocki, Len Brown, matthew...@nebula.com, Zhang, Rui
On Mon, Feb 1, 2016 at 4:26 AM, Chen Yu <yu.c...@intel.com> wrote:
> 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.


> +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

> + if (!osi->enable)
> + return true;
> + else
> + return false;

return !osi->enable;

> + }
> + }
> +
> + return false;
> +}


--
With Best Regards,
Andy Shevchenko

Chen, Yu C

unread,
Feb 1, 2016, 4:15:23 AM2/1/16
to Andy Shevchenko, linux...@vger.kernel.org, linux-...@vger.kernel.org, Rafael J. Wysocki, Len Brown, matthew...@nebula.com, Zhang, Rui
Thanks Andy,

> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.sh...@gmail.com]
> Sent: Monday, February 01, 2016 4:54 PM
> To: Chen, Yu C
> Cc: linux...@vger.kernel.org; linux-...@vger.kernel.org; Rafael J.
> Wysocki; Len Brown; matthew...@nebula.com; Zhang, Rui
> Subject: Re: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when
> acpi_osi=!Darwin provided
>
> On Mon, Feb 1, 2016 at 4:26 AM, Chen Yu <yu.c...@intel.com> wrote:
> > 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.
>
>
> > +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.
>
> > + if (!osi->enable)
> > + return true;
> > + else
> > + return false;
>
> return !osi->enable;
[Yu] OK.

Andy Shevchenko

unread,
Feb 1, 2016, 4:31:25 AM2/1/16
to Chen, Yu C, linux...@vger.kernel.org, linux-...@vger.kernel.org, Rafael J. Wysocki, Len Brown, matthew...@nebula.com, Zhang, Rui
On Mon, Feb 1, 2016 at 11:13 AM, Chen, Yu C <yu.c...@intel.com> wrote:

>> > +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.

Actually it will not help in this case. Sorry.

Chen, Yu C

unread,
Feb 1, 2016, 9:00:29 AM2/1/16
to Andy Shevchenko, linux...@vger.kernel.org, linux-...@vger.kernel.org, Rafael J. Wysocki, Len Brown, matthew...@nebula.com, Zhang, Rui
> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.sh...@gmail.com]
> Sent: Monday, February 01, 2016 5:31 PM
> To: Chen, Yu C
> Cc: linux...@vger.kernel.org; linux-...@vger.kernel.org; Rafael J.
> Wysocki; Len Brown; matthew...@nebula.com; Zhang, Rui
> Subject: Re: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when
> acpi_osi=!Darwin provided
>
Ah, osi_setup_entries is a array of structure rather than string.

Chen Yu

unread,
Feb 1, 2016, 8:36:06 PM2/1/16
to linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, andy.sh...@gmail.com, 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.

v3:
- Simplify acpi_osi_setup_disabled suggested by Andy Shevchenko.
v2:
- Convert osi_setup_entries to non-initdata variable, to
eliminate the warning from 0-DAY test infrastructure.
---
drivers/acpi/osl.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 67da6fb..8bb3a93 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -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,30 @@ 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 == NULL || *str == '\0')
+ return false;
+
+ for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
+ osi = &osi_setup_entries[i];
+ if (!strcmp(osi->string, str))
+ return !osi->enable;
+ }
+
+ return false;
+}
+

Zheng, Lv

unread,
Feb 22, 2016, 2:57:18 AM2/22/16
to Chen, Yu C, linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, andy.sh...@gmail.com, Chen, Yu C
Hi, Yu

> From: linux-ac...@vger.kernel.org [mailto:linux-acpi-
> ow...@vger.kernel.org] On Behalf Of Chen Yu
> Subject: [PATCH][v3] 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.
[Lv Zheng]
Both this patch and the original commit that is from Matthew look wrong to me.
IMO, the feature should be done with an entirely different approach.
Without test, I'm not sure if my comment is helpful for you.
So could you let me take over to fix this issue?

Thanks and best regards
-Lv
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majo...@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html

Chen, Yu C

unread,
Feb 22, 2016, 2:59:35 AM2/22/16
to Zheng, Lv, linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, andy.sh...@gmail.com
Yes, sure, thanks.

yu


Zheng, Lv

unread,
Feb 22, 2016, 3:56:12 AM2/22/16
to Chen, Yu C, linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, andy.sh...@gmail.com
Hi,
[Lv Zheng]
It looks to me, the original Matthew's commit was trying to make the world easier with "acpi_osi=! acpi_osi=Darwin".
While it finally adds limitation to the acpi_osi= quirk mechanism and is proven to be a bad idea.
So why don't we just revert that commit?

According to my understanding, there is no better choice other than letting users to choose a non-recent-Windows OS that the kernel should pretend to be.
So that kernel can stay simple to just pretend to be "recent-Windows".

And the only improvement that is acceptable in this case is:
We can allow acpi_osi=Darwin to be equivalent to "acpi_osi=! acpi_osi=Darwin".
While I don't think this improvement is necessary.
All reporters, including the contribution vendors should have already been familiar with "acpi_osi=! acpi_osi=Darwin".

Thanks and best regards
-Lv

>
> yu
>

Chen, Yu C

unread,
Mar 14, 2016, 10:17:27 AM3/14/16
to Zheng, Lv, linux...@vger.kernel.org, linux-...@vger.kernel.org, r...@rjwysocki.net, le...@kernel.org, matthew...@nebula.com, andy.sh...@gmail.com
Hi Lv,
> -----Original Message-----
> From: Zheng, Lv
> Sent: Monday, February 22, 2016 4:56 PM
> To: Chen, Yu C; linux...@vger.kernel.org
> Cc: linux-...@vger.kernel.org; r...@rjwysocki.net; le...@kernel.org;
> matthew...@nebula.com; andy.sh...@gmail.com
[Yu] Do you mean the new version be:
1. revert orginal 'OSI Darwin support' patch
2. improve acpi_osi=Linux/Darwin, automatically do acpi_osi=! for them
(though we need to add entry in acpi_default_supported_interfaces)

yu
0 new messages