mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists
@ 2024-02-06 22:04 Armin Wolf
  2024-02-06 22:04 ` [PATCH 2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods Armin Wolf
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Armin Wolf @ 2024-02-06 22:04 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen; +Cc: platform-driver-x86, linux-kernel

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.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 3c288e8f404b..9d544c85e5a8 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -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


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

* [PATCH 2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods
  2024-02-06 22:04 [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Armin Wolf
@ 2024-02-06 22:04 ` Armin Wolf
  2024-02-06 22:04 ` [PATCH 3/4] platform/x86: wmi: Remove unnecessary out-of-memory message Armin Wolf
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Armin Wolf @ 2024-02-06 22:04 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen; +Cc: platform-driver-x86, linux-kernel

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.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 39 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 9d544c85e5a8..545d6696d7cb 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -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


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

* [PATCH 3/4] platform/x86: wmi: Remove unnecessary out-of-memory message
  2024-02-06 22:04 [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Armin Wolf
  2024-02-06 22:04 ` [PATCH 2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods Armin Wolf
@ 2024-02-06 22:04 ` Armin Wolf
  2024-02-06 22:04 ` [PATCH 4/4] platform/x86: wmi: Replace pr_err() with dev_err() Armin Wolf
  2024-02-07 13:52 ` [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Ilpo Järvinen
  3 siblings, 0 replies; 5+ messages in thread
From: Armin Wolf @ 2024-02-06 22:04 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen; +Cc: platform-driver-x86, linux-kernel

If kzalloc() fails, an out-of-memory message is already
printed. Remove the unnecessary second warning message.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 545d6696d7cb..396344523bce 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -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


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

* [PATCH 4/4] platform/x86: wmi: Replace pr_err() with dev_err()
  2024-02-06 22:04 [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Armin Wolf
  2024-02-06 22:04 ` [PATCH 2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods Armin Wolf
  2024-02-06 22:04 ` [PATCH 3/4] platform/x86: wmi: Remove unnecessary out-of-memory message Armin Wolf
@ 2024-02-06 22:04 ` Armin Wolf
  2024-02-07 13:52 ` [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Ilpo Järvinen
  3 siblings, 0 replies; 5+ messages in thread
From: Armin Wolf @ 2024-02-06 22:04 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen; +Cc: platform-driver-x86, linux-kernel

Using dev_err() allows users to find out from which
device the error message came from.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 396344523bce..63906fdd0abf 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -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


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

* Re: [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists
  2024-02-06 22:04 [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Armin Wolf
                   ` (2 preceding siblings ...)
  2024-02-06 22:04 ` [PATCH 4/4] platform/x86: wmi: Replace pr_err() with dev_err() Armin Wolf
@ 2024-02-07 13:52 ` Ilpo Järvinen
  3 siblings, 0 replies; 5+ messages in thread
From: Ilpo Järvinen @ 2024-02-07 13:52 UTC (permalink / raw)
  To: hdegoede, Armin Wolf; +Cc: platform-driver-x86, linux-kernel

On Tue, 06 Feb 2024 23:04:44 +0100, Armin Wolf wrote:

> 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.


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

end of thread, other threads:[~2024-02-07 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-06 22:04 [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Armin Wolf
2024-02-06 22:04 ` [PATCH 2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods Armin Wolf
2024-02-06 22:04 ` [PATCH 3/4] platform/x86: wmi: Remove unnecessary out-of-memory message Armin Wolf
2024-02-06 22:04 ` [PATCH 4/4] platform/x86: wmi: Replace pr_err() with dev_err() Armin Wolf
2024-02-07 13:52 ` [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®