platform/x86: wmi: Rework WCxx/WExx ACPI method handling
authorArmin Wolf <W_Armin@gmx.de>
Sun, 16 Feb 2025 19:32:49 +0000 (20:32 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 24 Feb 2025 11:29:11 +0000 (13:29 +0200)
commit656f0961d126f5d1f0bcc62fa8bb7598d8f89207
treed7e434c1ddddda025839d28d0777186c374b6857
parentb6b566908cd75bd99eb0e4b396c89704588261b3
platform/x86: wmi: Rework WCxx/WExx ACPI method handling

The handling of the WExx ACPI methods used for enabling and disabling
WMI events has multiple flaws:

- the ACPI methods are called even when the WMI device has not been
  marked as expensive.

- WExx ACPI methods might be called for inappropriate WMI devices.

- the error code AE_NOT_FOUND is treated as success.

The handling of the WCxx ACPI methods used for enabling and disabling
WMI data blocks is also flawed:

- WMI data blocks are enabled and disabled for every single "query"
  operation. This is racy and inefficient.

Unify the handling of both ACPI methods by introducing a common
helper function for enabling and disabling WMI devices.

Also enable/disable WMI data blocks during probe/remove and shutdown
to match the handling of WMI events.

Legacy GUID-based functions still have to enable/disable the WMI
device manually and thus still suffer from a potential race condition.
Since those functions are deprecated and suffer from various other
flaws this issue is purposefully not fixed.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20250216193251.866125-7-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>
drivers/platform/x86/wmi.c