Skip to contentSkip to conversation

platform/x86: asus-wmi: Ignore return value when writing thermal policy

PATCH In review Armin Wolf 3 participants 7 messages Nov 24, 2024 – Dec 2, 2024

Subsystems (2)
lore
Share & tools
lore

Armin Wolf

author
#0 lore raw

PATCH 1/1 platform/x86: asus-wmi: Ignore return value when writing thermal policy

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle thermal policy")
---
 drivers/platform/x86/asus-wmi.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +2 -9
index ba8b6d028f9f..8bd187e8b47f 100644
@@ -3696,7 +3696,6 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
 /* Throttle thermal policy ****************************************************/
 static int throttle_thermal_policy_write(struct asus_wmi *asus)
 {
-	u32 retval;
 	u8 value;
 	int err;
 
@@ -3718,8 +3717,8 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
 		value = asus->throttle_thermal_policy_mode;
 	}
 
-	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
-				    value, &retval);
+	/* Some machines do not return an error code as a result, so we ignore it */
+	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, value, NULL);
 
 	sysfs_notify(&asus->platform_device->dev.kobj, NULL,
 			"throttle_thermal_policy");
@@ -3729,12 +3728,6 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
 		return err;
 	}
 
-	if (retval != 1) {
-		pr_warn("Failed to set throttle thermal policy (retval): 0x%x\n",
-			retval);
-		return -EIO;
-	}
-
 	/* Must set to disabled if mode is toggled */
 	if (asus->cpu_fan_curve_available)
 		asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false;

--
2.39.5

Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 10 lines · Armin Wolf

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle thermal policy")

Thanks, patch looks good to me:

Regards,

Hans

Quoted 43 lines
---
 drivers/platform/x86/asus-wmi.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +2 -10
index ba8b6d028f9f..8bd187e8b47f 100644
@@ -3696,7 +3696,6 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
 /* Throttle thermal policy ****************************************************/
 static int throttle_thermal_policy_write(struct asus_wmi *asus)
 {
-	u32 retval;
 	u8 value;
 	int err;
 
@@ -3718,8 +3717,8 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
 		value = asus->throttle_thermal_policy_mode;
 	}
 
-	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
-				    value, &retval);
+	/* Some machines do not return an error code as a result, so we ignore it */
+	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, value, NULL);
 
 	sysfs_notify(&asus->platform_device->dev.kobj, NULL,
 			"throttle_thermal_policy");
@@ -3729,12 +3728,6 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
 		return err;
 	}
 
-	if (retval != 1) {
-		pr_warn("Failed to set throttle thermal policy (retval): 0x%x\n",
-			retval);
-		return -EIO;
-	}
-
 	/* Must set to disabled if mode is toggled */
 	if (asus->cpu_fan_curve_available)
 		asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false;
--

2.39.5

#2 lore raw

Am 25.11.24 um 10:39 schrieb Hans de Goede:

Quoted 13 lines

Hi,

Quoted 10 lines · Armin Wolf

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle thermal policy")
Quoted 7 lines

Thanks, patch looks good to me:

Regards,

Hans

I forgot to add the following tag:

Can we pick this patch for the next fixes pull?

Thanks,
Armin Wolf

Quoted 44 lines
Quoted 43 lines
---
  drivers/platform/x86/asus-wmi.c | 11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +2 -10
index ba8b6d028f9f..8bd187e8b47f 100644
@@ -3696,7 +3696,6 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
  /* Throttle thermal policy ****************************************************/
  static int throttle_thermal_policy_write(struct asus_wmi *asus)
  {
-	u32 retval;
  	u8 value;
  	int err;
 
@@ -3718,8 +3717,8 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
  		value = asus->throttle_thermal_policy_mode;
  	}
 
-	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
-				    value, &retval);
+	/* Some machines do not return an error code as a result, so we ignore it */
+	err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, value, NULL);
 
  	sysfs_notify(&asus->platform_device->dev.kobj, NULL,
  			"throttle_thermal_policy");
@@ -3729,12 +3728,6 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
  		return err;
  	}
 
-	if (retval != 1) {
-		pr_warn("Failed to set throttle thermal policy (retval): 0x%x\n",
-			retval);
-		return -EIO;
-	}
-
  	/* Must set to disabled if mode is toggled */
  	if (asus->cpu_fan_curve_available)
  		asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false;
--

2.39.5

author
#3 lore raw

Am 29.11.24 um 20:29 schrieb Armin Wolf:

Quoted 24 lines

Am 25.11.24 um 10:39 schrieb Hans de Goede:

Quoted 14 lines

Hi,

Quoted 11 lines · Armin Wolf

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle

thermal policy")

Quoted 7 lines

Thanks, patch looks good to me:

Regards,

Hans

Quoted 9 lines

I forgot to add the following tag:

Can we pick this patch for the next fixes pull?

Thanks,
Armin Wolf

Another user (Edoardo Brogiolo <[email protected]>) reported a similar issue with another Asus machine, see https://bbs.archlinux.org/viewtopic.php?id=301341 for details.

Are there any blockers left for this patch to get accepted upstream?

Thanks,
Armin Wolf

Quoted 53 lines
Quoted 52 lines
Quoted 51 lines

---
  drivers/platform/x86/asus-wmi.c | 11 ++---------

  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +0 -1
index ba8b6d028f9f..8bd187e8b47f 100644
@@ -3696,7 +3696,6 @@ static int
 asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
   /* Throttle thermal policy
 ****************************************************/
   static int throttle_thermal_policy_write(struct asus_wmi *asus)
   {
-    u32 retval;
       u8 value;

      int err;

drivers/platform/x86/asus-wmi.c +1 -2
@@ -3718,8 +3717,8 @@ static int
 throttle_thermal_policy_write(struct asus_wmi *asus)
           value = asus->throttle_thermal_policy_mode;
       }
 
-    err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
-                    value, &retval);
+    /* Some machines do not return an error code as a result, so we

ignore it */
+    err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, value, NULL);

      sysfs_notify(&asus->platform_device->dev.kobj, NULL, "throttle_thermal_policy");

drivers/platform/x86/asus-wmi.c +0 -6
@@ -3729,12 +3728,6 @@ static int
 throttle_thermal_policy_write(struct asus_wmi *asus)
           return err;
       }
 
-    if (retval != 1) {
-        pr_warn("Failed to set throttle thermal policy (retval):
 0x%x\n",
-            retval);
-        return -EIO;
-    }
-
       /* Must set to disabled if mode is toggled */

      if (asus->cpu_fan_curve_available) asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; --
2.39.5

maintainer
#4 lore raw
Quoted 28 lines · Armin Wolf

Am 29.11.24 um 20:29 schrieb Armin Wolf:

Quoted 27 lines

Am 25.11.24 um 10:39 schrieb Hans de Goede:

Quoted 12 lines · Armin Wolf
Quoted 11 lines

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle

thermal policy")

Quoted 7 lines

Thanks, patch looks good to me:

Regards,

Hans

I forgot to add the following tag:

Can we pick this patch for the next fixes pull?

Quoted 8 lines
Quoted 3 lines

Thanks,
Armin Wolf

Another user (Edoardo Brogiolo <[email protected]>) reported a similar issue with another Asus machine,
see https://bbs.archlinux.org/viewtopic.php?id=301341 for details.

Are there any blockers left for this patch to get accepted upstream?

Hi Armin,

I don't think there are any blocker I'm aware of. It's just that I'm extremely busy right after the merge window has closed as usual.

Signature · 1 line
 i.
Quoted 54 lines
Quoted 53 lines
Quoted 52 lines
Quoted 51 lines

---
  drivers/platform/x86/asus-wmi.c | 11 ++---------

  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +0 -1
index ba8b6d028f9f..8bd187e8b47f 100644
@@ -3696,7 +3696,6 @@ static int
 asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
   /* Throttle thermal policy
 ****************************************************/
   static int throttle_thermal_policy_write(struct asus_wmi *asus)
   {
-    u32 retval;
       u8 value;

      int err;

drivers/platform/x86/asus-wmi.c +1 -2
@@ -3718,8 +3717,8 @@ static int
 throttle_thermal_policy_write(struct asus_wmi *asus)
           value = asus->throttle_thermal_policy_mode;
       }
 
-    err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
-                    value, &retval);
+    /* Some machines do not return an error code as a result, so we

ignore it */
+    err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, value, NULL);

      sysfs_notify(&asus->platform_device->dev.kobj, NULL, "throttle_thermal_policy");

drivers/platform/x86/asus-wmi.c +0 -6
@@ -3729,12 +3728,6 @@ static int
 throttle_thermal_policy_write(struct asus_wmi *asus)
           return err;
       }
 
-    if (retval != 1) {
-        pr_warn("Failed to set throttle thermal policy (retval):
 0x%x\n",
-            retval);
-        return -EIO;
-    }
-
       /* Must set to disabled if mode is toggled */

      if (asus->cpu_fan_curve_available) asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; --
2.39.5

author
#5 lore raw

Am 02.12.24 um 15:29 schrieb Ilpo Järvinen:

Quoted 35 lines · Armin Wolf
Quoted 34 lines

Am 29.11.24 um 20:29 schrieb Armin Wolf:

Quoted 20 lines

Am 25.11.24 um 10:39 schrieb Hans de Goede:

Quoted 12 lines · Armin Wolf
Quoted 11 lines

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

Reported-by [email protected]
Fixes 2daa86e78c49 ("platform/x86: asus_wmi: Support throttle

thermal policy")

Quoted 7 lines

Thanks, patch looks good to me:

Regards,

Hans

Quoted 9 lines

I forgot to add the following tag:

Can we pick this patch for the next fixes pull?

Thanks,
Armin Wolf

Another user (Edoardo Brogiolo <[email protected]>) reported a similar issue with another Asus machine,
see https://bbs.archlinux.org/viewtopic.php?id=301341 for details.

Quoted 6 lines
Quoted 1 line

Are there any blockers left for this patch to get accepted upstream?

Hi Armin,

I don't think there are any blocker I'm aware of. It's just that I'm extremely busy right after the merge window has closed as usual.

Ok, then i will just wait a bit.

Thanks,
Armin Wolf

maintainer
#6 lore raw
In reply to Armin Wolf
Quoted 8 lines · Armin Wolf

On some machines like the ASUS Vivobook S14 writing the thermal policy returns the currently writen thermal policy instead of an error code.

Ignore the return code to avoid falsely returning an error when the thermal policy was written successfully.

[...]

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/1] platform/x86: asus-wmi: Ignore return value when writing thermal policy

      commit: 25fb5f47f34d90aceda2c47a4230315536e97fa8

--
i.