public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree
@ 2025-04-21 14:03 gregkh
  2025-04-21 22:07 ` Armin Wolf
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2025-04-21 14:03 UTC (permalink / raw)
  To: W_Armin, ilpo.jarvinen, lkml; +Cc: stable


The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025042139-decimeter-dislike-3ca4@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e Mon Sep 17 00:00:00 2001
From: Armin Wolf <W_Armin@gmx.de>
Date: Mon, 14 Apr 2025 16:04:53 +0200
Subject: [PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware
 bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The ACPI byte code inside the ACPI control method responsible for
handling the WMI method calls uses a global buffer for constructing
the return value, yet the ACPI control method itself is not marked
as "Serialized".
This means that calling WMI methods on this WMI device is not
thread-safe, as concurrent WMI method calls will corrupt the global
buffer.

Fix this by serializing the WMI method calls using a mutex.

Cc: stable@vger.kernel.org # 6.x.x: 912d614ac99e: platform/x86: msi-wmi-platform: Rename "data" variable
Fixes: 9c0beb6b29e7 ("platform/x86: wmi: Add MSI WMI Platform driver")
Tested-by: Antheas Kapenekakis <lkml@antheas.dev>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20250414140453.7691-2-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>

diff --git a/Documentation/wmi/devices/msi-wmi-platform.rst b/Documentation/wmi/devices/msi-wmi-platform.rst
index 31a136942892..73197b31926a 100644
--- a/Documentation/wmi/devices/msi-wmi-platform.rst
+++ b/Documentation/wmi/devices/msi-wmi-platform.rst
@@ -138,6 +138,10 @@ input data, the meaning of which depends on the subfeature being accessed.
 The output buffer contains a single byte which signals success or failure (``0x00`` on failure)
 and 31 bytes of output data, the meaning if which depends on the subfeature being accessed.
 
+.. note::
+   The ACPI control method responsible for handling the WMI method calls is not thread-safe.
+   This is a firmware bug that needs to be handled inside the driver itself.
+
 WMI method Get_EC()
 -------------------
 
diff --git a/drivers/platform/x86/msi-wmi-platform.c b/drivers/platform/x86/msi-wmi-platform.c
index e15681dfca8d..dc5e9878cb68 100644
--- a/drivers/platform/x86/msi-wmi-platform.c
+++ b/drivers/platform/x86/msi-wmi-platform.c
@@ -10,6 +10,7 @@
 #include <linux/acpi.h>
 #include <linux/bits.h>
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
 #include <linux/debugfs.h>
 #include <linux/device.h>
 #include <linux/device/driver.h>
@@ -17,6 +18,7 @@
 #include <linux/hwmon.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/printk.h>
 #include <linux/rwsem.h>
 #include <linux/types.h>
@@ -76,8 +78,13 @@ enum msi_wmi_platform_method {
 	MSI_PLATFORM_GET_WMI		= 0x1d,
 };
 
-struct msi_wmi_platform_debugfs_data {
+struct msi_wmi_platform_data {
 	struct wmi_device *wdev;
+	struct mutex wmi_lock;	/* Necessary when calling WMI methods */
+};
+
+struct msi_wmi_platform_debugfs_data {
+	struct msi_wmi_platform_data *data;
 	enum msi_wmi_platform_method method;
 	struct rw_semaphore buffer_lock;	/* Protects debugfs buffer */
 	size_t length;
@@ -132,8 +139,9 @@ static int msi_wmi_platform_parse_buffer(union acpi_object *obj, u8 *output, siz
 	return 0;
 }
 
-static int msi_wmi_platform_query(struct wmi_device *wdev, enum msi_wmi_platform_method method,
-				  u8 *input, size_t input_length, u8 *output, size_t output_length)
+static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
+				  enum msi_wmi_platform_method method, u8 *input,
+				  size_t input_length, u8 *output, size_t output_length)
 {
 	struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer in = {
@@ -147,9 +155,15 @@ static int msi_wmi_platform_query(struct wmi_device *wdev, enum msi_wmi_platform
 	if (!input_length || !output_length)
 		return -EINVAL;
 
-	status = wmidev_evaluate_method(wdev, 0x0, method, &in, &out);
-	if (ACPI_FAILURE(status))
-		return -EIO;
+	/*
+	 * The ACPI control method responsible for handling the WMI method calls
+	 * is not thread-safe. Because of this we have to do the locking ourself.
+	 */
+	scoped_guard(mutex, &data->wmi_lock) {
+		status = wmidev_evaluate_method(data->wdev, 0x0, method, &in, &out);
+		if (ACPI_FAILURE(status))
+			return -EIO;
+	}
 
 	obj = out.pointer;
 	if (!obj)
@@ -170,13 +184,13 @@ static umode_t msi_wmi_platform_is_visible(const void *drvdata, enum hwmon_senso
 static int msi_wmi_platform_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
 				 int channel, long *val)
 {
-	struct wmi_device *wdev = dev_get_drvdata(dev);
+	struct msi_wmi_platform_data *data = dev_get_drvdata(dev);
 	u8 input[32] = { 0 };
 	u8 output[32];
 	u16 value;
 	int ret;
 
-	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_FAN, input, sizeof(input), output,
+	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_FAN, input, sizeof(input), output,
 				     sizeof(output));
 	if (ret < 0)
 		return ret;
@@ -231,7 +245,7 @@ static ssize_t msi_wmi_platform_write(struct file *fp, const char __user *input,
 		return ret;
 
 	down_write(&data->buffer_lock);
-	ret = msi_wmi_platform_query(data->wdev, data->method, payload, data->length, data->buffer,
+	ret = msi_wmi_platform_query(data->data, data->method, payload, data->length, data->buffer,
 				     data->length);
 	up_write(&data->buffer_lock);
 
@@ -277,17 +291,17 @@ static void msi_wmi_platform_debugfs_remove(void *data)
 	debugfs_remove_recursive(dir);
 }
 
-static void msi_wmi_platform_debugfs_add(struct wmi_device *wdev, struct dentry *dir,
+static void msi_wmi_platform_debugfs_add(struct msi_wmi_platform_data *drvdata, struct dentry *dir,
 					 const char *name, enum msi_wmi_platform_method method)
 {
 	struct msi_wmi_platform_debugfs_data *data;
 	struct dentry *entry;
 
-	data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&drvdata->wdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return;
 
-	data->wdev = wdev;
+	data->data = drvdata;
 	data->method = method;
 	init_rwsem(&data->buffer_lock);
 
@@ -298,82 +312,82 @@ static void msi_wmi_platform_debugfs_add(struct wmi_device *wdev, struct dentry
 
 	entry = debugfs_create_file(name, 0600, dir, data, &msi_wmi_platform_debugfs_fops);
 	if (IS_ERR(entry))
-		devm_kfree(&wdev->dev, data);
+		devm_kfree(&drvdata->wdev->dev, data);
 }
 
-static void msi_wmi_platform_debugfs_init(struct wmi_device *wdev)
+static void msi_wmi_platform_debugfs_init(struct msi_wmi_platform_data *data)
 {
 	struct dentry *dir;
 	char dir_name[64];
 	int ret, method;
 
-	scnprintf(dir_name, ARRAY_SIZE(dir_name), "%s-%s", DRIVER_NAME, dev_name(&wdev->dev));
+	scnprintf(dir_name, ARRAY_SIZE(dir_name), "%s-%s", DRIVER_NAME, dev_name(&data->wdev->dev));
 
 	dir = debugfs_create_dir(dir_name, NULL);
 	if (IS_ERR(dir))
 		return;
 
-	ret = devm_add_action_or_reset(&wdev->dev, msi_wmi_platform_debugfs_remove, dir);
+	ret = devm_add_action_or_reset(&data->wdev->dev, msi_wmi_platform_debugfs_remove, dir);
 	if (ret < 0)
 		return;
 
 	for (method = MSI_PLATFORM_GET_PACKAGE; method <= MSI_PLATFORM_GET_WMI; method++)
-		msi_wmi_platform_debugfs_add(wdev, dir, msi_wmi_platform_debugfs_names[method - 1],
+		msi_wmi_platform_debugfs_add(data, dir, msi_wmi_platform_debugfs_names[method - 1],
 					     method);
 }
 
-static int msi_wmi_platform_hwmon_init(struct wmi_device *wdev)
+static int msi_wmi_platform_hwmon_init(struct msi_wmi_platform_data *data)
 {
 	struct device *hdev;
 
-	hdev = devm_hwmon_device_register_with_info(&wdev->dev, "msi_wmi_platform", wdev,
+	hdev = devm_hwmon_device_register_with_info(&data->wdev->dev, "msi_wmi_platform", data,
 						    &msi_wmi_platform_chip_info, NULL);
 
 	return PTR_ERR_OR_ZERO(hdev);
 }
 
-static int msi_wmi_platform_ec_init(struct wmi_device *wdev)
+static int msi_wmi_platform_ec_init(struct msi_wmi_platform_data *data)
 {
 	u8 input[32] = { 0 };
 	u8 output[32];
 	u8 flags;
 	int ret;
 
-	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_EC, input, sizeof(input), output,
+	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_EC, input, sizeof(input), output,
 				     sizeof(output));
 	if (ret < 0)
 		return ret;
 
 	flags = output[MSI_PLATFORM_EC_FLAGS_OFFSET];
 
-	dev_dbg(&wdev->dev, "EC RAM version %lu.%lu\n",
+	dev_dbg(&data->wdev->dev, "EC RAM version %lu.%lu\n",
 		FIELD_GET(MSI_PLATFORM_EC_MAJOR_MASK, flags),
 		FIELD_GET(MSI_PLATFORM_EC_MINOR_MASK, flags));
-	dev_dbg(&wdev->dev, "EC firmware version %.28s\n",
+	dev_dbg(&data->wdev->dev, "EC firmware version %.28s\n",
 		&output[MSI_PLATFORM_EC_VERSION_OFFSET]);
 
 	if (!(flags & MSI_PLATFORM_EC_IS_TIGERLAKE)) {
 		if (!force)
 			return -ENODEV;
 
-		dev_warn(&wdev->dev, "Loading on a non-Tigerlake platform\n");
+		dev_warn(&data->wdev->dev, "Loading on a non-Tigerlake platform\n");
 	}
 
 	return 0;
 }
 
-static int msi_wmi_platform_init(struct wmi_device *wdev)
+static int msi_wmi_platform_init(struct msi_wmi_platform_data *data)
 {
 	u8 input[32] = { 0 };
 	u8 output[32];
 	int ret;
 
-	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_WMI, input, sizeof(input), output,
+	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_WMI, input, sizeof(input), output,
 				     sizeof(output));
 	if (ret < 0)
 		return ret;
 
-	dev_dbg(&wdev->dev, "WMI interface version %u.%u\n",
+	dev_dbg(&data->wdev->dev, "WMI interface version %u.%u\n",
 		output[MSI_PLATFORM_WMI_MAJOR_OFFSET],
 		output[MSI_PLATFORM_WMI_MINOR_OFFSET]);
 
@@ -381,7 +395,8 @@ static int msi_wmi_platform_init(struct wmi_device *wdev)
 		if (!force)
 			return -ENODEV;
 
-		dev_warn(&wdev->dev, "Loading despite unsupported WMI interface version (%u.%u)\n",
+		dev_warn(&data->wdev->dev,
+			 "Loading despite unsupported WMI interface version (%u.%u)\n",
 			 output[MSI_PLATFORM_WMI_MAJOR_OFFSET],
 			 output[MSI_PLATFORM_WMI_MINOR_OFFSET]);
 	}
@@ -391,19 +406,31 @@ static int msi_wmi_platform_init(struct wmi_device *wdev)
 
 static int msi_wmi_platform_probe(struct wmi_device *wdev, const void *context)
 {
+	struct msi_wmi_platform_data *data;
 	int ret;
 
-	ret = msi_wmi_platform_init(wdev);
+	data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->wdev = wdev;
+	dev_set_drvdata(&wdev->dev, data);
+
+	ret = devm_mutex_init(&wdev->dev, &data->wmi_lock);
 	if (ret < 0)
 		return ret;
 
-	ret = msi_wmi_platform_ec_init(wdev);
+	ret = msi_wmi_platform_init(data);
 	if (ret < 0)
 		return ret;
 
-	msi_wmi_platform_debugfs_init(wdev);
+	ret = msi_wmi_platform_ec_init(data);
+	if (ret < 0)
+		return ret;
 
-	return msi_wmi_platform_hwmon_init(wdev);
+	msi_wmi_platform_debugfs_init(data);
+
+	return msi_wmi_platform_hwmon_init(data);
 }
 
 static const struct wmi_device_id msi_wmi_platform_id_table[] = {


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

* Re: FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree
  2025-04-21 14:03 FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree gregkh
@ 2025-04-21 22:07 ` Armin Wolf
  2025-04-22  7:39   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Armin Wolf @ 2025-04-21 22:07 UTC (permalink / raw)
  To: gregkh, ilpo.jarvinen, lkml; +Cc: stable

Am 21.04.25 um 16:03 schrieb gregkh@linuxfoundation.org:

> The patch below does not apply to the 6.12-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> To reproduce the conflict and resubmit, you may use the following commands:
>
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
> git checkout FETCH_HEAD
> git cherry-pick -x baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025042139-decimeter-dislike-3ca4@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
>
> Possible dependencies:

Hi,

this patch depends on 912d614ac99e ("platform/x86: msi-wmi-platform: Rename "data" variable"). I thought that i signaled that
by using the "Cc: stable@vger.kernel.org # 6.x.x:" tag.

Where did i mess up?

Thanks,
Armin Wold

> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
>  From baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e Mon Sep 17 00:00:00 2001
> From: Armin Wolf <W_Armin@gmx.de>
> Date: Mon, 14 Apr 2025 16:04:53 +0200
> Subject: [PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware
>   bug
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The ACPI byte code inside the ACPI control method responsible for
> handling the WMI method calls uses a global buffer for constructing
> the return value, yet the ACPI control method itself is not marked
> as "Serialized".
> This means that calling WMI methods on this WMI device is not
> thread-safe, as concurrent WMI method calls will corrupt the global
> buffer.
>
> Fix this by serializing the WMI method calls using a mutex.
>
> Cc: stable@vger.kernel.org # 6.x.x: 912d614ac99e: platform/x86: msi-wmi-platform: Rename "data" variable
> Fixes: 9c0beb6b29e7 ("platform/x86: wmi: Add MSI WMI Platform driver")
> Tested-by: Antheas Kapenekakis <lkml@antheas.dev>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> Link: https://lore.kernel.org/r/20250414140453.7691-2-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>
>
> diff --git a/Documentation/wmi/devices/msi-wmi-platform.rst b/Documentation/wmi/devices/msi-wmi-platform.rst
> index 31a136942892..73197b31926a 100644
> --- a/Documentation/wmi/devices/msi-wmi-platform.rst
> +++ b/Documentation/wmi/devices/msi-wmi-platform.rst
> @@ -138,6 +138,10 @@ input data, the meaning of which depends on the subfeature being accessed.
>   The output buffer contains a single byte which signals success or failure (``0x00`` on failure)
>   and 31 bytes of output data, the meaning if which depends on the subfeature being accessed.
>   
> +.. note::
> +   The ACPI control method responsible for handling the WMI method calls is not thread-safe.
> +   This is a firmware bug that needs to be handled inside the driver itself.
> +
>   WMI method Get_EC()
>   -------------------
>   
> diff --git a/drivers/platform/x86/msi-wmi-platform.c b/drivers/platform/x86/msi-wmi-platform.c
> index e15681dfca8d..dc5e9878cb68 100644
> --- a/drivers/platform/x86/msi-wmi-platform.c
> +++ b/drivers/platform/x86/msi-wmi-platform.c
> @@ -10,6 +10,7 @@
>   #include <linux/acpi.h>
>   #include <linux/bits.h>
>   #include <linux/bitfield.h>
> +#include <linux/cleanup.h>
>   #include <linux/debugfs.h>
>   #include <linux/device.h>
>   #include <linux/device/driver.h>
> @@ -17,6 +18,7 @@
>   #include <linux/hwmon.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
> +#include <linux/mutex.h>
>   #include <linux/printk.h>
>   #include <linux/rwsem.h>
>   #include <linux/types.h>
> @@ -76,8 +78,13 @@ enum msi_wmi_platform_method {
>   	MSI_PLATFORM_GET_WMI		= 0x1d,
>   };
>   
> -struct msi_wmi_platform_debugfs_data {
> +struct msi_wmi_platform_data {
>   	struct wmi_device *wdev;
> +	struct mutex wmi_lock;	/* Necessary when calling WMI methods */
> +};
> +
> +struct msi_wmi_platform_debugfs_data {
> +	struct msi_wmi_platform_data *data;
>   	enum msi_wmi_platform_method method;
>   	struct rw_semaphore buffer_lock;	/* Protects debugfs buffer */
>   	size_t length;
> @@ -132,8 +139,9 @@ static int msi_wmi_platform_parse_buffer(union acpi_object *obj, u8 *output, siz
>   	return 0;
>   }
>   
> -static int msi_wmi_platform_query(struct wmi_device *wdev, enum msi_wmi_platform_method method,
> -				  u8 *input, size_t input_length, u8 *output, size_t output_length)
> +static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
> +				  enum msi_wmi_platform_method method, u8 *input,
> +				  size_t input_length, u8 *output, size_t output_length)
>   {
>   	struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
>   	struct acpi_buffer in = {
> @@ -147,9 +155,15 @@ static int msi_wmi_platform_query(struct wmi_device *wdev, enum msi_wmi_platform
>   	if (!input_length || !output_length)
>   		return -EINVAL;
>   
> -	status = wmidev_evaluate_method(wdev, 0x0, method, &in, &out);
> -	if (ACPI_FAILURE(status))
> -		return -EIO;
> +	/*
> +	 * The ACPI control method responsible for handling the WMI method calls
> +	 * is not thread-safe. Because of this we have to do the locking ourself.
> +	 */
> +	scoped_guard(mutex, &data->wmi_lock) {
> +		status = wmidev_evaluate_method(data->wdev, 0x0, method, &in, &out);
> +		if (ACPI_FAILURE(status))
> +			return -EIO;
> +	}
>   
>   	obj = out.pointer;
>   	if (!obj)
> @@ -170,13 +184,13 @@ static umode_t msi_wmi_platform_is_visible(const void *drvdata, enum hwmon_senso
>   static int msi_wmi_platform_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
>   				 int channel, long *val)
>   {
> -	struct wmi_device *wdev = dev_get_drvdata(dev);
> +	struct msi_wmi_platform_data *data = dev_get_drvdata(dev);
>   	u8 input[32] = { 0 };
>   	u8 output[32];
>   	u16 value;
>   	int ret;
>   
> -	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_FAN, input, sizeof(input), output,
> +	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_FAN, input, sizeof(input), output,
>   				     sizeof(output));
>   	if (ret < 0)
>   		return ret;
> @@ -231,7 +245,7 @@ static ssize_t msi_wmi_platform_write(struct file *fp, const char __user *input,
>   		return ret;
>   
>   	down_write(&data->buffer_lock);
> -	ret = msi_wmi_platform_query(data->wdev, data->method, payload, data->length, data->buffer,
> +	ret = msi_wmi_platform_query(data->data, data->method, payload, data->length, data->buffer,
>   				     data->length);
>   	up_write(&data->buffer_lock);
>   
> @@ -277,17 +291,17 @@ static void msi_wmi_platform_debugfs_remove(void *data)
>   	debugfs_remove_recursive(dir);
>   }
>   
> -static void msi_wmi_platform_debugfs_add(struct wmi_device *wdev, struct dentry *dir,
> +static void msi_wmi_platform_debugfs_add(struct msi_wmi_platform_data *drvdata, struct dentry *dir,
>   					 const char *name, enum msi_wmi_platform_method method)
>   {
>   	struct msi_wmi_platform_debugfs_data *data;
>   	struct dentry *entry;
>   
> -	data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL);
> +	data = devm_kzalloc(&drvdata->wdev->dev, sizeof(*data), GFP_KERNEL);
>   	if (!data)
>   		return;
>   
> -	data->wdev = wdev;
> +	data->data = drvdata;
>   	data->method = method;
>   	init_rwsem(&data->buffer_lock);
>   
> @@ -298,82 +312,82 @@ static void msi_wmi_platform_debugfs_add(struct wmi_device *wdev, struct dentry
>   
>   	entry = debugfs_create_file(name, 0600, dir, data, &msi_wmi_platform_debugfs_fops);
>   	if (IS_ERR(entry))
> -		devm_kfree(&wdev->dev, data);
> +		devm_kfree(&drvdata->wdev->dev, data);
>   }
>   
> -static void msi_wmi_platform_debugfs_init(struct wmi_device *wdev)
> +static void msi_wmi_platform_debugfs_init(struct msi_wmi_platform_data *data)
>   {
>   	struct dentry *dir;
>   	char dir_name[64];
>   	int ret, method;
>   
> -	scnprintf(dir_name, ARRAY_SIZE(dir_name), "%s-%s", DRIVER_NAME, dev_name(&wdev->dev));
> +	scnprintf(dir_name, ARRAY_SIZE(dir_name), "%s-%s", DRIVER_NAME, dev_name(&data->wdev->dev));
>   
>   	dir = debugfs_create_dir(dir_name, NULL);
>   	if (IS_ERR(dir))
>   		return;
>   
> -	ret = devm_add_action_or_reset(&wdev->dev, msi_wmi_platform_debugfs_remove, dir);
> +	ret = devm_add_action_or_reset(&data->wdev->dev, msi_wmi_platform_debugfs_remove, dir);
>   	if (ret < 0)
>   		return;
>   
>   	for (method = MSI_PLATFORM_GET_PACKAGE; method <= MSI_PLATFORM_GET_WMI; method++)
> -		msi_wmi_platform_debugfs_add(wdev, dir, msi_wmi_platform_debugfs_names[method - 1],
> +		msi_wmi_platform_debugfs_add(data, dir, msi_wmi_platform_debugfs_names[method - 1],
>   					     method);
>   }
>   
> -static int msi_wmi_platform_hwmon_init(struct wmi_device *wdev)
> +static int msi_wmi_platform_hwmon_init(struct msi_wmi_platform_data *data)
>   {
>   	struct device *hdev;
>   
> -	hdev = devm_hwmon_device_register_with_info(&wdev->dev, "msi_wmi_platform", wdev,
> +	hdev = devm_hwmon_device_register_with_info(&data->wdev->dev, "msi_wmi_platform", data,
>   						    &msi_wmi_platform_chip_info, NULL);
>   
>   	return PTR_ERR_OR_ZERO(hdev);
>   }
>   
> -static int msi_wmi_platform_ec_init(struct wmi_device *wdev)
> +static int msi_wmi_platform_ec_init(struct msi_wmi_platform_data *data)
>   {
>   	u8 input[32] = { 0 };
>   	u8 output[32];
>   	u8 flags;
>   	int ret;
>   
> -	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_EC, input, sizeof(input), output,
> +	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_EC, input, sizeof(input), output,
>   				     sizeof(output));
>   	if (ret < 0)
>   		return ret;
>   
>   	flags = output[MSI_PLATFORM_EC_FLAGS_OFFSET];
>   
> -	dev_dbg(&wdev->dev, "EC RAM version %lu.%lu\n",
> +	dev_dbg(&data->wdev->dev, "EC RAM version %lu.%lu\n",
>   		FIELD_GET(MSI_PLATFORM_EC_MAJOR_MASK, flags),
>   		FIELD_GET(MSI_PLATFORM_EC_MINOR_MASK, flags));
> -	dev_dbg(&wdev->dev, "EC firmware version %.28s\n",
> +	dev_dbg(&data->wdev->dev, "EC firmware version %.28s\n",
>   		&output[MSI_PLATFORM_EC_VERSION_OFFSET]);
>   
>   	if (!(flags & MSI_PLATFORM_EC_IS_TIGERLAKE)) {
>   		if (!force)
>   			return -ENODEV;
>   
> -		dev_warn(&wdev->dev, "Loading on a non-Tigerlake platform\n");
> +		dev_warn(&data->wdev->dev, "Loading on a non-Tigerlake platform\n");
>   	}
>   
>   	return 0;
>   }
>   
> -static int msi_wmi_platform_init(struct wmi_device *wdev)
> +static int msi_wmi_platform_init(struct msi_wmi_platform_data *data)
>   {
>   	u8 input[32] = { 0 };
>   	u8 output[32];
>   	int ret;
>   
> -	ret = msi_wmi_platform_query(wdev, MSI_PLATFORM_GET_WMI, input, sizeof(input), output,
> +	ret = msi_wmi_platform_query(data, MSI_PLATFORM_GET_WMI, input, sizeof(input), output,
>   				     sizeof(output));
>   	if (ret < 0)
>   		return ret;
>   
> -	dev_dbg(&wdev->dev, "WMI interface version %u.%u\n",
> +	dev_dbg(&data->wdev->dev, "WMI interface version %u.%u\n",
>   		output[MSI_PLATFORM_WMI_MAJOR_OFFSET],
>   		output[MSI_PLATFORM_WMI_MINOR_OFFSET]);
>   
> @@ -381,7 +395,8 @@ static int msi_wmi_platform_init(struct wmi_device *wdev)
>   		if (!force)
>   			return -ENODEV;
>   
> -		dev_warn(&wdev->dev, "Loading despite unsupported WMI interface version (%u.%u)\n",
> +		dev_warn(&data->wdev->dev,
> +			 "Loading despite unsupported WMI interface version (%u.%u)\n",
>   			 output[MSI_PLATFORM_WMI_MAJOR_OFFSET],
>   			 output[MSI_PLATFORM_WMI_MINOR_OFFSET]);
>   	}
> @@ -391,19 +406,31 @@ static int msi_wmi_platform_init(struct wmi_device *wdev)
>   
>   static int msi_wmi_platform_probe(struct wmi_device *wdev, const void *context)
>   {
> +	struct msi_wmi_platform_data *data;
>   	int ret;
>   
> -	ret = msi_wmi_platform_init(wdev);
> +	data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->wdev = wdev;
> +	dev_set_drvdata(&wdev->dev, data);
> +
> +	ret = devm_mutex_init(&wdev->dev, &data->wmi_lock);
>   	if (ret < 0)
>   		return ret;
>   
> -	ret = msi_wmi_platform_ec_init(wdev);
> +	ret = msi_wmi_platform_init(data);
>   	if (ret < 0)
>   		return ret;
>   
> -	msi_wmi_platform_debugfs_init(wdev);
> +	ret = msi_wmi_platform_ec_init(data);
> +	if (ret < 0)
> +		return ret;
>   
> -	return msi_wmi_platform_hwmon_init(wdev);
> +	msi_wmi_platform_debugfs_init(data);
> +
> +	return msi_wmi_platform_hwmon_init(data);
>   }
>   
>   static const struct wmi_device_id msi_wmi_platform_id_table[] = {
>

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

* Re: FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree
  2025-04-21 22:07 ` Armin Wolf
@ 2025-04-22  7:39   ` Greg KH
  2025-04-22 23:30     ` Armin Wolf
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2025-04-22  7:39 UTC (permalink / raw)
  To: Armin Wolf; +Cc: ilpo.jarvinen, lkml, stable

On Tue, Apr 22, 2025 at 12:07:23AM +0200, Armin Wolf wrote:
> Am 21.04.25 um 16:03 schrieb gregkh@linuxfoundation.org:
> 
> > The patch below does not apply to the 6.12-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> > 
> > To reproduce the conflict and resubmit, you may use the following commands:
> > 
> > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
> > git checkout FETCH_HEAD
> > git cherry-pick -x baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e
> > # <resolve conflicts, build, test, etc.>
> > git commit -s
> > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025042139-decimeter-dislike-3ca4@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
> > 
> > Possible dependencies:
> 
> Hi,
> 
> this patch depends on 912d614ac99e ("platform/x86: msi-wmi-platform: Rename "data" variable"). I thought that i signaled that
> by using the "Cc: stable@vger.kernel.org # 6.x.x:" tag.
> 
> Where did i mess up?

You didn't, I missed that, sorry.

I've fixed this up for 6.12.y and 6.14.y, but both of these commits do
not apply to 6.6.y at all (filenames are wrong.)

Please send backports for 6.6.y if you want to see the commit there.

thanks,

greg k-h

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

* Re: FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree
  2025-04-22  7:39   ` Greg KH
@ 2025-04-22 23:30     ` Armin Wolf
  0 siblings, 0 replies; 4+ messages in thread
From: Armin Wolf @ 2025-04-22 23:30 UTC (permalink / raw)
  To: Greg KH; +Cc: ilpo.jarvinen, lkml, stable

Am 22.04.25 um 09:39 schrieb Greg KH:

> On Tue, Apr 22, 2025 at 12:07:23AM +0200, Armin Wolf wrote:
>> Am 21.04.25 um 16:03 schrieb gregkh@linuxfoundation.org:
>>
>>> The patch below does not apply to the 6.12-stable tree.
>>> If someone wants it applied there, or to any other stable or longterm
>>> tree, then please email the backport, including the original git commit
>>> id to <stable@vger.kernel.org>.
>>>
>>> To reproduce the conflict and resubmit, you may use the following commands:
>>>
>>> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
>>> git checkout FETCH_HEAD
>>> git cherry-pick -x baf2f2c2b4c8e1d398173acd4d2fa9131a86b84e
>>> # <resolve conflicts, build, test, etc.>
>>> git commit -s
>>> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025042139-decimeter-dislike-3ca4@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
>>>
>>> Possible dependencies:
>> Hi,
>>
>> this patch depends on 912d614ac99e ("platform/x86: msi-wmi-platform: Rename "data" variable"). I thought that i signaled that
>> by using the "Cc: stable@vger.kernel.org # 6.x.x:" tag.
>>
>> Where did i mess up?
> You didn't, I missed that, sorry.
>
> I've fixed this up for 6.12.y and 6.14.y, but both of these commits do
> not apply to 6.6.y at all (filenames are wrong.)
>
> Please send backports for 6.6.y if you want to see the commit there.

The affected driver was introduced with kernel 6.10, so both patches are unnecessary for kernel 6.6.y.

Thanks,
Armin Wolf

> thanks,
>
> greg k-h

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

end of thread, other threads:[~2025-04-22 23:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 14:03 FAILED: patch "[PATCH] platform/x86: msi-wmi-platform: Workaround a ACPI firmware" failed to apply to 6.12-stable tree gregkh
2025-04-21 22:07 ` Armin Wolf
2025-04-22  7:39   ` Greg KH
2025-04-22 23:30     ` Armin Wolf

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