platform/x86: wmi: Fix WMI event enablement
Subsystems (3)
Armin Wolf
maintainerPATCH 1/2 platform/x86: wmi: Fix WMI event enablement
It turns out that the Windows WMI-ACPI driver always enables/disables WMI events regardless of whether they are marked as expensive or not. This finding is further reinforced when reading the documentation of the WMI_FUNCTION_CONTROL_CALLBACK callback used by Windows drivers for enabling/disabling WMI devices:
The DpWmiFunctionControl routine enables or disables notification of events, and enables or disables data collection for data blocks that the driver registered as expensive to collect.
Follow this behavior to fix the WMI event used for reporting hotkey events on the Dell Latitude 5400 and likely many more devices.
--- drivers/platform/x86/wmi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/platform/x86/wmi.c +11 -5
@@ -180,16 +180,22 @@ static int wmi_device_enable(struct wmi_device *wdev, bool enable)acpi_handle handle;acpi_status status; -if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE )) -return 0 ; -if (wblock->dev.dev.type == &wmi_type_method)return 0 ; -if (wblock->dev.dev.type == &wmi_type_event) +if (wblock->dev.dev.type == &wmi_type_event) { +/* +* Windows always enables/disables WMI events, even when they are +* not marked as being expensive. We follow this behavior for +* compatibility reasons. +*/ snprintf (method,sizeof (method),"WE%02X" , wblock->gblock.notify_id); -else + }else { +if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE )) +return 0 ; +get_acpi_method_name (wblock,'C' , method); + }/* * Not all WMI devices marked as expensive actually implement the
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH 2/2 platform/x86: wmi: Update documentation of WCxx/WExx ACPI methods
Inform potential firmware developers that WExx ACPI methods are always called by the WMI driver core even if the associated WMI event is not marked as being expensive.
--- Documentation/wmi/acpi-interface.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Documentation/wmi/acpi-interface.rst +9 -5
@@ -36,7 +36,7 @@ Offset Size (in bytes) Content The WMI object flags control whether the method or notification ID is used: -- 0x1: Data block usage is expensive and must be explicitly enabled/disabled. +- 0x1: Data block is expensive to collect. - 0x2: Data block contains WMI methods. - 0x4: Data block contains ASCIZ string. - 0x8: Data block describes a WMI event, use notification ID instead
@@ -83,14 +83,18 @@ event as hexadecimal value. Their first parameter is an integer with a value of 0 if the WMI event should be disabled, other values will enable the WMI event. +Those ACPI methods are always called even for WMI events not registered as +being expensive to collect to match the behavior of the Windows driver. + WCxx ACPI methods ----------------- -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. +Similar to the ``WExx`` ACPI methods, except that instead of WMI events it controls +data collection of data blocks registered as being expensive to collect. 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. +behavior of the Windows driver. _WED ACPI method ----------------
Signature · 1 line
2.39.5
Ilpo Järvinen
maintainerQuoted 32 lines · Armin Wolf
It turns out that the Windows WMI-ACPI driver always enables/disables WMI events regardless of whether they are marked as expensive or not. This finding is further reinforced when reading the documentation of the
WMI_FUNCTION_CONTROL_CALLBACKcallback used by Windows drivers for enabling/disabling WMI devices:The DpWmiFunctionControl routine enables or disables notification of events, and enables or disables data collection for data blocks that the driver registered as expensive to collect.
Follow this behavior to fix the WMI event used for reporting hotkey events on the Dell Latitude 5400 and likely many more devices.
Reported-by Dmytro Bagrii <[email protected]>Tested-by Dmytro Bagrii <[email protected]>Fixes 656f0961d126 ("platform/x86: wmi: Rework WCxx/WExx ACPI method handling")Signed-off-by Armin Wolf <[email protected]>--- drivers/platform/x86/wmi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)drivers/platform/x86/wmi.c +0
-1@@ -180,16 +180,22 @@ static int wmi_device_enable(struct wmi_device *wdev, bool enable)acpi_handle handle;acpi_status status; -if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE ))
drivers/platform/x86/wmi.c static int wmi_device_enable(struct wmi_device *wdev, bool enable) · line 189
Quoted 10 lines
drivers/platform/x86/wmi.c +4
-3-return 0 ; -if (wblock->dev.dev.type == &wmi_type_method)return 0 ; -if (wblock->dev.dev.type == &wmi_type_event) +if (wblock->dev.dev.type == &wmi_type_event) { +/* +* Windows always enables/disables WMI events, even when they are +* not marked as being expensive. We follow this behavior for
Hi Armin,
Is the wording in the comment reversed? (I suspect you didn't mean to include "not" into that statement?)
Quoted 14 lines
drivers/platform/x86/wmi.c +7
-1+* compatibility reasons. +*/ snprintf (method,sizeof (method),"WE%02X" , wblock->gblock.notify_id); - else + }else { +if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE )) +return 0 ; +get_acpi_method_name (wblock,'C' , method); + }/* * Not all WMI devices marked as expensive actually implement the
Signature · 1 line
i.
Am 25.06.25 um 14:28 schrieb Ilpo Järvinen:
Quoted 46 lines · Armin Wolf
Quoted 33 lines
It turns out that the Windows WMI-ACPI driver always enables/disables WMI events regardless of whether they are marked as expensive or not. This finding is further reinforced when reading the documentation of the
WMI_FUNCTION_CONTROL_CALLBACKcallback used by Windows drivers for enabling/disabling WMI devices:The DpWmiFunctionControl routine enables or disables notification of events, and enables or disables data collection for data blocks that the driver registered as expensive to collect.
Follow this behavior to fix the WMI event used for reporting hotkey events on the Dell Latitude 5400 and likely many more devices.
Reported-by Dmytro Bagrii <[email protected]>Tested-by Dmytro Bagrii <[email protected]>Fixes 656f0961d126 ("platform/x86: wmi: Rework WCxx/WExx ACPI method handling")Signed-off-by Armin Wolf <[email protected]>--- drivers/platform/x86/wmi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)drivers/platform/x86/wmi.c +0
-1@@ -180,16 +180,22 @@ static int wmi_device_enable(struct wmi_device *wdev, bool enable)acpi_handle handle;acpi_status status; -if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE ))drivers/platform/x86/wmi.c static int wmi_device_enable(struct wmi_device *wdev, bool enable) · line 189
Quoted 10 lines
drivers/platform/x86/wmi.c +4
-3-return 0 ; -if (wblock->dev.dev.type == &wmi_type_method)return 0 ; -if (wblock->dev.dev.type == &wmi_type_event) +if (wblock->dev.dev.type == &wmi_type_event) { +/* +* Windows always enables/disables WMI events, even when they are +* not marked as being expensive. We follow this behavior for Hi Armin,
Quoted 2 lines
Is the wording in the comment reversed? (I suspect you didn't mean to include "not" into that statement?)
Actually i did.
The WMI-ACPI spec seemed to suggest that WMI events should be enabled/disabled only if they are being marked as expensive, however it turned out that WMI events should also be enabled/disabled even if _not_ marked as being expensive.
Besides that another user tested this patch on his machine, so:
Thanks,
Armin Wolf
Quoted 14 lines
Quoted 14 lines
drivers/platform/x86/wmi.c +7
-1+* compatibility reasons. +*/ snprintf (method,sizeof (method),"WE%02X" , wblock->gblock.notify_id); - else + }else { +if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE )) +return 0 ; +get_acpi_method_name (wblock,'C' , method); + }/* * Not all WMI devices marked as expensive actually implement the
Ilpo Järvinen
maintainerQuoted 51 lines · Armin Wolf
Am 25.06.25 um 14:28 schrieb Ilpo Järvinen:
Quoted 47 lines · Armin Wolf
Quoted 43 lines
It turns out that the Windows WMI-ACPI driver always enables/disables WMI events regardless of whether they are marked as expensive or not. This finding is further reinforced when reading the documentation of the
WMI_FUNCTION_CONTROL_CALLBACKcallback used by Windows drivers for enabling/disabling WMI devices:The DpWmiFunctionControl routine enables or disables notification of events, and enables or disables data collection for data blocks that the driver registered as expensive to collect.
Follow this behavior to fix the WMI event used for reporting hotkey events on the Dell Latitude 5400 and likely many more devices.
Reported-by Dmytro Bagrii <[email protected]>Tested-by Dmytro Bagrii <[email protected]>Fixes 656f0961d126 ("platform/x86: wmi: Rework WCxx/WExx ACPI methodhandling")
Signed-off-by Armin Wolf <[email protected]>--- drivers/platform/x86/wmi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)drivers/platform/x86/wmi.c +3
-2@@ -180,16 +180,22 @@ static int wmi_device_enable(struct wmi_device *wdev, bool enable) acpi_handle handle;acpi_status status; - if (!(wblock->gblock.flags & ACPI_WMI_EXPENSIVE)) -return 0 ; -if (wblock->dev.dev.type == &wmi_type_method)return 0 ; - if (wblock->dev.dev.type == &wmi_type_event) +if (wblock->dev.dev.type == &wmi_type_event) { +/* +* Windows always enables/disables WMI events, even when they are
drivers/platform/x86/wmi.c static int wmi_device_enable(struct wmi_device *wdev, bool enable) · line 189
Quoted 1 line
drivers/platform/x86/wmi.c +1
-0+* not marked as being expensive. We follow this behavior for Hi Armin,
Quoted 2 lines
Is the wording in the comment reversed? (I suspect you didn't mean to include "not" into that statement?)
Quoted 6 lines
Actually i did.
The WMI-ACPI spec seemed to suggest that WMI events should be enabled/disabled only if they are being marked as expensive, however it turned out that WMI events
should also be enabled/disabled even if _not_ marked as being expensive.
Okay, fine. I seemingly missed the negation in the ACPI_WMI_EXPENSIVE check.
Signature · 1 line
i.
Quoted 22 lines
Besides that another user tested this patch on his machine, so:
Tested-by Grzegorz Suwaj <[email protected]>Thanks,
Armin WolfQuoted 14 lines
Quoted 14 lines
drivers/platform/x86/wmi.c +2
-0+* compatibility reasons. +*/ snprintf(method, sizeof(method), "WE%02X",
wblock->gblock.notify_id);drivers/platform/x86/wmi.c +5
-1-else + }else { +if (!(wblock->gblock.flags &ACPI_WMI_EXPENSIVE )) +return 0 ; +get_acpi_method_name (wblock,'C' , method); + }/* * Not all WMI devices marked as expensive actually implement the
Ilpo Järvinen
maintainerQuoted 6 lines · Armin Wolf
It turns out that the Windows WMI-ACPI driver always enables/disables WMI events regardless of whether they are marked as expensive or not. This finding is further reinforced when reading the documentation of the
WMI_FUNCTION_CONTROL_CALLBACKcallback used by Windows drivers for enabling/disabling WMI devices:
Quoted 6 lines
The DpWmiFunctionControl routine enables or disables notification of events, and enables or disables data collection for data blocks that the driver registered as expensive to collect.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/2] platform/x86: wmi: Fix WMI event enablement
commit: cf0b812500e64a7d5e2957abed38c3a97917b34f
[2/2] platform/x86: wmi: Update documentation of WCxx/WExx ACPI methods
commit: 50b6914fc53c718c5426fb6e9cd9484f9ae967c2--
i.