linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / bus: Introduce a list of ids for "always present" devices
@ 2017-02-25 18:23 Hans de Goede
  2017-02-27 13:30 ` Rafael J. Wysocki
  0 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2017-02-25 18:23 UTC (permalink / raw)
  To: Jani Nikula, Ville Syrjälä, Rafael J . Wysocki,
	Len Brown
  Cc: Hans de Goede, intel-gfx, linux-acpi

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);
+	if (acpi_match_device_ids(device, always_present_device_ids) == 0) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] is in always present list setting status [%08x]\n",
+				  device->pnp.bus_id, ACPI_STA_DEFAULT));
+		return 0;
+	}
+	acpi_set_device_status(device, 0);
+
 	status = acpi_bus_get_status_handle(device->handle, &sta);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
-- 
2.9.3


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

end of thread, other threads:[~2017-04-10 15:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-02-27 21:58           ` Hans de Goede
2017-02-27 22:02             ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).