All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
@ 2016-02-01  2:26 Chen Yu
  2016-02-01  8:54 ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Yu @ 2016-02-01  2:26 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-kernel, rjw, lenb, matthew.garrett, rui.zhang, 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.chen@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},
 	{"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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
  2016-02-01  2:26 [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided Chen Yu
@ 2016-02-01  8:54 ` Andy Shevchenko
  2016-02-01  9:13   ` Chen, Yu C
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2016-02-01  8:54 UTC (permalink / raw)
  To: Chen Yu
  Cc: linux-acpi, linux-kernel, Rafael J. Wysocki, Len Brown,
	matthew.garrett, Zhang, Rui

On Mon, Feb 1, 2016 at 4:26 AM, Chen Yu <yu.c.chen@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
  2016-02-01  8:54 ` Andy Shevchenko
@ 2016-02-01  9:13   ` Chen, Yu C
  2016-02-01  9:31     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Chen, Yu C @ 2016-02-01  9:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-acpi, linux-kernel, Rafael J. Wysocki, Len Brown,
	matthew.garrett, Zhang, Rui

Thanks Andy,

> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com]
> Sent: Monday, February 01, 2016 4:54 PM
> To: Chen, Yu C
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; Rafael J.
> Wysocki; Len Brown; matthew.garrett@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.chen@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.
> 
> > +               }
> > +       }
> > +
> > +       return false;
> > +}
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
  2016-02-01  9:13   ` Chen, Yu C
@ 2016-02-01  9:31     ` Andy Shevchenko
  2016-02-01 14:00       ` Chen, Yu C
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2016-02-01  9:31 UTC (permalink / raw)
  To: Chen, Yu C
  Cc: linux-acpi, linux-kernel, Rafael J. Wysocki, Len Brown,
	matthew.garrett, Zhang, Rui

On Mon, Feb 1, 2016 at 11:13 AM, Chen, Yu C <yu.c.chen@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.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided
  2016-02-01  9:31     ` Andy Shevchenko
@ 2016-02-01 14:00       ` Chen, Yu C
  0 siblings, 0 replies; 5+ messages in thread
From: Chen, Yu C @ 2016-02-01 14:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-acpi, linux-kernel, Rafael J. Wysocki, Len Brown,
	matthew.garrett, Zhang, Rui

> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com]
> Sent: Monday, February 01, 2016 5:31 PM
> To: Chen, Yu C
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; Rafael J.
> Wysocki; Len Brown; matthew.garrett@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 11:13 AM, Chen, Yu C <yu.c.chen@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.
Ah,  osi_setup_entries is a array of structure rather than string.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-01 14:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-01  2:26 [PATCH][v2] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided Chen Yu
2016-02-01  8:54 ` Andy Shevchenko
2016-02-01  9:13   ` Chen, Yu C
2016-02-01  9:31     ` Andy Shevchenko
2016-02-01 14:00       ` Chen, Yu C

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.