platform/x86: wmi: Check if WMxx control method exists
PATCH 1/4 platform/x86: wmi: Check if WMxx control method exists
Some devices like the MSI GF63-12VF contain WMI method blocks without providing the necessary WMxx ACPI control methods. Avoid creating WMI devices for such WMI method blocks since the resulting WMI device is going to be unusable.
--- drivers/platform/x86/wmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/platform/x86/wmi.c +9 -0
@@ -990,6 +990,15 @@ static int wmi_create_device(struct device *wmi_bus_dev, }if (wblock->gblock.flags &ACPI_WMI_METHOD ) { +get_acpi_method_name (wblock,'M' , method); +if (!acpi_has_method (device->handle, method)) { +dev_warn (wmi_bus_dev, +FW_BUG "%s method block execution control method not found\n" , + method); + +return -ENXIO ; + } + wblock->dev.dev.type = &wmi_type_method; goto out_init; }
--
2.39.2
PATCH 2/4 platform/x86: wmi: Use FW_BUG when warning about missing control methods
A missing WQxx control method is a firmware bug and should be marked as such using FW_BUG so that users know that the issue is not a kernel issue.
Since get_subobj_info() might fail even if the control method is present, we need to print the warning only if acpi_get_handle() fails.
--- drivers/platform/x86/wmi.c | 39 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 27 deletions(-)
drivers/platform/x86/wmi.c +12 -27
@@ -132,26 +132,6 @@ static const void *find_guid_context(struct wmi_block *wblock,return NULL ; } -static int get_subobj_info (acpi_handle handle,const char *pathname, -struct acpi_device_info **info) -{ -acpi_handle subobj_handle; -acpi_status status; - - status =acpi_get_handle (handle, pathname, &subobj_handle); -if (status ==AE_NOT_FOUND ) -return -ENOENT ; - -if (ACPI_FAILURE (status)) -return -EIO ; - - status =acpi_get_object_info (subobj_handle, info); -if (ACPI_FAILURE (status)) -return -EIO ; - -return 0 ; -} -static acpi_status wmi_method_enable (struct wmi_block *wblock,bool enable) {struct guid_block *block;
@@ -979,9 +959,10 @@ static int wmi_create_device(struct device *wmi_bus_dev,struct wmi_block *wblock, struct acpi_device *device) { - struct acpi_device_info *info; char method[WMI_ACPI_METHOD_NAME_SIZE]; -int result; +struct acpi_device_info *info; +acpi_handle method_handle; +acpi_status status;uint count;if (wblock->gblock.flags &ACPI_WMI_EVENT ) {
@@ -1009,15 +990,19 @@ static int wmi_create_device(struct device *wmi_bus_dev,* we ignore this data block. */ get_acpi_method_name (wblock,'Q' , method); - result =get_subobj_info (device->handle, method, &info); - -if (result) { + status =acpi_get_handle (device->handle, method, &method_handle); +if (ACPI_FAILURE (status)) {dev_warn (wmi_bus_dev, -"%s data block query control method not found\n" , +FW_BUG "%s data block query control method not found\n" , method); -return result; + +return -ENXIO ; } + status =acpi_get_object_info (method_handle, &info); +if (ACPI_FAILURE (status)) +return -EIO ; + wblock->dev.dev.type = &wmi_type_data;/*
--
2.39.2
PATCH 3/4 platform/x86: wmi: Remove unnecessary out-of-memory message
In reply to Armin WolfIf kzalloc() fails, an out-of-memory message is already printed. Remove the unnecessary second warning message.
--- drivers/platform/x86/wmi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/x86/wmi.c +1 -3
@@ -1127,10 +1127,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)continue ; wblock =kzalloc (sizeof (*wblock),GFP_KERNEL ); -if (!wblock) { -dev_err (wmi_bus_dev,"Failed to allocate %pUL\n" , &gblock[i].guid); +if (!wblock)continue ; - } wblock->acpi_device = device; wblock->gblock = gblock[i];
--
2.39.2
PATCH 4/4 platform/x86: wmi: Replace pr_err() with dev_err()
In reply to Armin WolfUsing dev_err() allows users to find out from which device the error message came from.
--- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/wmi.c +1 -1
@@ -1339,7 +1339,7 @@ static int acpi_wmi_probe(struct platform_device *device) error =parse_wdg (wmi_bus_dev, device);if (error) { -pr_err ("Failed to parse WDG method\n" ); +dev_err (&device->dev,"Failed to parse _WDG method\n" );return error; }
--
2.39.2
Ilpo Järvinen
maintainerQuoted 6 lines · Armin Wolf
Some devices like the MSI GF63-12VF contain WMI method blocks without providing the necessary WMxx ACPI control methods. Avoid creating WMI devices for such WMI method blocks since the resulting WMI device is going to be unusable.
Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/4] platform/x86: wmi: Check if WMxx control method exists
commit: 7f1b998a9108f7fd465039323d5fc2599b8cae77
[2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods
commit: d0c595a11785573aad3b9e32ae293c48757eceff
[3/4] platform/x86: wmi: Remove unnecessary out-of-memory message
commit: 49c67cd5b6a4b611ac775de3831f5e739dd580f2
[4/4] platform/x86: wmi: Replace pr_err() with dev_err()
commit: fde7da1072f3c0239a80b590e7b75c9411e8b630--
i.