platform/x86: wmi: Call WCxx methods when setting data blocks
authorArmin Wolf <W_Armin@gmx.de>
Sun, 16 Feb 2025 19:32:50 +0000 (20:32 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 24 Feb 2025 11:30:15 +0000 (13:30 +0200)
After performing some tests with a custom SSDT table available at
https://github.com/Wer-Wolf/acpi-wmi-ssdt i found out that Windows
also enables data block collection even when the data block is
being set.

Emulate this behaviour to avoid confusing the ACPI firmware.
The bus-based API already implements this behaviour, so only the
legacy GUID-based API needs to be changed.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20250216193251.866125-8-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Documentation/wmi/acpi-interface.rst
drivers/platform/x86/wmi.c

index 06fb7fcf44134ae6ca23c548121127b2a8f0f649..f1b28835d23ceb8712a95fd0fadffa5d9e5c2538 100644 (file)
@@ -89,6 +89,9 @@ Similar to the ``WExx`` ACPI methods, except that it controls data collection
 instead of events and thus the last two characters of the ACPI method name are
 the method ID of the data block to enable/disable.
 
+Those ACPI methods are also called before setting data blocks to match the
+behaviour of the Windows driver.
+
 _WED ACPI method
 ----------------
 
index 9377c5e6ba6fb55e55596b11fcbc9511b9e8ae00..e46453750d5f1475eb87342b1c5fd04fe20df335 100644 (file)
@@ -463,7 +463,14 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, const struct acp
        if (IS_ERR(wdev))
                return AE_ERROR;
 
+       if (wmi_device_enable(wdev, true) < 0)
+               dev_warn(&wdev->dev, "Failed to enable device\n");
+
        status =  wmidev_block_set(wdev, instance, in);
+
+       if (wmi_device_enable(wdev, false) < 0)
+               dev_warn(&wdev->dev, "Failed to disable device\n");
+
        wmi_device_put(wdev);
 
        return status;