Skip to contentSkip to conversation

asus-wmi: add platform_profile support

PATCH Superseded Luke D. Jones 4 participants 13 messages Aug 14, 2021 – Aug 16, 2021

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Luke D. Jones

author maintainer
#0 lore raw

v3 cover asus-wmi: add platform_profile support

Changelog:
- V2
+ Correctly unregister from platform_profile if throttle_thermal_policy fails
+ Do platform_profile_notify() in both throttle_thermal_policy_store() and in throttle_thermal_policy_switch_next()
+ Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
- V3
+ Add missing declaration for err in throttle_thermal_policy_switch_next

Luke D. Jones (1):
asus-wmi: Add support for platform_profile

 drivers/platform/x86/asus-wmi.c | 139 +++++++++++++++++++++++++++++++-
 1 file changed, 135 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH v3 1/1 asus-wmi: Add support for platform_profile

Add initial support for platform_profile where the support is based on availability of ASUS_THROTTLE_THERMAL_POLICY.

Because throttle_thermal_policy is used by platform_profile and is writeable separately to platform_profile any userspace changes to throttle_thermal_policy need to notify platform_profile.

In future throttle_thermal_policy sysfs should be removed so that only one method controls the laptop power profile.

---
 drivers/platform/x86/asus-wmi.c | 139 +++++++++++++++++++++++++++++++-
 1 file changed, 135 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-wmi.c +135 -4
index 90a6a0d00deb..909fc2663008 100644
@@ -26,6 +26,7 @@
 #include <linux/rfkill.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
+#include <linux/platform_profile.h>
 #include <linux/power_supply.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
@@ -219,6 +220,9 @@ struct asus_wmi {
 	bool throttle_thermal_policy_available;
 	u8 throttle_thermal_policy_mode;
 
+	struct platform_profile_handler platform_profile_handler;
+	bool platform_profile_support;
+
 	// The RSOC controls the maximum charging percentage.
 	bool battery_rsoc_available;
 
@@ -2103,12 +2107,23 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus)
 static int throttle_thermal_policy_switch_next(struct asus_wmi *asus)
 {
 	u8 new_mode = asus->throttle_thermal_policy_mode + 1;
+	int err;
 
 	if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT)
 		new_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
 
 	asus->throttle_thermal_policy_mode = new_mode;
-	return throttle_thermal_policy_write(asus);
+	err = throttle_thermal_policy_write(asus);
+	if (err)
+		return err;
+
+	/*
+	 * Ensure that platform_profile updates userspace with the change to ensure
+	 * that platform_profile and throttle_thermal_policy_mode are in sync
+	 */
+	platform_profile_notify();
+
+	return 0;
 }
 
 static ssize_t throttle_thermal_policy_show(struct device *dev,
@@ -2124,9 +2139,10 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
 				    struct device_attribute *attr,
 				    const char *buf, size_t count)
 {
-	int result;
-	u8 new_mode;
 	struct asus_wmi *asus = dev_get_drvdata(dev);
+	u8 new_mode;
+	int result;
+	int err;
 
 	result = kstrtou8(buf, 10, &new_mode);
 	if (result < 0)
@@ -2136,7 +2152,15 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
 		return -EINVAL;
 
 	asus->throttle_thermal_policy_mode = new_mode;
-	throttle_thermal_policy_write(asus);
+	err = throttle_thermal_policy_write(asus);
+	if (err)
+		return err;
+
+	/*
+	 * Ensure that platform_profile updates userspace with the change to ensure
+	 * that platform_profile and throttle_thermal_policy_mode are in sync
+	 */
+	platform_profile_notify();
 
 	return count;
 }
@@ -2144,6 +2168,103 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
 // Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent
 static DEVICE_ATTR_RW(throttle_thermal_policy);
 
+/* Platform profile ***********************************************************/
+static int platform_profile_get(struct platform_profile_handler *pprof,
+				enum platform_profile_option *profile)
+{
+	struct asus_wmi *asus;
+	int tp;
+
+	asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
+
+	/* All possible toggles like throttle_thermal_policy here */
+	if (asus->throttle_thermal_policy_available) {
+		tp = asus->throttle_thermal_policy_mode;
+	} else {
+		return -1;
+	}
+
+	if (tp < 0)
+		return tp;
+
+	switch (tp) {
+	case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
+		*profile = PLATFORM_PROFILE_BALANCED;
+		break;
+	case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
+		*profile = PLATFORM_PROFILE_PERFORMANCE;
+		break;
+	case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
+		*profile = PLATFORM_PROFILE_QUIET;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int platform_profile_set(struct platform_profile_handler *pprof,
+				enum platform_profile_option profile)
+{
+	struct asus_wmi *asus;
+	int tp;
+
+	asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
+
+	/* All possible toggles like throttle_thermal_policy here */
+	if (!asus->throttle_thermal_policy_available) {
+		return -1;
+	}
+
+	switch (profile) {
+	case PLATFORM_PROFILE_PERFORMANCE:
+		tp = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST;
+		break;
+	case PLATFORM_PROFILE_BALANCED:
+		tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
+		break;
+	case PLATFORM_PROFILE_QUIET:
+		tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT;
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	asus->throttle_thermal_policy_mode = tp;
+	return throttle_thermal_policy_write(asus);
+}
+
+static int platform_profile_setup(struct asus_wmi *asus)
+{
+	int err;
+
+	if (asus->throttle_thermal_policy_available) {
+		pr_info("Using throttle_thermal_policy for platform_profile support\n");
+	} else {
+		/*
+		 * Not an error if a component platform_profile relies on is unavailable
+		 * so early return, skipping the setup of platform_profile.
+		*/
+		return 0;
+	}
+	asus->platform_profile_handler.profile_get = platform_profile_get;
+	asus->platform_profile_handler.profile_set = platform_profile_set;
+
+	set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices);
+	set_bit(PLATFORM_PROFILE_BALANCED,
+		asus->platform_profile_handler.choices);
+	set_bit(PLATFORM_PROFILE_PERFORMANCE,
+		asus->platform_profile_handler.choices);
+
+	err = platform_profile_register(&asus->platform_profile_handler);
+	if (err)
+		return err;
+
+	asus->platform_profile_support = true;
+	return 0;
+}
+
 /* Backlight ******************************************************************/
 
 static int read_backlight_power(struct asus_wmi *asus)
@@ -2904,6 +3025,10 @@ static int asus_wmi_add(struct platform_device *pdev)
 	else
 		throttle_thermal_policy_set_default(asus);
 
+	err = platform_profile_setup(asus);
+	if (err)
+		goto fail_platform_profile_setup;
+
 	err = panel_od_check_present(asus);
 	if (err)
 		goto fail_panel_od;
@@ -2993,6 +3118,9 @@ static int asus_wmi_add(struct platform_device *pdev)
 	asus_wmi_sysfs_exit(asus->platform_device);
 fail_sysfs:
 fail_throttle_thermal_policy:
+fail_platform_profile_setup:
+	if (asus->platform_profile_support)
+		platform_profile_remove();
 fail_fan_boost_mode:
 fail_egpu_enable:
 fail_dgpu_disable:
@@ -3017,6 +3145,9 @@ static int asus_wmi_remove(struct platform_device *device)
 	asus_fan_set_auto(asus);
 	asus_wmi_battery_exit(asus);
 
+	if (asus->platform_profile_support)
+		platform_profile_remove();
+
 	kfree(asus);
 	return 0;
 }
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

Quoted 10 lines · Luke D. Jones

Add initial support for platform_profile where the support is based on availability of ASUS_THROTTLE_THERMAL_POLICY.

Because throttle_thermal_policy is used by platform_profile and is writeable separately to platform_profile any userspace changes to throttle_thermal_policy need to notify platform_profile.

In future throttle_thermal_policy sysfs should be removed so that only one method controls the laptop power profile.

Some comments below.

...

drivers/platform/x86/asus-wmi.c static int throttle_thermal_policy_set_default(struct asus_wmi *asus) · line 2122

Quoted 3 lines
drivers/platform/x86/asus-wmi.c +3 -0
+       /*
+        * Ensure that platform_profile updates userspace with the change to ensure
+        * that platform_profile and throttle_thermal_policy_mode are in sync

Missed period here and in other multi-line comments.

Quoted 1 line

+ */

...

drivers/platform/x86/asus-wmi.c static ssize_t throttle_thermal_policy_store(struct device *dev, · line 2188

Quoted 9 lines
drivers/platform/x86/asus-wmi.c +9 -0
+       /* All possible toggles like throttle_thermal_policy here */
+       if (asus->throttle_thermal_policy_available) {
+               tp = asus->throttle_thermal_policy_mode;
+       } else {
+               return -1;
+       }
+
+       if (tp < 0)
+               return tp;

This will be better in a form

    if (!..._available)
        return -ENODATA; // what -1 means?

    tp = ...;
    if (tp < 0)
        return tp;

...

drivers/platform/x86/asus-wmi.c static ssize_t throttle_thermal_policy_store(struct device *dev, · line 2217

Quoted 3 lines
drivers/platform/x86/asus-wmi.c +3 -0
+       /* All possible toggles like throttle_thermal_policy here */
+       if (!asus->throttle_thermal_policy_available) {
+               return -1;

See above.

Quoted 1 line

+ }

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (asus->throttle_thermal_policy_available) {
+               pr_info("Using throttle_thermal_policy for platform_profile support\n");

Why pr_*()?

drivers/platform/x86/asus-wmi.c static ssize_t throttle_thermal_policy_store(struct device *dev, · line 2249

Quoted 6 lines
drivers/platform/x86/asus-wmi.c +6 -0
+       } else {
+               /*
+                * Not an error if a component platform_profile relies on is unavailable
+                * so early return, skipping the setup of platform_profile.
+               */
+               return 0;

Do it other way around,

/*
* Comment
*/
if (!...)
return 0;

Quoted 1 line

+ }

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

Hi Andy, thanks for the feedback. All is addressed, and some inline comment/reply. New version incoming pending pr_info() vs dev_info()

Quoted 38 lines · Andy Shevchenko
Quoted 10 lines · Luke D. Jones

Add initial support for platform_profile where the support is based on availability of ASUS_THROTTLE_THERMAL_POLICY.

Because throttle_thermal_policy is used by platform_profile and is writeable separately to platform_profile any userspace changes to throttle_thermal_policy need to notify platform_profile.

In future throttle_thermal_policy sysfs should be removed so that only one method controls the laptop power profile.

Some comments below.

...

Quoted 5 lines

+ /*
+ * Ensure that platform_profile updates userspace with the
change to ensure
+ * that platform_profile and throttle_thermal_policy_mode
are in sync

Missed period here and in other multi-line comments.

Quoted 1 line

+ */

...

Quoted 9 lines

+ /* All possible toggles like throttle_thermal_policy here */
+ if (asus->throttle_thermal_policy_available) {
+ tp = asus->throttle_thermal_policy_mode;
+ } else {
+ return -1;
+ }
+
+ if (tp < 0)
+ return tp;

Quoted 5 lines

This will be better in a form

if (!..._available)
return -ENODATA; // what -1 means?

I wasn't sure what the best return was here. On your suggestion I've changed to ENODATA

Quoted 14 lines
    tp = ...;
    if (tp < 0)
        return tp;

...

Quoted 3 lines

+ /* All possible toggles like throttle_thermal_policy here */
+ if (!asus->throttle_thermal_policy_available) {
+ return -1;

See above.

Quoted 1 line

+ }

Quoted 7 lines

...

Quoted 3 lines

+ if (asus->throttle_thermal_policy_available) {
+ pr_info("Using throttle_thermal_policy for
platform_profile support\n");

Why pr_*()?

That seemed to be the convention? I see there is also dev_info(), so I've switched to that as it seems more appropriate.

Quoted 10 lines
Quoted 9 lines

+ } else {
+ /*
+ * Not an error if a component platform_profile
relies on is unavailable
+ * so early return, skipping the setup of
platform_profile.
+ */
+ return 0;

Quoted 7 lines

Do it other way around,

/*
* Comment
*/
if (!...)
return 0;

Thanks, I think I was transliterating thought process to code as I went along. All updated now.

Quoted 7 lines
Quoted 2 lines

+ }

--
With Best Regards,
Andy Shevchenko

author maintainer
#4 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

A very quick question: should I be enabling platform_profile by default if asus_wmi is enabled in kconfig?

Quoted 104 lines · Luke Jones

Hi Andy, thanks for the feedback. All is addressed, and some inline comment/reply. New version incoming pending pr_info() vs dev_info()

Quoted 39 lines · Andy Shevchenko
Quoted 10 lines · Luke D. Jones

Add initial support for platform_profile where the support is based on availability of ASUS_THROTTLE_THERMAL_POLICY.

Because throttle_thermal_policy is used by platform_profile and is writeable separately to platform_profile any userspace changes to throttle_thermal_policy need to notify platform_profile.

In future throttle_thermal_policy sysfs should be removed so that only one method controls the laptop power profile.

Some comments below.

...

Quoted 5 lines

+ /*
+ * Ensure that platform_profile updates userspace with the
change to ensure
+ * that platform_profile and throttle_thermal_policy_mode
are in sync

Missed period here and in other multi-line comments.

Quoted 1 line

+ */

...

Quoted 10 lines

+ /* All possible toggles like throttle_thermal_policy here
*/
+ if (asus->throttle_thermal_policy_available) {
+ tp = asus->throttle_thermal_policy_mode;
+ } else {
+ return -1;
+ }
+
+ if (tp < 0)
+ return tp;

Quoted 5 lines

This will be better in a form

if (!..._available)
return -ENODATA; // what -1 means?

I wasn't sure what the best return was here. On your suggestion I've changed to ENODATA

Quoted 15 lines
    tp = ...;
    if (tp < 0)
        return tp;

...

Quoted 4 lines

+ /* All possible toggles like throttle_thermal_policy here
*/
+ if (!asus->throttle_thermal_policy_available) {
+ return -1;

See above.

Quoted 1 line

+ }

Quoted 7 lines

...

Quoted 3 lines

+ if (asus->throttle_thermal_policy_available) {
+ pr_info("Using throttle_thermal_policy for
platform_profile support\n");

Why pr_*()?

That seemed to be the convention? I see there is also dev_info(), so I've switched to that as it seems more appropriate.

Quoted 10 lines
Quoted 9 lines

+ } else {
+ /*
+ * Not an error if a component platform_profile
relies on is unavailable
+ * so early return, skipping the setup of
platform_profile.
+ */
+ return 0;

Quoted 7 lines

Do it other way around,

/*
* Comment
*/
if (!...)
return 0;

Thanks, I think I was transliterating thought process to code as I went along. All updated now.

Quoted 7 lines
Quoted 2 lines

+ }

--
With Best Regards,
Andy Shevchenko

#5 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

Quoted 2 lines · Luke Jones

A very quick question: should I be enabling platform_profile by default if asus_wmi is enabled in kconfig?

Very quick for you, but me. I dunno. I think the best thing is what Hans can tell here.

Nevertheless, I think that this kind of default should be applied to all modules (yes, I know there might be possible exceptions).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

In reply to Luke Jones

Hi,

Quoted 1 line · Luke Jones

A very quick question: should I be enabling platform_profile by default if asus_wmi is enabled in kconfig?

You should add a "select ACPI_PLATFORM_PROFILE" to the Kconfig part for ASUS_WMI, the PLATFORM_PROFILE support / common code is a library, so it needs to be selected by the drivers which need it.

Regards,

Hans

Quoted 101 lines · Luke Jones
Quoted 97 lines

Hi Andy, thanks for the feedback. All is addressed, and some inline comment/reply. New version incoming pending pr_info() vs dev_info()

Quoted 36 lines · Andy Shevchenko
Quoted 10 lines · Luke D. Jones

 Add initial support for platform_profile where the support is based on availability of ASUS_THROTTLE_THERMAL_POLICY.

 Because throttle_thermal_policy is used by platform_profile and is writeable separately to platform_profile any userspace changes to throttle_thermal_policy need to notify platform_profile.

 In future throttle_thermal_policy sysfs should be removed so that only one method controls the laptop power profile.

Some comments below.

...

Quoted 3 lines

 +       /*
 +        * Ensure that platform_profile updates userspace with the change to ensure +        * that platform_profile and throttle_thermal_policy_mode are in sync

Missed period here and in other multi-line comments.

Quoted 1 line

 +        */

...

Quoted 9 lines

 +       /* All possible toggles like throttle_thermal_policy here */ +       if (asus->throttle_thermal_policy_available) {
 +               tp = asus->throttle_thermal_policy_mode; +       } else {
 +               return -1;
 +       }
 +
 +       if (tp < 0)
 +               return tp;

Quoted 5 lines

This will be better in a form

    if (!..._available)
        return -ENODATA; // what -1 means?

I wasn't sure what the best return was here. On your suggestion I've changed to ENODATA

Quoted 12 lines

    tp = ...;
    if (tp < 0)
        return tp;

...

Quoted 3 lines

 +       /* All possible toggles like throttle_thermal_policy here */ +       if (!asus->throttle_thermal_policy_available) {
 +               return -1;

See above.

Quoted 8 lines
Quoted 1 line

 +       }

...

Quoted 2 lines

 +       if (asus->throttle_thermal_policy_available) {
 +               pr_info("Using throttle_thermal_policy for platform_profile support\n");

Why pr_*()?

That seemed to be the convention? I see there is also dev_info(), so I've switched to that as it seems more appropriate.

Quoted 8 lines
Quoted 7 lines

 +       } else {
 +               /*
 +                * Not an error if a component platform_profile relies on is unavailable +                * so early return, skipping the setup of platform_profile. +               */
 +               return 0;

Quoted 7 lines

Do it other way around,

/*
 * Comment
 */
if (!...)
  return 0;

Thanks, I think I was transliterating thought process to code as I went along. All updated now.

Quoted 7 lines
Quoted 2 lines

 +       }

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v3 1/1] asus-wmi: Add support for platform_profile

In reply to Luke Jones
Quoted 3 lines · Luke Jones
Quoted 1 line · Andy Shevchenko

On Sat, Aug 14, 2021 at 7:33 AM Luke D. Jones <[email protected]> wrote:

...

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

+ pr_info("Using throttle_thermal_policy for
platform_profile support\n");

Why pr_*()?

That seemed to be the convention? I see there is also dev_info(), so I've switched to that as it seems more appropriate.

The rule of thumb is if you have the device the message belongs to, use dev_*(), if it's really stuff before we know anything about devices, use pr_*(). In some cases if you have ACPI handle, you may use acpi_handle_*().

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#8 lore raw
In reply to Luke D. Jones
Quoted 16 lines · Luke D. Jones

Changelog:
- V2
+ Correctly unregister from platform_profile if throttle_thermal_policy fails
+ Do platform_profile_notify() in both
throttle_thermal_policy_store()
and in throttle_thermal_policy_switch_next()
+ Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
- V3
+ Add missing declaration for err in throttle_thermal_policy_switch_next

Luke D. Jones (1):
asus-wmi: Add support for platform_profile

Quoted 6 lines
 drivers/platform/x86/asus-wmi.c | 139 
+++++++++++++++++++++++++++++++-
 1 file changed, 135 insertions(+), 4 deletions(-)

--
2.31.1

Hi,

I teested the patch again and it appears that the platform_profile_notify() in both throttle_thermal_policy_store() and throttle_thermal_policy_switch_next() updates the /sys/firmware/acpi/platform_profile sysfs path fine, but userspace isn't updated?

The way I'm checking is:
1. echo 1 |sudo tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy
2. cat -p /sys/firmware/acpi/platform_profile
- performance (updated correctly by platform_profile_notify)
3. Check gnome-settings, not updated.

Doing echo "performance" |sudo tee /sys/firmware/acpi/platform_profile updates both throttle_thermal_policy and userspace as expected. I'm wondering if I've missed something?

Cheers,
Luke.

#9 lore raw

Hi,

Quoted 28 lines · Luke Jones
Quoted 12 lines · Luke D. Jones

Changelog:
- V2
  + Correctly unregister from platform_profile if throttle_thermal_policy fails
  + Do platform_profile_notify() in both throttle_thermal_policy_store() and in throttle_thermal_policy_switch_next()
  + Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
- V3
  + Add missing declaration for err in throttle_thermal_policy_switch_next

Quoted 8 lines

Luke D. Jones (1):
  asus-wmi: Add support for platform_profile

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

 1 file changed, 135 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1

Hi,

I teested the patch again and it appears that the platform_profile_notify() in both throttle_thermal_policy_store() and throttle_thermal_policy_switch_next() updates the /sys/firmware/acpi/platform_profile sysfs path fine, but userspace isn't updated?

Quoted 7 lines

The way I'm checking is:
1. echo 1 |sudo tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy
2. cat -p /sys/firmware/acpi/platform_profile
  - performance (updated correctly by platform_profile_notify)
3. Check gnome-settings, not updated.

Doing echo "performance" |sudo tee /sys/firmware/acpi/platform_profile updates both throttle_thermal_policy and userspace as expected. I'm wondering if I've missed something?

If you add a printk where you call platform_profile_notify() and you see that happening, then you are likely seeing a userspace bug. Possibly your power-profile-daemon is simply a bit old and therefor does not support the combination of profiles which asus-wmi offers, IIRC it falls back to using intel-pstate in that case.

You could try building the latest power-profile-daemon from git and run it in verbose mode. If it sees the changes and the control-panel applet is still not updating then I would not worry about that. The userspace code is still somewhat new and I'm not sure which version your distro is running and how well it is keeping up with gnome-updates.

Regards,

Hans

#10 lore raw
Quoted 50 lines · Hans de Goede

Hi,

Quoted 42 lines · Luke Jones
Quoted 13 lines · Luke D. Jones

Changelog:
- V2
  + Correctly unregister from platform_profile if throttle_thermal_policy fails
  + Do platform_profile_notify() in both throttle_thermal_policy_store()
    and in throttle_thermal_policy_switch_next()
  + Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
- V3
  + Add missing declaration for err in throttle_thermal_policy_switch_next

Quoted 9 lines

Luke D. Jones (1):
  asus-wmi: Add support for platform_profile

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

 1 file changed, 135 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1

Hi,

I teested the patch again and it appears that the platform_profile_notify() in both throttle_thermal_policy_store() and throttle_thermal_policy_switch_next() updates the /sys/firmware/acpi/platform_profile sysfs path fine, but userspace isn't updated?

The way I'm checking is:
1. echo 1 |sudo tee /sys/devices/platform/asus-nb- wmi/throttle_thermal_policy
2. cat -p /sys/firmware/acpi/platform_profile
  - performance (updated correctly by platform_profile_notify)
3. Check gnome-settings, not updated.

Quoted 4 lines

Doing echo "performance" |sudo tee /sys/firmware/acpi/platform_profile updates both throttle_thermal_policy and userspace as expected. I'm wondering if I've missed something?

Quoted 7 lines

If you add a printk where you call platform_profile_notify() and you see that
happening, then you are likely seeing a userspace bug. Possibly your power-profile-daemon is simply a bit old and therefor does not support the combination of profiles which asus-wmi offers, IIRC it falls back to
using intel-pstate in that case.

Support for the quiet profile is only available in git:
https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/c9b646025d9f155509a6cda1c292bfd120daeb9e

You can apply the patch on top of 0.9.0 if you want to use your distribution's packages or something.

There's debugging info in the README should that be necessary.

Quoted 12 lines

You could try building the latest power-profile-daemon from git and run it in verbose mode. If it sees the changes and the control-panel applet is
still not updating then I would not worry about that. The userspace code
is still somewhat new and I'm not sure which version your distro is running and how well it is keeping up with gnome-updates.

Regards,

Hans

author maintainer
#11 lore raw
In reply to Hans de Goede
Quoted 42 lines · Hans de Goede

Hi,

Quoted 39 lines · Luke Jones
Quoted 16 lines · Luke D. Jones

Changelog:
- V2
+ Correctly unregister from platform_profile if throttle_thermal_policy fails
+ Do platform_profile_notify() in both
throttle_thermal_policy_store()
and in throttle_thermal_policy_switch_next()
+ Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
- V3
+ Add missing declaration for err in throttle_thermal_policy_switch_next

Luke D. Jones (1):
asus-wmi: Add support for platform_profile

Quoted 6 lines
  drivers/platform/x86/asus-wmi.c | 139 
+++++++++++++++++++++++++++++++-
  1 file changed, 135 insertions(+), 4 deletions(-)

--
2.31.1

Hi,

I teested the patch again and it appears that the
platform_profile_notify() in both throttle_thermal_policy_store() and throttle_thermal_policy_switch_next() updates the /sys/firmware/acpi/platform_profile sysfs path fine, but userspace isn't updated?

The way I'm checking is:
1. echo 1 |sudo tee
/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy
2. cat -p /sys/firmware/acpi/platform_profile
- performance (updated correctly by platform_profile_notify)
3. Check gnome-settings, not updated.

Quoted 8 lines
Quoted 2 lines

Doing `echo "performance" |sudo tee
/sys/firmware/acpi/platform_profile` updates both throttle_thermal_policy and userspace as expected. I'm wondering if I've missed something?

If you add a printk where you call platform_profile_notify() and you see that happening, then you are likely seeing a userspace bug. Possibly your power-profile-daemon is simply a bit old and therefor does not support the combination of profiles which asus-wmi offers, IIRC it falls back to using intel-pstate in that case.

It's possible that it's a userspace bug then. The power-profile-daemon I'm using is fresh from git (0.9+). To be clear updating via /sys/firmware/acpi/platform_profile works perfectly fine and power-profile-daemon updates etc. But if I do platform_profile_notify() then it doesn't seem to be updated. Nevertheless I will finalise the patch as it is and submit for merging and we can go from there.

Quoted 11 lines

You could try building the latest power-profile-daemon from git and run it in verbose mode. If it sees the changes and the control-panel applet is still not updating then I would not worry about that. The userspace code is still somewhat new and I'm not sure which version your distro is running and how well it is keeping up with gnome-updates.

Regards,

Hans

#12 lore raw

Hi,

Quoted 42 lines · Luke Jones
Quoted 39 lines · Hans de Goede

Hi,

Quoted 35 lines · Luke Jones
Quoted 12 lines · Luke D. Jones

 Changelog:
 - V2
   + Correctly unregister from platform_profile if throttle_thermal_policy fails
   + Do platform_profile_notify() in both throttle_thermal_policy_store() and in throttle_thermal_policy_switch_next()
   + Remove unnecessary prep for possible fan-boost modes as this doesn't match expected platform_profile behaviour
 - V3
   + Add missing declaration for err in throttle_thermal_policy_switch_next

Quoted 8 lines

 Luke D. Jones (1):
   asus-wmi: Add support for platform_profile

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

  1 file changed, 135 insertions(+), 4 deletions(-)

 --
 2.31.1

 Hi,

 I teested the patch again and it appears that the platform_profile_notify() in both throttle_thermal_policy_store() and throttle_thermal_policy_switch_next() updates the /sys/firmware/acpi/platform_profile sysfs path fine, but userspace isn't updated?

 The way I'm checking is:
 1. echo 1 |sudo tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy
 2. cat -p /sys/firmware/acpi/platform_profile
   - performance (updated correctly by platform_profile_notify)
 3. Check gnome-settings, not updated.

 Doing echo "performance" |sudo tee /sys/firmware/acpi/platform_profile updates both throttle_thermal_policy and userspace as expected. I'm wondering if I've missed something?

Quoted 7 lines
Quoted 5 lines

If you add a printk where you call platform_profile_notify() and you see that happening, then you are likely seeing a userspace bug. Possibly your power-profile-daemon is simply a bit old and therefor does not support the combination of profiles which asus-wmi offers, IIRC it falls back to using intel-pstate in that case.

It's possible that it's a userspace bug then. The power-profile-daemon I'm using is fresh from git (0.9+). To be clear updating via /sys/firmware/acpi/platform_profile works perfectly fine and power-profile-daemon updates etc. But if I do platform_profile_notify() then it doesn't seem to be updated. Nevertheless I will finalise the patch as it is and submit for merging and we can go from there.

This is weird, I wonder if there is a difference in glib versions used, where one does include polling for POLLPRI on sysfs files in GFileMonitor and the other only uses inotify which only catches changes from another userspace write ?

Regards,

Hans