All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Len Brown <lenb@kernel.org>
Subject: Re: [PATCH] ACPI / bus: Introduce a list of ids for "always present" devices
Date: Mon, 27 Feb 2017 22:49:28 +0100	[thread overview]
Message-ID: <CAJZ5v0jAFr0eJ44mMjpsvrGfnaqN1BQNQdN688mfA0SajimBtg@mail.gmail.com> (raw)
In-Reply-To: <53f42d4d-542e-096c-6a91-031b61adcbe0@redhat.com>

On Mon, Feb 27, 2017 at 10:29 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
>
> On 27-02-17 22:25, Rafael J. Wysocki wrote:
>>
>> On Mon, Feb 27, 2017 at 3:25 PM, Hans de Goede <hdegoede@redhat.com>
>> wrote:
>>>
>>> Hi,
>>>
>>>
>>> On 27-02-17 14:30, Rafael J. Wysocki wrote:
>>>>
>>>>
>>>> +Mika & Andy
>>>>
>>>> On Saturday, February 25, 2017 07:23:28 PM Hans de Goede wrote:
>>>>>
>>>>>
>>>>> Several cherrytrail devices (all of which ship with windows 10) hide
>>>>> the
>>>>> lpss pwm controller in ACPI, typically the _STA method looks like this:
>>>>>
>>>>>     Method (_STA, 0, NotSerialized)  // _STA: Status
>>>>>     {
>>>>>         If (OSID == One)
>>>>>         {
>>>>>             Return (Zero)
>>>>>         }
>>>>>
>>>>>         Return (0x0F)
>>>>>     }
>>>>>
>>>>> Where OSID is some dark magic seen in all cherrytrail ACPI tables
>>>>> making
>>>>> the machine behave differently depending on which OS it *thinks* it is
>>>>> booting, this gets set in a number of ways which we cannot control, on
>>>>> some newer machines it simple hardcoded to "One" aka win10.
>>>>>
>>>>> This causes the PWM controller to get hidden, which means Linux cannot
>>>>> control the backlight level on cht based tablets / laptops.
>>>>>
>>>>> Since loading the driver for this does no harm (the only in kernel user
>>>>> of it is the i915 driver, which will only use it when it needs it),
>>>>> this
>>>>> commit makes acpi_bus_get_status() always set status to
>>>>> ACPI_STA_DEFAULT
>>>>> for the 80862288 device, fixing the lack of backlight control.
>>>>>
>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>>> ---
>>>>>  drivers/acpi/bus.c | 25 +++++++++++++++++++++++++
>>>>>  1 file changed, 25 insertions(+)
>>>>>
>>>>> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
>>>>> index 95855cb..483d4d0 100644
>>>>> --- a/drivers/acpi/bus.c
>>>>> +++ b/drivers/acpi/bus.c
>>>>> @@ -109,11 +109,36 @@ acpi_status
>>>>> acpi_bus_get_status_handle(acpi_handle
>>>>> handle,
>>>>>         return status;
>>>>>  }
>>>>>
>>>>> +/*
>>>>> + * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es
>>>>> because
>>>>> + * some recent windows drivers bind to one device but poke at multiple
>>>>> + * devices at the same time, so the others get hidden.
>>>>> + * We work around this by always reporting ACPI_STA_DEFAULT for these
>>>>> + * devices. Note this MUST only be done for devices where this is
>>>>> safe.
>>>>> + */
>>>>> +static const struct acpi_device_id always_present_device_ids[] = {
>>>>> +       /*
>>>>> +        * Cherrytrail pwm directly poked by GPU driver in win10,
>>>>> +        * but Linux uses a separate pwm driver, harmless if not used.
>>>>> +        */
>>>>> +       { "80862288", },
>>>>> +       { }
>>>>> +};
>>>>> +
>>>>>  int acpi_bus_get_status(struct acpi_device *device)
>>>>>  {
>>>>>         acpi_status status;
>>>>>         unsigned long long sta;
>>>>>
>>>>> +       /* acpi_match_device_ids checks status, so start with default
>>>>> */
>>>>> +       acpi_set_device_status(device, ACPI_STA_DEFAULT);
>>>>
>>>>
>>>>
>>>> This shouldn't be done in a "get" routine.
>>>
>>>
>>>
>>> With this you mean the acpi_match_device_ids() check I assume ?
>>> (acpi_bus_get_status already calls acpi_set_device_status())
>>
>>
>> Yes, the device ID check.
>>
>>>> Ideally, a scan handler should do that or similar.
>>>
>>>
>>>
>>> The problem is that drivers/acpi/scan.c: acpi_bus_attach()
>>> calls acpi_bus_get_status() and if it does not set
>>> the status to present acpi_bus_attach() exits without bothering
>>> with attaching scan handlers, which is why I ended up doing this
>>> here.
>>
>>
>> Fair enough.
>>
>> Two problems with this approach.
>>
>> One is that it doesn't prevent _STA from being evaluated as
>> acpi_bus_get_status_handle() is called directly from a couple of
>> places.
>
> Yes I noticed that, but that is not a problem for this
> (and I would assume most) devices. Intervening directly
> in acpi_bus_get_status_handle is harder as there is no
> access to the hid there.

But if you modify acpi_set_device_status(), that should make it
consistent AFAICS.

And this is just a quirk for devices where _STA is known to return
garbage sometimes and I'd call it a quirk openly.

Thanks,
Rafael
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-02-27 21:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25 18:23 [PATCH] ACPI / bus: Introduce a list of ids for "always present" devices Hans de Goede
2017-02-27 13:30 ` Rafael J. Wysocki
2017-02-27 14:25   ` Hans de Goede
2017-02-27 14:40     ` Takashi Iwai
2017-02-27 21:27       ` Rafael J. Wysocki
2017-02-27 22:53         ` Takashi Iwai
2017-04-09 20:32           ` [Intel-gfx] " Hans de Goede
2017-04-10 13:56             ` Takashi Iwai
2017-04-10 15:44               ` Hans de Goede
2017-02-27 21:25     ` Rafael J. Wysocki
2017-02-27 21:29       ` Hans de Goede
2017-02-27 21:49         ` Rafael J. Wysocki [this message]
2017-02-27 21:58           ` Hans de Goede
2017-02-27 22:02             ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJZ5v0jAFr0eJ44mMjpsvrGfnaqN1BQNQdN688mfA0SajimBtg@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.