"custom" ACPI platform profile support
Subsystems (3)
cover "custom" ACPI platform profile support
From: Mario Limonciello <[email protected]>
There are two major ways to tune platform performance in Linux:
* ACPI platform profile
* Manually tuning APU performance
Changing the ACPI platform profile is a "one stop shop" to change performance limits and fan curves all at the same time.
On AMD systems the manual tuning methods typically involve changing values of settings such as fPPT, sPPT or SPL.
The problem with changing these settings manually is that the definition of the ACPI platform profile if supported by the hardware is no longer accurate. At best this can cause misrepresenting the state of the platform to userspace and at worst can cause the state machine into an invalid state.
The existence and continued development of projects such as ryzenadj which manipulate debugging interfaces show there is a demand for manually tuning performance.
Furthermore some systems (such as ASUS and Lenovo handhelds) offer an ACPI-WMI interface for changing these settings. If using anything outside that WMI interface the state will be wrong. If using that WMI interface the platform profile will be wrong.
This series introduces a "custom" ACPI platform profile and adds support for the AMD PMF driver to use it when a user has enabled manual adjustments.
If agreeable a similar change should be made to asus-armoury and any other drivers that export the ability to change these settings but also a platform profile.
Mario Limonciello (2):
ACPI: Add support for a 'custom' profile platform/x86/amd: pmf: Add manual control support
Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ .../ABI/testing/sysfs-platform_profile | 1 + drivers/acpi/platform_profile.c | 1 + drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 ++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 + include/linux/platform_profile.h | 1 + 9 files changed, 120 insertions(+) create mode 100644 drivers/platform/x86/amd/pmf/manual.c
Signature · 1 line
2.43.0
RFC 1/2 ACPI: Add support for a 'custom' profile
From: Mario Limonciello <[email protected]>
Introduce a new profile type called 'custom' that can be set to allow changing settings outside of the standard profile settings.
The idea behind this is to enforce a state machine so that a user can't set 'balanced' then manually change one APU setting and confuse userspace because the system is no longer really behaving in balanced.
In practice the intention is that userspace would first set "custom" followed by modifying any settings. If userspace wants to go back to one of the predefined profiles then those profiles can be written to /sys/firmware/acpi/platform_profile.
--- Documentation/ABI/testing/sysfs-platform_profile | 1 + drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 3 files changed, 3 insertions(+)
Documentation/ABI/testing/sysfs-platform_profile +1 -0
@@ -15,6 +15,7 @@ Description: This file contains a space-separated list of profiles supported for power consumption with a slight bias towards performance performance High performance operation + custom Custom profile tuned by the user ==================== ======================================== Userspace may expect drivers to offer more than one of these
drivers/acpi/platform_profile.c +1 -0
@@ -19,6 +19,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_BALANCED] = "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", + [PLATFORM_PROFILE_CUSTOM ] ="custom" , };static_assert (ARRAY_SIZE (profile_names) ==PLATFORM_PROFILE_LAST );
include/linux/platform_profile.h +1 -0
@@ -23,6 +23,7 @@ enum platform_profile_option {PLATFORM_PROFILE_BALANCED ,PLATFORM_PROFILE_BALANCED_PERFORMANCE ,PLATFORM_PROFILE_PERFORMANCE , +PLATFORM_PROFILE_CUSTOM , PLATFORM_PROFILE_LAST, /*must always be last */ };
Signature · 1 line
2.43.0
RFC 2/2 platform/x86/amd: pmf: Add manual control support
In reply to Mario LimoncielloFrom: Mario Limonciello <[email protected]>
A number of users resort to using reverse engineered software like ryzenadj to manipulate debugging interfaces for modifying APU settings.
At a glance these tools are useful, but the problem is they break state machines in other software such as the PMF driver or the OEM EC.
Offer a knob for PMF to allow 'manual control' which will users can directly change things like fPPT and sPPT. As this can be harmful for a system to try to push limits outside of a thermal design, taint the kernel and show a critical message when in use.
--- Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 +++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 ++ 6 files changed, 117 insertions(+) create mode 100644 drivers/platform/x86/amd/pmf/manual.c
Documentation/ABI/testing/sysfs-amd-pmf +10 -0
@@ -11,3 +11,13 @@ Description: Reading this file tells if the AMD Platform Management(PMF) To turn off CnQF user can write "off" to the sysfs node. Note: Systems that support auto mode will not have this sysfs file available. + +What: /sys/devices/platform/*/{spl, fppt, sppt, sppt_apu_only, stt_min, stt_limit_apu, stt_skip_temp} +Date: December 2024 +Contact: Mario Limonciello <[email protected]> +Description: Manual control of AMD PMF APU coefficients + . + These files are used to manually control the APU coefficients. + In order to write to these files the module most be + loaded with manual_control=1 and the user must write "custom" + to the ACPI platform profile.
drivers/platform/x86/amd/pmf/Makefile +1 -0
@@ -7,4 +7,5 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ + manual.o \ tee-if.o spc.o pmf-quirks.o
drivers/platform/x86/amd/pmf/core.c +9 -0
@@ -53,6 +53,10 @@ static bool force_load;module_param (force_load, bool,0444 );MODULE_PARM_DESC (force_load,"Force load this driver on supported older platforms (experimental)" ); +bool pmf_manual_control; +module_param_named (manual_control, pmf_manual_control, bool,0444 ); +MODULE_PARM_DESC (manual_control,"Expose manual control knobs (experimental)" ); +static int amd_pmf_pwr_src_notify_call (struct notifier_block *nb,unsigned long event,void *data) { struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);
@@ -349,6 +353,10 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)dev_dbg (dev->dev,"SPS enabled and Platform Profiles registered\n" ); } +if (pmf_manual_control) { +amd_pmf_init_manual_control (dev); +return ; + }amd_pmf_init_smart_pc (dev);if (dev->smart_pc_enabled) {dev_dbg (dev->dev,"Smart PC Solution Enabled\n" );
@@ -485,6 +493,7 @@ static void amd_pmf_remove(struct platform_device *pdev)static const struct attribute_group *amd_pmf_driver_groups[] = { &cnqf_feature_attribute_group, + &manual_attribute_group,NULL , };
drivers/platform/x86/amd/pmf/manual.c new file +88 -0
88 lines not on this page · raw message
drivers/platform/x86/amd/pmf/pmf.h +5 -0
@@ -798,4 +798,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table */* Quirk infrastructure */ void amd_pmf_quirks_init (struct amd_pmf_dev *dev); +/* Manual configuration */ +extern bool pmf_manual_control; +extern const struct attribute_group manual_attribute_group; +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev); +#endif /* PMF_H */
drivers/platform/x86/amd/pmf/sps.c +4 -0
@@ -305,6 +305,8 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)case PLATFORM_PROFILE_LOW_POWER : mode =POWER_MODE_POWER_SAVER ;break ; +case PLATFORM_PROFILE_CUSTOM : +return 0 ;default :dev_err (pmf->dev,"Unknown Platform Profile.\n" );return -EOPNOTSUPP ;
@@ -412,6 +414,8 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)set_bit (PLATFORM_PROFILE_LOW_POWER , dev->pprof.choices);set_bit (PLATFORM_PROFILE_BALANCED , dev->pprof.choices);set_bit (PLATFORM_PROFILE_PERFORMANCE , dev->pprof.choices); +if (pmf_manual_control) +set_bit (PLATFORM_PROFILE_CUSTOM , dev->pprof.choices);/* Create platform_profile structure and register */ err =platform_profile_register (&dev->pprof);
Signature · 1 line
2.43.0
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Hi Mario,
It is fine to require a module parameter for turning on custom profiles.
However, distributions such as Bazzite use per-device kernel parameters, which, while user accessible, will not be modified by the user for 95% of use-cases. In fact, the Bazzite update system manages the kernel parameters of devices automatically.
What this would mean in practice is that for devices where this custom control may be used, the module parameter will be set globally for all of them and taint their kernels.
Instead, only taint the kernel when entering custom mode. If combined with something such as custom_mode_choices, only taint the kernel if amd-pmf-user is selected after that.
drivers/platform/x86/amd/pmf/manual.c line 88
Quoted 5 lines
drivers/platform/x86/amd/pmf/manual.c new file +5
-0+{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}
"Manual PMF control is enabled. If the device supports other ways of thermal management, please use those before reporting any bugs unrelated to PMF. If not, only if setting TDP is required for testing (e.g., under load in specific thermal conditions), proceed with the understanding that this module may cause interference, especially with the amd-gpu driver, the suspend process, and, if the parameters are out of spec, general stability of the system."
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 9 lines · Antheas Kapenekakis
Hi Mario,
It is fine to require a module parameter for turning on custom profiles.
However, distributions such as Bazzite use per-device kernel parameters, which, while user accessible, will not be modified by the user for 95% of use-cases. In fact, the Bazzite update system manages the kernel parameters of devices automatically.
Quoted 7 lines
What this would mean in practice is that for devices where this custom control may be used, the module parameter will be set globally for all of them and taint their kernels.
Instead, only taint the kernel when entering custom mode. If combined with something such as
custom_mode_choices, only taint the kernel ifamd-pmf-useris selected after that.
Yeah if we continue down a variation of this direction that is a sensible change to push the taint down to only when in it's actually been used, not just when the module parameter is set.
Quoted 16 lines
drivers/platform/x86/amd/pmf/manual.c line 88
Quoted 6 lines
drivers/platform/x86/amd/pmf/manual.c new file +5
-0+{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}"Manual PMF control is enabled. If the device supports other ways of thermal management, please use those before reporting any bugs unrelated to PMF. If not, only if setting TDP is required for testing (e.g., under load in specific thermal conditions), proceed with the understanding that this module may cause interference, especially with the amd-gpu driver, the suspend process, and, if the parameters are out of spec, general stability of the system."
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Hello all,
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
I appreciate the proposal, but giving users this control seems similar to using tools like Ryzenadj or Ryzen Master, which are primarily for overclocking. Atleast Ryzen Master has a dedicated mailbox with PMFW.
In the laptop market I agree with you. However, in the handheld market, users expect to be able to lower the power envelope of the device on demand in a granular fashion. As the battery drop is measured in Watts, tying a slider to Watts is a natural solution.
Quoted 4 lines
Most of the time, when those controls are used it is to limit the thermal envelope of the device, not exceed it. We want to remove the use of these tools and allow manufacturers the ability to customise the power envelope they offer to users.
I agree with Mario here. Due to the use case and battery size, handheld users intent is to minimize power draw while maintaining performance. The typical use case in "per-watt" control is to manage this. It is usually done per-game (either
manually by the user or recalled with userspace tools). We have found that the 'performance' profile alone won't always limit the power enough, which decreases the playtime, and 'balanced' will limit it too much, decreasing performance. Users want to be able to tune a "sweet spot" to get maximal performance from both metrics.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
While some existing PMF mailboxes are being deprecated, and SPL has been removed starting with Strix[1] due to the APTS method.
Hmm, what do you think about about offering a wrapper for this for people to manipulate?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
It's important to use some settings together rather than individually (which the users might not be aware of). For instance, updating SPL requires corresponding updates to STT limits to avoid negative outcomes.
The tough part about striking the balance here is how would an end user know what values to set in tandem. I think a lot of people just assume they can "just change SPL" and that's it and have a good experience.
I'm unsure of the generalized case here, but if we are using this to limit SPL rather than raise it over design spec, then it would seem to me that STT would be set to match or exceed SPL and the cooling solution would be able to compensate for that. I'm happy to be corrected here if this is not a correct assumption. I think there may be some variation on how manufacturers implement this in the BIOS. For example, the Legion Go uses STT to push TDP to the thermal limit (between SPL and SPPT) when using the ACPI profiles. Their "custom" profile changes the behavior to fully respect the user set SPL/SPPT/ FPPT. I'm not sure if/how others handle this differently. In any case, I would expect
the driver could handle this.
Quoted 10 lines
Quoted 7 lines
This suggestion was referring to a combined slider, much like the suggestion below. So STT limits would be modified in tandem, respecting manufacturer profiles. See comments below.
If you find the name SPL disagreeable, it could be named {tdp,
tdp_min,tdp_max}. This is the solution used by Valve on the Steam Deck (power1_cap{+min,max}, power2_cap{+min,max}).It's not so much that it's disagreeable term but Shyam is pointing out that SPL is no longer a valid argument to the platform mailbox.
I think intuitive generic terms would be ideal. [ppt|sppt|fppt]_limit[_min|_max] are well understood by power users currently. There should be some terminology that applies generally across different implementations of similar concepts.
Quoted 5 lines
Quoted 5 lines
In addition, boost is seen as detrimental to handheld devices, with most users disliking and disabling it. Steam Deck does not use boost. It is disabled by Steam (
power1_cap==power2_cap). So STT and STAPM are not very relevant. In addition, Steam Deck van gogh has a more linear response so TDP limits are less required.
I find this to be case by case, some games have more sudden/dynamic loads and need the extra overhead, while others will waste it. Flexibility is important I think. The Deck also benefits from scale and Steam integration right now so publishers are able to, and do, tune for that device specifically. I don't know how far the lessons from that device transfer to other handhelds. Having them as an option, even if unused, would be a benefit.
Quoted 27 lines
Quoted 6 lines
Quoted 6 lines
Additionally, altering these parameters can exceed thermal limits and potentially void warranties.
Considering CnQF, why not let OEMs opt-in and allow the algorithm to manage power budgets, rather than providing these controls to users from the kernel when userspace tools already exist?
The problem is all of the RE tools rely upon PCI config space access or
/dev/memaccess to manipulate undocumented register offsets.When the system is under kernel lockdown (such as with distro kernel when UEFI secure boot is turned on) then those interfaces are intentionally locked down.
That's why I'm hoping we can strike some sort of balance at the request for some advanced users being able to tune values in a predictable fashion while also allowing OEMs to configure policies like CNQF or Smart PC when users for users that don't tinker.
Quoted 3 lines
Quoted 3 lines
Please note that on systems with Smart PC enabled, if users manually adjust the system thermals, it can lead to the thermal controls becoming unmanageable.
Yeah; that's why as this RFC patch I didn't let CNQF, ITS or Smart PC initialize. Basically if manual control is enabled then "SPS" and manual sysfs control is the only thing available.
Quoted 8 lines
Quoted 5 lines
Much like you, we dislike AutoTDP solutions that use e.g., RyzenAdj, as they:
1) Do not respect manufacturer limits
2) Cause system instability such as stutters when setting values
3) Can cause crashes if they access the mailbox at the same time as
the AMD drm driver.Yes. Exactly why I feel that if we offer an interface instead people can use such an interface instead of these tools.
The general consensus on the userspace development side is that we'd like to move away from needing to do these hacks to get the most from the hardware. I would say things like RyzenAdj, ryzen_smu, acpi_call, etc. have provided enough evidence that there is a gap in the baseline functionality that will ultimately be filled *somehow*. I'd like to see a move towards this as an acceptable in-kernel standard to replace those tools. In that same vein I think it's important that common sense defaults and manufacturers intent are respected. I have some ideas for how that could be done. If information is not available for a
given device then the "custom" parameter will not be available in power_profile_available and attempts to set to it will -EINVAL. Similarly, have PPT
attrs only show in sysfs if that data is available.
- For legacy devices (and likely many smaller "boutique" manufacturers for the foreseeable future) a DMI table with limits for each supported attribute could provide this. Limiting this table to handhelds specifically would be acceptable to me, I don't see the value for laptops personally. For almost everything on the market currently we have this data, provided by the OEM.
- For devices with WMI (Legion Go, ROG Ally) the manufacturer has provided the methods to get these limits directly, so that could be handled in the appropriate manufacturer WMI drivers.
- For future devices this information should be (is?) included in the PMF tables in the BIOS and enabled automatically when detected by the driver, which will hopefully reduce the number of necessary kernel patches going forward.
Shyam Sundar S K
maintainerRe: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
In reply to Mario LimoncielloQuoted 5 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
A number of users resort to using reverse engineered software like ryzenadj to manipulate debugging interfaces for modifying APU settings.
Quoted 8 lines
At a glance these tools are useful, but the problem is they break state machines in other software such as the PMF driver or the OEM EC.
Offer a knob for PMF to allow 'manual control' which will users can directly change things like fPPT and sPPT. As this can be harmful for a system to try to push limits outside of a thermal design, taint the kernel and show a critical message when in use.
I appreciate the proposal, but giving users this control seems similar to using tools like Ryzenadj or Ryzen Master, which are primarily for overclocking. Atleast Ryzen Master has a dedicated mailbox with PMFW.
While some existing PMF mailboxes are being deprecated, and SPL has been removed starting with Strix[1] due to the APTS method.
It's important to use some settings together rather than individually (which the users might not be aware of). For instance, updating SPL requires corresponding updates to STT limits to avoid negative outcomes.
Additionally, altering these parameters can exceed thermal limits and potentially void warranties.
Considering CnQF, why not let OEMs opt-in and allow the algorithm to manage power budgets, rather than providing these controls to users from the kernel when userspace tools already exist?
Please note that on systems with Smart PC enabled, if users manually adjust the system thermals, it can lead to the thermal controls becoming unmanageable.
Please consider this perspective.
[1]
https://github.com/torvalds/linux/blob/master/drivers/platform/x86/amd/pmf/sps.c#L193
IMHO, having a 'custom' platform-profile node is fine, but tieing that to PMF static slider would be a NO from my side, because of the above said reasons.
Thanks,
Shyam
Quoted 204 lines
Signed-off-by Mario Limonciello <[email protected]>--- Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 +++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 ++ 6 files changed, 117 insertions(+) create mode 100644 drivers/platform/x86/amd/pmf/manual.cDocumentation/ABI/testing/sysfs-amd-pmf +10
-0@@ -11,3 +11,13 @@ Description: Reading this file tells if the AMD Platform Management(PMF) To turn off CnQF user can write "off" to the sysfs node. Note: Systems that support auto mode will not have this sysfs file available. + +What: /sys/devices/platform/*/{spl, fppt, sppt, sppt_apu_only, stt_min, stt_limit_apu, stt_skip_temp} +Date: December 2024 +Contact: Mario Limonciello <[email protected]> +Description: Manual control of AMD PMF APU coefficients + . + These files are used to manually control the APU coefficients. + In order to write to these files the module most be + loaded with manual_control=1 and the user must write "custom" + to the ACPI platform profile.drivers/platform/x86/amd/pmf/Makefile +1
-0@@ -7,4 +7,5 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ + manual.o \ tee-if.o spc.o pmf-quirks.odrivers/platform/x86/amd/pmf/core.c +9
-0@@ -53,6 +53,10 @@ static bool force_load;module_param (force_load, bool,0444 );MODULE_PARM_DESC (force_load,"Force load this driver on supported older platforms (experimental)" ); +bool pmf_manual_control; +module_param_named (manual_control, pmf_manual_control, bool,0444 ); +MODULE_PARM_DESC (manual_control,"Expose manual control knobs (experimental)" ); +static int amd_pmf_pwr_src_notify_call (struct notifier_block *nb,unsigned long event,void *data) { struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);@@ -349,6 +353,10 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)dev_dbg (dev->dev,"SPS enabled and Platform Profiles registered\n" ); } +if (pmf_manual_control) { +amd_pmf_init_manual_control (dev); +return ; + }amd_pmf_init_smart_pc (dev);if (dev->smart_pc_enabled) {dev_dbg (dev->dev,"Smart PC Solution Enabled\n" );@@ -485,6 +493,7 @@ static void amd_pmf_remove(struct platform_device *pdev)static const struct attribute_group *amd_pmf_driver_groups[] = { &cnqf_feature_attribute_group, + &manual_attribute_group,NULL , };drivers/platform/x86/amd/pmf/manual.c new file +88
-0@@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* AMD Platform Management Framework Driver +* +* Copyright (c) 2024, Advanced Micro Devices, Inc. +* All Rights Reserved. +* +* Author: Mario Limonciello <[email protected]> +*/ + +#include "pmf.h" + +#define pmf_manual_attribute (_name, _set_command, _get_command) \ +static ssize_t _name##_store(struct device *d, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + if (dev->current_profile != PLATFORM_PROFILE_CUSTOM) { \ + dev_warn_once(dev->dev, \ + "Manual control is disabled, please set " \ + "platform profile to custom.\n"); \ + return -EINVAL; \ + } \ + \ + if (kstrtouint(buf, 10, &val) < 0) \ + return -EINVAL; \ + \ + amd_pmf_send_cmd(dev, _set_command, false, val, NULL); \ + \ + return count; \ +} \ +static ssize_t _name##_show(struct device *d, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + amd_pmf_send_cmd(dev, _get_command, true, ARG_NONE, &val); \ + \ + return sysfs_emit(buf, "%u\n", val); \ +} + +pmf_manual_attribute (spl,SET_SPL ,GET_SPL ); +static DEVICE_ATTR_RW (spl); +pmf_manual_attribute (fppt,SET_FPPT ,GET_FPPT ); +static DEVICE_ATTR_RW (fppt); +pmf_manual_attribute (sppt,SET_SPPT ,GET_SPPT ); +static DEVICE_ATTR_RW (sppt); +pmf_manual_attribute (sppt_apu_only,SET_SPPT_APU_ONLY ,GET_SPPT_APU_ONLY ); +static DEVICE_ATTR_RW (sppt_apu_only); +pmf_manual_attribute (stt_min,SET_STT_MIN_LIMIT ,GET_STT_MIN_LIMIT ); +static DEVICE_ATTR_RW (stt_min); +pmf_manual_attribute (stt_limit_apu,SET_STT_LIMIT_APU ,GET_STT_LIMIT_APU ); +static DEVICE_ATTR_RW (stt_limit_apu); +pmf_manual_attribute (stt_skin_temp,SET_STT_LIMIT_HS2 ,GET_STT_LIMIT_HS2 ); +static DEVICE_ATTR_RW (stt_skin_temp); + +static umode_t manual_attr_is_visible (struct kobject *kobj,struct attribute *attr,int idx) +{ +return pmf_manual_control ?0660 :0 ; +} + +static struct attribute *manual_attrs[] = { + &dev_attr_spl.attr, + &dev_attr_fppt.attr, + &dev_attr_sppt.attr, + &dev_attr_sppt_apu_only.attr, + &dev_attr_stt_min.attr, + &dev_attr_stt_limit_apu.attr, + &dev_attr_stt_skin_temp.attr, +NULL , +}; + +const struct attribute_group manual_attribute_group = { + .attrs = manual_attrs, + .is_visible = manual_attr_is_visible, +}; + +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev) +{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}drivers/platform/x86/amd/pmf/pmf.h +5
-0@@ -798,4 +798,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table */* Quirk infrastructure */ void amd_pmf_quirks_init (struct amd_pmf_dev *dev); +/* Manual configuration */ +extern bool pmf_manual_control; +extern const struct attribute_group manual_attribute_group; +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev); +#endif /* PMF_H */ drivers/platform/x86/amd/pmf/sps.c +4
-0@@ -305,6 +305,8 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)case PLATFORM_PROFILE_LOW_POWER : mode =POWER_MODE_POWER_SAVER ;break ; +case PLATFORM_PROFILE_CUSTOM : +return 0 ;default :dev_err (pmf->dev,"Unknown Platform Profile.\n" );return -EOPNOTSUPP ;@@ -412,6 +414,8 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)set_bit (PLATFORM_PROFILE_LOW_POWER , dev->pprof.choices);set_bit (PLATFORM_PROFILE_BALANCED , dev->pprof.choices);set_bit (PLATFORM_PROFILE_PERFORMANCE , dev->pprof.choices); +if (pmf_manual_control) +set_bit (PLATFORM_PROFILE_CUSTOM , dev->pprof.choices);/* Create platform_profile structure and register */ err =platform_profile_register (&dev->pprof);
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Hi Shyam,
Quoted 3 lines
I appreciate the proposal, but giving users this control seems similar to using tools like Ryzenadj or Ryzen Master, which are primarily for overclocking. Atleast Ryzen Master has a dedicated mailbox with PMFW.
In the laptop market I agree with you. However, in the handheld market, users expect to be able to lower the power envelope of the device on demand in a granular fashion. As the battery drop is measured in Watts, tying a slider to Watts is a natural solution.
Most of the time, when those controls are used it is to limit the thermal envelope of the device, not exceed it. We want to remove the use of these tools and allow manufacturers the ability to customise the power envelope they offer to users.
Quoted 6 lines
While some existing PMF mailboxes are being deprecated, and SPL has been removed starting with Strix[1] due to the APTS method.
It's important to use some settings together rather than individually (which the users might not be aware of). For instance, updating SPL requires corresponding updates to STT limits to avoid negative outcomes.
This suggestion was referring to a combined slider, much like the suggestion below. So STT limits would be modified in tandem, respecting manufacturer profiles. See comments below.
If you find the name SPL disagreeable, it could be named {tdp, tdp_min, tdp_max}. This is the solution used by Valve on the Steam Deck (power1_cap{+min,max}, power2_cap{+min,max}).
In addition, boost is seen as detrimental to handheld devices, with most users disliking and disabling it. Steam Deck does not use boost. It is disabled by Steam (power1_cap == power2_cap). So STT and STAPM are not very relevant. In addition, Steam Deck van gogh has a more linear response so TDP limits are less required.
Quoted 7 lines
Additionally, altering these parameters can exceed thermal limits and potentially void warranties.
Considering CnQF, why not let OEMs opt-in and allow the algorithm to manage power budgets, rather than providing these controls to users from the kernel when userspace tools already exist?
Quoted 8 lines
Please note that on systems with Smart PC enabled, if users manually adjust the system thermals, it can lead to the thermal controls becoming unmanageable.
Please consider this perspective.
[1]
https://github.com/torvalds/linux/blob/master/drivers/platform/x86/amd/pmf/sps.c#L193
This slider looks like it would do what we would need. I will note the importance of tying the slider to Watts to manage user expectation and adding more gradations (e.g., 15-25, every 1-2W for sub-50W devices).
We have found automatic solutions to not work in the handheld market, as most AAA games will consume the maximum TDP the profile allows. In addition, due to performance non-linearities above e.g., 15W, performance will be similar. For example, on the Legion Go, performance might increase 20% when going from 17W-25W, however consumption will increase from ~30W to 45W (50%) which greatly affects battery life.
Therefore, we need to allow the user to choose between 20% and extra battery life. If you think we can use an algorithm for this I would love to know.
Much like you, we dislike AutoTDP solutions that use e.g., RyzenAdj, as they:
1) Do not respect manufacturer limits
2) Cause system instability such as stutters when setting values
3) Can cause crashes if they access the mailbox at the same time as
the AMD drm driver.
Thank you for your time,
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 11 lines · Antheas Kapenekakis
Hi Shyam,
Quoted 3 lines
I appreciate the proposal, but giving users this control seems similar to using tools like Ryzenadj or Ryzen Master, which are primarily for overclocking. Atleast Ryzen Master has a dedicated mailbox with PMFW.
In the laptop market I agree with you. However, in the handheld market, users expect to be able to lower the power envelope of the device on demand in a granular fashion. As the battery drop is measured in Watts, tying a slider to Watts is a natural solution.
Quoted 7 lines
Most of the time, when those controls are used it is to limit the thermal envelope of the device, not exceed it. We want to remove the use of these tools and allow manufacturers the ability to customise the power envelope they offer to users.
Quoted 2 lines
While some existing PMF mailboxes are being deprecated, and SPL has been removed starting with Strix[1] due to the APTS method.
Hmm, what do you think about about offering a wrapper for this for people to manipulate?
Quoted 5 lines
Quoted 4 lines
It's important to use some settings together rather than individually (which the users might not be aware of). For instance, updating SPL requires corresponding updates to STT limits to avoid negative outcomes.
The tough part about striking the balance here is how would an end user know what values to set in tandem. I think a lot of people just assume they can "just change SPL" and that's it and have a good experience.
Quoted 7 lines
This suggestion was referring to a combined slider, much like the suggestion below. So STT limits would be modified in tandem, respecting manufacturer profiles. See comments below.
If you find the name SPL disagreeable, it could be named {tdp,
tdp_min,tdp_max}. This is the solution used by Valve on the Steam Deck (power1_cap{+min,max}, power2_cap{+min,max}).
It's not so much that it's disagreeable term but Shyam is pointing out that SPL is no longer a valid argument to the platform mailbox.
Quoted 13 lines
In addition, boost is seen as detrimental to handheld devices, with most users disliking and disabling it. Steam Deck does not use boost. It is disabled by Steam (
power1_cap==power2_cap). So STT and STAPM are not very relevant. In addition, Steam Deck van gogh has a more linear response so TDP limits are less required.Quoted 6 lines
Additionally, altering these parameters can exceed thermal limits and potentially void warranties.
Considering CnQF, why not let OEMs opt-in and allow the algorithm to manage power budgets, rather than providing these controls to users from the kernel when userspace tools already exist?
The problem is all of the RE tools rely upon PCI config space access or /dev/mem access to manipulate undocumented register offsets.
When the system is under kernel lockdown (such as with distro kernel when UEFI secure boot is turned on) then those interfaces are intentionally locked down.
That's why I'm hoping we can strike some sort of balance at the request for some advanced users being able to tune values in a predictable fashion while also allowing OEMs to configure policies like CNQF or Smart PC when users for users that don't tinker.
Quoted 4 lines
Quoted 4 lines
Please note that on systems with Smart PC enabled, if users manually adjust the system thermals, it can lead to the thermal controls becoming unmanageable.
Yeah; that's why as this RFC patch I didn't let CNQF, ITS or Smart PC initialize. Basically if manual control is enabled then "SPS" and manual sysfs control is the only thing available.
Quoted 7 lines
Much like you, we dislike AutoTDP solutions that use e.g., RyzenAdj, as they:
1) Do not respect manufacturer limits
2) Cause system instability such as stutters when setting values
3) Can cause crashes if they access the mailbox at the same time as
the AMD drm driver.
Yes. Exactly why I feel that if we offer an interface instead people can use such an interface instead of these tools.
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Hi Mario,
Quoted 18 lines · Mario Limonciello
Quoted 16 lines · Antheas Kapenekakis
Hi Shyam,
Quoted 3 lines
I appreciate the proposal, but giving users this control seems similar to using tools like Ryzenadj or Ryzen Master, which are primarily for overclocking. Atleast Ryzen Master has a dedicated mailbox with PMFW.
In the laptop market I agree with you. However, in the handheld market, users expect to be able to lower the power envelope of the device on demand in a granular fashion. As the battery drop is measured in Watts, tying a slider to Watts is a natural solution.
Most of the time, when those controls are used it is to limit the thermal envelope of the device, not exceed it. We want to remove the use of these tools and allow manufacturers the ability to customise the power envelope they offer to users.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
While some existing PMF mailboxes are being deprecated, and SPL has been removed starting with Strix[1] due to the APTS method.
Hmm, what do you think about about offering a wrapper for this for people to manipulate?
Having a single call that sets everything would be my preference, so I would support this.
Although looking at [1], seems like it will be separate calls anway.
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
It's important to use some settings together rather than individually (which the users might not be aware of). For instance, updating SPL requires corresponding updates to STT limits to avoid negative outcomes.
The tough part about striking the balance here is how would an end user know what values to set in tandem. I think a lot of people just assume they can "just change SPL" and that's it and have a good experience.
Spoken like a true linux user. Users do not know what a kernel or sysfs is and they will not be touching any of this. It just needs to be baby-proofed enough so for the 5 users that do it is safe.
Let us focus on the problem here. There are currently around 5 manufacturers shipping products in a space where granular TDP control is expected and where AMD has not provided them with a solution.
And for this, there are two issues. First, there is no standard for granular TDP control tuned by the manufacturer. Second, when such a standard is created, there is a healthy pool of devices in the market where the manufacturer cannot be expected to provide an updated BIOS for them.
Therefore, we need a proposal where 1) the manufacturer can provide granular TDP controls in a fully customizable manner (e.g., with a LUT that controls everything), and 2) for devices that will not get that tuning, a custom profile setting that will expose important tuning parameters to userspace so that we can retrofit it and extend the their lifespan.
Quoted 10 lines
Quoted 7 lines
This suggestion was referring to a combined slider, much like the suggestion below. So STT limits would be modified in tandem, respecting manufacturer profiles. See comments below.
If you find the name SPL disagreeable, it could be named {tdp,
tdp_min,tdp_max}. This is the solution used by Valve on the Steam Deck (power1_cap{+min,max}, power2_cap{+min,max}).It's not so much that it's disagreeable term but Shyam is pointing out that SPL is no longer a valid argument to the platform mailbox.
I'd tend to agree since the current mailbox targets that I know of are STAPM limit (for STAPM) and skin temp limit (for STT). Since you used the term SPL, I carried that over to the proposal, but it would not control SPL. Instead it would control both of the former, including sPPT and fPPT (if that is still supported; unclear in [1]; but disabling boost will be a requirement).
Quoted 17 lines
Quoted 13 lines
In addition, boost is seen as detrimental to handheld devices, with most users disliking and disabling it. Steam Deck does not use boost. It is disabled by Steam (
power1_cap==power2_cap). So STT and STAPM are not very relevant. In addition, Steam Deck van gogh has a more linear response so TDP limits are less required.Quoted 6 lines
Additionally, altering these parameters can exceed thermal limits and potentially void warranties.
Considering CnQF, why not let OEMs opt-in and allow the algorithm to manage power budgets, rather than providing these controls to users from the kernel when userspace tools already exist?
The problem is all of the RE tools rely upon PCI config space access or
/dev/memaccess to manipulate undocumented register offsets.
Quoted 8 lines
When the system is under kernel lockdown (such as with distro kernel when UEFI secure boot is turned on) then those interfaces are intentionally locked down.
That's why I'm hoping we can strike some sort of balance at the request for some advanced users being able to tune values in a predictable fashion while also allowing OEMs to configure policies like CNQF or Smart PC when users for users that don't tinker.
I will have to repeat that as far as the handheld market is concerned, we are not talking about advanced users. Instead, we are talking for all users.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Please note that on systems with Smart PC enabled, if users manually adjust the system thermals, it can lead to the thermal controls becoming unmanageable.
Yeah; that's why as this RFC patch I didn't let CNQF, ITS or Smart PC initialize. Basically if manual control is enabled then "SPS" and manual sysfs control is the only thing available.
Sounds like you have your work cut out for you if the custom profile is supposed to dynamically load.
Quoted 10 lines
Quoted 7 lines
Much like you, we dislike AutoTDP solutions that use e.g., RyzenAdj, as they:
1) Do not respect manufacturer limits
2) Cause system instability such as stutters when setting values
3) Can cause crashes if they access the mailbox at the same time as
the AMD drm driver.Yes. Exactly why I feel that if we offer an interface instead people can use such an interface instead of these tools.
While (in Bazzite) we have a solution that works very reliably and is safe (not RyzenAdj), we have to begin cleaning up loose ends so that we can 1) enable TDP control in a stock secureboot kernel with early lockdown enabled (e.g., Fedora), 2) provide manufacturers with certain reliability guarantees so they can warranty units running under linux,
3) prepare our solutions for being packaged in upstream distribution repositories (Debian, Fedora), where using an existing solution is a blocker as they do not provide or should provide such hardware access when secure boot is enabled.
Though, since manufacturers like Ayaneo currently use RyzenAdj in Windows, I might be nitpicking too much.
As for why Secure Boot is important, let add [2], where Rockstar points the finger to Valve for BattlEye not working. Much of the anticheat issue is due to the fact that it is trivial to cheat without having a secureboot enabled kernel with the early lockdown flag engaged, as it allows both custom drivers and userspace to gain access to sensitive process memory in a way that is undetectable by anticheat. Vanguard does not work in Linux for much of the same reason.
Steam Deck is, for those uninitiated, a device that does not carry Secureboot keys, and SteamOS is a distribution that does not support Secure boot. Although both can change (Steam Deck BIOS supports secure boot). However, Bazzite is secure boot enabled and we encourage our users to leave it enabled, although for the moment they have to enroll our MOK key, which most of them do.
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
In reply to Mario LimoncielloHi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.
So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down /dev/mem and ACPI by spring.
Moreover, since the other two proposed drivers use the firmware_attributes API, should this be used here as well?
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Antheas
Quoted 221 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
A number of users resort to using reverse engineered software like ryzenadj to manipulate debugging interfaces for modifying APU settings.
At a glance these tools are useful, but the problem is they break state machines in other software such as the PMF driver or the OEM EC.
Offer a knob for PMF to allow 'manual control' which will users can directly change things like fPPT and sPPT. As this can be harmful for a system to try to push limits outside of a thermal design, taint the kernel and show a critical message when in use.
Signed-off-by Mario Limonciello <[email protected]>--- Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 +++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 ++ 6 files changed, 117 insertions(+) create mode 100644 drivers/platform/x86/amd/pmf/manual.cDocumentation/ABI/testing/sysfs-amd-pmf +10
-0@@ -11,3 +11,13 @@ Description: Reading this file tells if the AMD Platform Management(PMF) To turn off CnQF user can write "off" to the sysfs node. Note: Systems that support auto mode will not have this sysfs file available. + +What: /sys/devices/platform/*/{spl, fppt, sppt, sppt_apu_only, stt_min, stt_limit_apu, stt_skip_temp} +Date: December 2024 +Contact: Mario Limonciello <[email protected]> +Description: Manual control of AMD PMF APU coefficients + . + These files are used to manually control the APU coefficients. + In order to write to these files the module most be + loaded with manual_control=1 and the user must write "custom" + to the ACPI platform profile.drivers/platform/x86/amd/pmf/Makefile +1
-0@@ -7,4 +7,5 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ + manual.o \ tee-if.o spc.o pmf-quirks.odrivers/platform/x86/amd/pmf/core.c +9
-0@@ -53,6 +53,10 @@ static bool force_load;module_param (force_load, bool,0444 );MODULE_PARM_DESC (force_load,"Force load this driver on supported older platforms (experimental)" ); +bool pmf_manual_control; +module_param_named (manual_control, pmf_manual_control, bool,0444 ); +MODULE_PARM_DESC (manual_control,"Expose manual control knobs (experimental)" ); +static int amd_pmf_pwr_src_notify_call (struct notifier_block *nb,unsigned long event,void *data) { struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);@@ -349,6 +353,10 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)dev_dbg (dev->dev,"SPS enabled and Platform Profiles registered\n" ); } +if (pmf_manual_control) { +amd_pmf_init_manual_control (dev); +return ; + }amd_pmf_init_smart_pc (dev);if (dev->smart_pc_enabled) {dev_dbg (dev->dev,"Smart PC Solution Enabled\n" );@@ -485,6 +493,7 @@ static void amd_pmf_remove(struct platform_device *pdev)static const struct attribute_group *amd_pmf_driver_groups[] = { &cnqf_feature_attribute_group, + &manual_attribute_group,NULL , };drivers/platform/x86/amd/pmf/manual.c new file +88
-0@@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* AMD Platform Management Framework Driver +* +* Copyright (c) 2024, Advanced Micro Devices, Inc. +* All Rights Reserved. +* +* Author: Mario Limonciello <[email protected]> +*/ + +#include "pmf.h" + +#define pmf_manual_attribute (_name, _set_command, _get_command) \ +static ssize_t _name##_store(struct device *d, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + if (dev->current_profile != PLATFORM_PROFILE_CUSTOM) { \ + dev_warn_once(dev->dev, \ + "Manual control is disabled, please set " \ + "platform profile to custom.\n"); \ + return -EINVAL; \ + } \ + \ + if (kstrtouint(buf, 10, &val) < 0) \ + return -EINVAL; \ + \ + amd_pmf_send_cmd(dev, _set_command, false, val, NULL); \ + \ + return count; \ +} \ +static ssize_t _name##_show(struct device *d, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + amd_pmf_send_cmd(dev, _get_command, true, ARG_NONE, &val); \ + \ + return sysfs_emit(buf, "%u\n", val); \ +} + +pmf_manual_attribute (spl,SET_SPL ,GET_SPL ); +static DEVICE_ATTR_RW (spl); +pmf_manual_attribute (fppt,SET_FPPT ,GET_FPPT ); +static DEVICE_ATTR_RW (fppt); +pmf_manual_attribute (sppt,SET_SPPT ,GET_SPPT ); +static DEVICE_ATTR_RW (sppt); +pmf_manual_attribute (sppt_apu_only,SET_SPPT_APU_ONLY ,GET_SPPT_APU_ONLY ); +static DEVICE_ATTR_RW (sppt_apu_only); +pmf_manual_attribute (stt_min,SET_STT_MIN_LIMIT ,GET_STT_MIN_LIMIT ); +static DEVICE_ATTR_RW (stt_min); +pmf_manual_attribute (stt_limit_apu,SET_STT_LIMIT_APU ,GET_STT_LIMIT_APU ); +static DEVICE_ATTR_RW (stt_limit_apu); +pmf_manual_attribute (stt_skin_temp,SET_STT_LIMIT_HS2 ,GET_STT_LIMIT_HS2 ); +static DEVICE_ATTR_RW (stt_skin_temp); + +static umode_t manual_attr_is_visible (struct kobject *kobj,struct attribute *attr,int idx) +{ +return pmf_manual_control ?0660 :0 ; +} + +static struct attribute *manual_attrs[] = { + &dev_attr_spl.attr, + &dev_attr_fppt.attr, + &dev_attr_sppt.attr, + &dev_attr_sppt_apu_only.attr, + &dev_attr_stt_min.attr, + &dev_attr_stt_limit_apu.attr, + &dev_attr_stt_skin_temp.attr, +NULL , +}; + +const struct attribute_group manual_attribute_group = { + .attrs = manual_attrs, + .is_visible = manual_attr_is_visible, +}; + +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev) +{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}drivers/platform/x86/amd/pmf/pmf.h +5
-0@@ -798,4 +798,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table */* Quirk infrastructure */ void amd_pmf_quirks_init (struct amd_pmf_dev *dev); +/* Manual configuration */ +extern bool pmf_manual_control; +extern const struct attribute_group manual_attribute_group; +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev); +#endif /* PMF_H */ drivers/platform/x86/amd/pmf/sps.c +4
-1@@ -305,6 +305,8 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)case PLATFORM_PROFILE_LOW_POWER : mode =POWER_MODE_POWER_SAVER ;break ; +case PLATFORM_PROFILE_CUSTOM : +return 0 ;default :dev_err (pmf->dev,"Unknown Platform Profile.\n" );return -EOPNOTSUPP ;@@ -412,6 +414,8 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)set_bit (PLATFORM_PROFILE_LOW_POWER , dev->pprof.choices);set_bit (PLATFORM_PROFILE_BALANCED , dev->pprof.choices);set_bit (PLATFORM_PROFILE_PERFORMANCE , dev->pprof.choices); +if (pmf_manual_control) +set_bit (PLATFORM_PROFILE_CUSTOM , dev->pprof.choices);/* Create platform_profile structure and register */ err =platform_profile_register (&dev->pprof); --2.43.0
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?
I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
Quoted 225 lines
Antheas
Quoted 221 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
A number of users resort to using reverse engineered software like ryzenadj to manipulate debugging interfaces for modifying APU settings.
At a glance these tools are useful, but the problem is they break state machines in other software such as the PMF driver or the OEM EC.
Offer a knob for PMF to allow 'manual control' which will users can directly change things like fPPT and sPPT. As this can be harmful for a system to try to push limits outside of a thermal design, taint the kernel and show a critical message when in use.
Signed-off-by Mario Limonciello <[email protected]>--- Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 +++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 ++ 6 files changed, 117 insertions(+)create mode 100644
drivers/platform/x86/amd/pmf/manual.cDocumentation/ABI/testing/sysfs-amd-pmf +10
-0@@ -11,3 +11,13 @@ Description: Reading this file tells if the AMD Platform Management(PMF) To turn off CnQF user can write "off" to the sysfs node. Note: Systems that support auto mode will not have this sysfs file available. + +What: /sys/devices/platform/*/{spl, fppt, sppt, sppt_apu_only, stt_min, stt_limit_apu, stt_skip_temp} +Date: December 2024 +Contact: Mario Limonciello <[email protected]> +Description: Manual control of AMD PMF APU coefficients + . + These files are used to manually control the APU coefficients. + In order to write to these files the module most be + loaded with manual_control=1 and the user must write "custom" + to the ACPI platform profile.drivers/platform/x86/amd/pmf/Makefile +1
-0@@ -7,4 +7,5 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ + manual.o \ tee-if.o spc.o pmf-quirks.odrivers/platform/x86/amd/pmf/core.c +9
-0@@ -53,6 +53,10 @@ static bool force_load;module_param (force_load, bool,0444 );MODULE_PARM_DESC (force_load,"Force load this driver on supported older platforms (experimental)" ); +bool pmf_manual_control; +module_param_named (manual_control, pmf_manual_control, bool,0444 ); +MODULE_PARM_DESC (manual_control,"Expose manual control knobs (experimental)" ); +static int amd_pmf_pwr_src_notify_call (struct notifier_block *nb,unsigned long event,void *data) { struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);@@ -349,6 +353,10 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)dev_dbg (dev->dev,"SPS enabled and Platform Profiles registered\n" ); } +if (pmf_manual_control) { +amd_pmf_init_manual_control (dev); +return ; + }amd_pmf_init_smart_pc (dev);if (dev->smart_pc_enabled) {dev_dbg (dev->dev,"Smart PC Solution Enabled\n" );@@ -485,6 +493,7 @@ static void amd_pmf_remove(struct platform_device *pdev)static const struct attribute_group *amd_pmf_driver_groups[] = { &cnqf_feature_attribute_group, + &manual_attribute_group,NULL , };drivers/platform/x86/amd/pmf/manual.c new file +88
-0@@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* AMD Platform Management Framework Driver +* +* Copyright (c) 2024, Advanced Micro Devices, Inc. +* All Rights Reserved. +* +* Author: Mario Limonciello <[email protected]> +*/ + +#include "pmf.h" + +#define pmf_manual_attribute (_name, _set_command, _get_command) \ +static ssize_t _name##_store(struct device *d, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + if (dev->current_profile != PLATFORM_PROFILE_CUSTOM) { \ + dev_warn_once(dev->dev, \ + "Manual control is disabled, please set " \ + "platform profile to custom.\n"); \ + return -EINVAL; \ + } \ + \ + if (kstrtouint(buf, 10, &val) < 0) \ + return -EINVAL; \ + \ + amd_pmf_send_cmd(dev, _set_command, false, val, NULL); \ + \ + return count; \ +} \ +static ssize_t _name##_show(struct device *d, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + amd_pmf_send_cmd(dev, _get_command, true, ARG_NONE, &val); \ + \ + return sysfs_emit(buf, "%u\n", val); \ +} + +pmf_manual_attribute (spl,SET_SPL ,GET_SPL ); +static DEVICE_ATTR_RW (spl); +pmf_manual_attribute (fppt,SET_FPPT ,GET_FPPT ); +static DEVICE_ATTR_RW (fppt); +pmf_manual_attribute (sppt,SET_SPPT ,GET_SPPT ); +static DEVICE_ATTR_RW (sppt); +pmf_manual_attribute (sppt_apu_only,SET_SPPT_APU_ONLY ,GET_SPPT_APU_ONLY ); +static DEVICE_ATTR_RW (sppt_apu_only); +pmf_manual_attribute (stt_min,SET_STT_MIN_LIMIT ,GET_STT_MIN_LIMIT ); +static DEVICE_ATTR_RW (stt_min); +pmf_manual_attribute (stt_limit_apu,SET_STT_LIMIT_APU ,GET_STT_LIMIT_APU ); +static DEVICE_ATTR_RW (stt_limit_apu); +pmf_manual_attribute (stt_skin_temp,SET_STT_LIMIT_HS2 ,GET_STT_LIMIT_HS2 ); +static DEVICE_ATTR_RW (stt_skin_temp); + +static umode_t manual_attr_is_visible (struct kobject *kobj,struct attribute *attr,int idx) +{ +return pmf_manual_control ?0660 :0 ; +} + +static struct attribute *manual_attrs[] = { + &dev_attr_spl.attr, + &dev_attr_fppt.attr, + &dev_attr_sppt.attr, + &dev_attr_sppt_apu_only.attr, + &dev_attr_stt_min.attr, + &dev_attr_stt_limit_apu.attr, + &dev_attr_stt_skin_temp.attr, +NULL , +}; + +const struct attribute_group manual_attribute_group = { + .attrs = manual_attrs, + .is_visible = manual_attr_is_visible, +}; + +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev) +{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}drivers/platform/x86/amd/pmf/pmf.h +5
-0@@ -798,4 +798,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table */* Quirk infrastructure */ void amd_pmf_quirks_init (struct amd_pmf_dev *dev); +/* Manual configuration */ +extern bool pmf_manual_control; +extern const struct attribute_group manual_attribute_group; +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev); +#endif /* PMF_H */ drivers/platform/x86/amd/pmf/sps.c +4
-1@@ -305,6 +305,8 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)case PLATFORM_PROFILE_LOW_POWER : mode =POWER_MODE_POWER_SAVER ;break ; +case PLATFORM_PROFILE_CUSTOM : +return 0 ;default :dev_err (pmf->dev,"Unknown Platform Profile.\n" );return -EOPNOTSUPP ;@@ -412,6 +414,8 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)set_bit (PLATFORM_PROFILE_LOW_POWER , dev->pprof.choices);set_bit (PLATFORM_PROFILE_BALANCED , dev->pprof.choices);set_bit (PLATFORM_PROFILE_PERFORMANCE , dev->pprof.choices); +if (pmf_manual_control) +set_bit (PLATFORM_PROFILE_CUSTOM , dev->pprof.choices);/* Create platform_profile structure and register */ err =platform_profile_register (&dev->pprof); --2.43.0
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.
Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
Antheas
Quoted 226 lines
Quoted 225 lines
Antheas
Quoted 221 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
A number of users resort to using reverse engineered software like ryzenadj to manipulate debugging interfaces for modifying APU settings.
At a glance these tools are useful, but the problem is they break state machines in other software such as the PMF driver or the OEM EC.
Offer a knob for PMF to allow 'manual control' which will users can directly change things like fPPT and sPPT. As this can be harmful for a system to try to push limits outside of a thermal design, taint the kernel and show a critical message when in use.
Signed-off-by Mario Limonciello <[email protected]>--- Documentation/ABI/testing/sysfs-amd-pmf | 10 +++ drivers/platform/x86/amd/pmf/Makefile | 1 + drivers/platform/x86/amd/pmf/core.c | 9 +++ drivers/platform/x86/amd/pmf/manual.c | 88 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 5 ++ drivers/platform/x86/amd/pmf/sps.c | 4 ++ 6 files changed, 117 insertions(+)create mode 100644
drivers/platform/x86/amd/pmf/manual.cDocumentation/ABI/testing/sysfs-amd-pmf +10
-0@@ -11,3 +11,13 @@ Description: Reading this file tells if the AMD Platform Management(PMF) To turn off CnQF user can write "off" to the sysfs node. Note: Systems that support auto mode will not have this sysfs file available. + +What: /sys/devices/platform/*/{spl, fppt, sppt, sppt_apu_only, stt_min, stt_limit_apu, stt_skip_temp} +Date: December 2024 +Contact: Mario Limonciello <[email protected]> +Description: Manual control of AMD PMF APU coefficients + . + These files are used to manually control the APU coefficients. + In order to write to these files the module most be + loaded with manual_control=1 and the user must write "custom" + to the ACPI platform profile.drivers/platform/x86/amd/pmf/Makefile +1
-0@@ -7,4 +7,5 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ + manual.o \ tee-if.o spc.o pmf-quirks.odrivers/platform/x86/amd/pmf/core.c +9
-0@@ -53,6 +53,10 @@ static bool force_load;module_param (force_load, bool,0444 );MODULE_PARM_DESC (force_load,"Force load this driver on supported older platforms (experimental)" ); +bool pmf_manual_control; +module_param_named (manual_control, pmf_manual_control, bool,0444 ); +MODULE_PARM_DESC (manual_control,"Expose manual control knobs (experimental)" ); +static int amd_pmf_pwr_src_notify_call (struct notifier_block *nb,unsigned long event,void *data) { struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);@@ -349,6 +353,10 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)dev_dbg (dev->dev,"SPS enabled and Platform Profiles registered\n" ); } +if (pmf_manual_control) { +amd_pmf_init_manual_control (dev); +return ; + }amd_pmf_init_smart_pc (dev);if (dev->smart_pc_enabled) {dev_dbg (dev->dev,"Smart PC Solution Enabled\n" );@@ -485,6 +493,7 @@ static void amd_pmf_remove(struct platform_device *pdev)static const struct attribute_group *amd_pmf_driver_groups[] = { &cnqf_feature_attribute_group, + &manual_attribute_group,NULL , };drivers/platform/x86/amd/pmf/manual.c new file +88
-0@@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* AMD Platform Management Framework Driver +* +* Copyright (c) 2024, Advanced Micro Devices, Inc. +* All Rights Reserved. +* +* Author: Mario Limonciello <[email protected]> +*/ + +#include "pmf.h" + +#define pmf_manual_attribute (_name, _set_command, _get_command) \ +static ssize_t _name##_store(struct device *d, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + if (dev->current_profile != PLATFORM_PROFILE_CUSTOM) { \ + dev_warn_once(dev->dev, \ + "Manual control is disabled, please set " \ + "platform profile to custom.\n"); \ + return -EINVAL; \ + } \ + \ + if (kstrtouint(buf, 10, &val) < 0) \ + return -EINVAL; \ + \ + amd_pmf_send_cmd(dev, _set_command, false, val, NULL); \ + \ + return count; \ +} \ +static ssize_t _name##_show(struct device *d, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct amd_pmf_dev *dev = dev_get_drvdata(d); \ + uint val; \ + \ + amd_pmf_send_cmd(dev, _get_command, true, ARG_NONE, &val); \ + \ + return sysfs_emit(buf, "%u\n", val); \ +} + +pmf_manual_attribute (spl,SET_SPL ,GET_SPL ); +static DEVICE_ATTR_RW (spl); +pmf_manual_attribute (fppt,SET_FPPT ,GET_FPPT ); +static DEVICE_ATTR_RW (fppt); +pmf_manual_attribute (sppt,SET_SPPT ,GET_SPPT ); +static DEVICE_ATTR_RW (sppt); +pmf_manual_attribute (sppt_apu_only,SET_SPPT_APU_ONLY ,GET_SPPT_APU_ONLY ); +static DEVICE_ATTR_RW (sppt_apu_only); +pmf_manual_attribute (stt_min,SET_STT_MIN_LIMIT ,GET_STT_MIN_LIMIT ); +static DEVICE_ATTR_RW (stt_min); +pmf_manual_attribute (stt_limit_apu,SET_STT_LIMIT_APU ,GET_STT_LIMIT_APU ); +static DEVICE_ATTR_RW (stt_limit_apu); +pmf_manual_attribute (stt_skin_temp,SET_STT_LIMIT_HS2 ,GET_STT_LIMIT_HS2 ); +static DEVICE_ATTR_RW (stt_skin_temp); + +static umode_t manual_attr_is_visible (struct kobject *kobj,struct attribute *attr,int idx) +{ +return pmf_manual_control ?0660 :0 ; +} + +static struct attribute *manual_attrs[] = { + &dev_attr_spl.attr, + &dev_attr_fppt.attr, + &dev_attr_sppt.attr, + &dev_attr_sppt_apu_only.attr, + &dev_attr_stt_min.attr, + &dev_attr_stt_limit_apu.attr, + &dev_attr_stt_skin_temp.attr, +NULL , +}; + +const struct attribute_group manual_attribute_group = { + .attrs = manual_attrs, + .is_visible = manual_attr_is_visible, +}; + +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev) +{ +add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); +pr_crit ("Manual PMF control is enabled, please disable it before " +"reporting any bugs unrelated to PMF.\n" ); +}drivers/platform/x86/amd/pmf/pmf.h +5
-0@@ -798,4 +798,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table */* Quirk infrastructure */ void amd_pmf_quirks_init (struct amd_pmf_dev *dev); +/* Manual configuration */ +extern bool pmf_manual_control; +extern const struct attribute_group manual_attribute_group; +void amd_pmf_init_manual_control (struct amd_pmf_dev *dev); +#endif /* PMF_H */ drivers/platform/x86/amd/pmf/sps.c +4
-1@@ -305,6 +305,8 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)case PLATFORM_PROFILE_LOW_POWER : mode =POWER_MODE_POWER_SAVER ;break ; +case PLATFORM_PROFILE_CUSTOM : +return 0 ;default :dev_err (pmf->dev,"Unknown Platform Profile.\n" );return -EOPNOTSUPP ;@@ -412,6 +414,8 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)set_bit (PLATFORM_PROFILE_LOW_POWER , dev->pprof.choices);set_bit (PLATFORM_PROFILE_BALANCED , dev->pprof.choices);set_bit (PLATFORM_PROFILE_PERFORMANCE , dev->pprof.choices); +if (pmf_manual_control) +set_bit (PLATFORM_PROFILE_CUSTOM , dev->pprof.choices);/* Create platform_profile structure and register */ err =platform_profile_register (&dev->pprof); --2.43.0
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 55 lines · Antheas Kapenekakis
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
Quoted 8 lines
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
I've got a fundamental question - why the fixation on PPT?
This just sets "limits" for the package. In Windows it's probably the best knob to tune to adjust performance in an effort to extend battery life, but in Linux we have a lot of other knobs:
* the ability to tune EPP (energy_performance_preference)
* set min and max CPU frequencies (scaling_min_freq, scaling_max_freq)
* offline cores at will
* change DPM setting in the GPU driver (power_dpm_force_performance_level)
All the core related knobs can be changed on a per-core basis. So for example even on a non-heterogeneous design you could potentially make it perform "like" a hetero design where you set it so that some cores don't go above nominal frequency or the EPP value is tuned less aggressively on some cores.
These knobs can have just as drastic of a result on battery life as adjusting the various power limiting knobs. Most importantly these knobs have architectural limits that you won't be able to override so you can safely change them to min/max and see what happens.
I feel like specifically if you keep EPP at balance_performance, keep scaling_min_freq at lowest non linear frequency and change scaling_max_freq on a few of the cores you should be able to influence the battery life quite a bit while still keeping the system responsive.
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 66 lines · Mario Limonciello
Quoted 55 lines · Antheas Kapenekakis
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
Quoted 8 lines
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
Quoted 8 lines
I've got a fundamental question - why the fixation on PPT?
This just sets "limits" for the package. In Windows it's probably the best knob to tune to adjust performance in an effort to extend battery life, but in Linux we have a lot of other knobs:
* the ability to tune EPP (
energy_performance_preference)
* set min and max CPU frequencies (scaling_min_freq,scaling_max_freq)
We use both of these.
Quoted 1 line
* offline cores at will
if a core is parked and you try to write into its sysfs entrypoints, we found that this might cause a userspace program to hang indefinitely. Since a lot of settings are per core that's problematic and since it does not help much most TDP programs dont offer it anymore.
Quoted 1 line
* change DPM setting in the GPU driver (
power_dpm_force_performance_level)
I think we played with this mostly to try to get lower than 800mhz. However, going lower than 800mhz in these APUs causes issues.
Quoted 10 lines
All the core related knobs can be changed on a per-core basis. So for example even on a non-heterogeneous design you could potentially make it perform "like" a hetero design where you set it so that some cores don't go above nominal frequency or the EPP value is tuned less aggressively on some cores.
These knobs can have just as drastic of a result on battery life as adjusting the various power limiting knobs. Most importantly these knobs have architectural limits that you won't be able to override so you can safely change them to min/max and see what happens.
I feel like we are discussing different targets here. When it comes to computing tasks, you have a certain block of work that needs to be done and after that the CPU is free. In this case, programs like tuned (allegedly) optimize these settings so that they take the minimum amount of power to complete that block of work.
However, games are different. Games have no problem burning power if you let them and they are also playable at a variety of power levels. Typically, unless the user caps the framerate and video quality of the game it will use the full slow temp limit value. Even if they do set that, the game will typically burn 3-4W more than what is needed depending on TDP, EPP etc.
Therefore, the question we ask users is how loud do you want your device to be and how long (in hours) do you want the battery to last. This is done by ppt + the other settings, which are set automatically based on ppt.
Then the users can compromise with what fidelity and fps they get based on their TDP.
Quoted 4 lines
I feel like specifically if you keep EPP at
balance_performance, keepscaling_min_freqat lowest non linear frequency and changescaling_max_freqon a few of the cores you should be able to influence the battery life quite a bit while still keeping the system responsive.
The sweet spot on these APUs is max freq to be nominal (i.e., no boost), EPP at balance_power or power for very low tdps, and min_freq to be 0. Especially for min_freq, setting it to lowest non-linear seems to have no effect.
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 78 lines · Antheas Kapenekakis
Quoted 66 lines · Mario Limonciello
Quoted 55 lines · Antheas Kapenekakis
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
Quoted 8 lines
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
Quoted 8 lines
I've got a fundamental question - why the fixation on PPT?
This just sets "limits" for the package. In Windows it's probably the best knob to tune to adjust performance in an effort to extend battery life, but in Linux we have a lot of other knobs:
* the ability to tune EPP (
energy_performance_preference)
* set min and max CPU frequencies (scaling_min_freq,scaling_max_freq)We use both of these.
Quoted 7 lines
Quoted 1 line
* offline cores at will
if a core is parked and you try to write into its sysfs entrypoints, we found that this might cause a userspace program to hang indefinitely. Since a lot of settings are per core that's problematic and since it does not help much most TDP programs dont offer it anymore.
This sounds like a kernel bug if you're hanging programs when trying to write to sysfs files of offlined cores. If we can get that fixed having that in your toolbelt is quite useful. I'm sure there are plenty of games that don't really need all the cores up and you can save some power.
Can you get a simple reproducer for me into a bug report to look at next year?
Quoted 23 lines
Quoted 2 lines
* change DPM setting in the GPU driver (
power_dpm_force_performance_level)I think we played with this mostly to try to get lower than 800mhz. However, going lower than 800mhz in these APUs causes issues.
Quoted 10 lines
All the core related knobs can be changed on a per-core basis. So for example even on a non-heterogeneous design you could potentially make it perform "like" a hetero design where you set it so that some cores don't go above nominal frequency or the EPP value is tuned less aggressively on some cores.
These knobs can have just as drastic of a result on battery life as adjusting the various power limiting knobs. Most importantly these knobs have architectural limits that you won't be able to override so you can safely change them to min/max and see what happens.
I feel like we are discussing different targets here. When it comes to computing tasks, you have a certain block of work that needs to be done and after that the CPU is free. In this case, programs like tuned (allegedly) optimize these settings so that they take the minimum amount of power to complete that block of work.
Quoted 6 lines
However, games are different. Games have no problem burning power if you let them and they are also playable at a variety of power levels. Typically, unless the user caps the framerate and video quality of the game it will use the full slow temp limit value. Even if they do set that, the game will typically burn 3-4W more than what is needed depending on TDP, EPP etc.
Part of what I'm wondering is if our 4 levels of EPP values "aren't enough" for optimization on a per game basis.
IMO They're incredibly rigid. I do have a patch that can expose "raw" numbers for amd-pstate like intel-pstate does, but I haven't brought it on the lists yet because I'm still discussing it with others internal to AMD.
EPP is really about responsiveness in games.
Quoted 14 lines
Therefore, the question we ask users is how loud do you want your device to be and how long (in hours) do you want the battery to last. This is done by ppt + the other settings, which are set automatically based on ppt.
Then the users can compromise with what fidelity and fps they get based on their TDP.
Quoted 4 lines
I feel like specifically if you keep EPP at
balance_performance, keepscaling_min_freqat lowest non linear frequency and changescaling_max_freqon a few of the cores you should be able to influence the battery life quite a bit while still keeping the system responsive.
Quoted 4 lines
The sweet spot on these APUs is max freq to be nominal (i.e., no boost), EPP at
balance_poweror power for very low tdps, andmin_freqto be 0. Especially formin_freq, setting it to lowest non-linear seems to have no effect.
Min freq can't go to 0, but maybe you mean the unitless perf value of 0, right?
There is a pretty big current swing you'll have going from perf 0 vs the swing you get from lowest nonlinear perf. It might not be visually noticeable, but I think it would be good to characterize how many joules are used for a given predictable gaming "workload" to decide what to do.
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 88 lines · Mario Limonciello
Quoted 78 lines · Antheas Kapenekakis
Quoted 66 lines · Mario Limonciello
Quoted 55 lines · Antheas Kapenekakis
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
Quoted 8 lines
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
Quoted 8 lines
I've got a fundamental question - why the fixation on PPT?
This just sets "limits" for the package. In Windows it's probably the best knob to tune to adjust performance in an effort to extend battery life, but in Linux we have a lot of other knobs:
* the ability to tune EPP (
energy_performance_preference)
* set min and max CPU frequencies (scaling_min_freq,scaling_max_freq)We use both of these.
Quoted 7 lines
Quoted 1 line
* offline cores at will
if a core is parked and you try to write into its sysfs entrypoints, we found that this might cause a userspace program to hang indefinitely. Since a lot of settings are per core that's problematic and since it does not help much most TDP programs dont offer it anymore.
Quoted 7 lines
This sounds like a kernel bug if you're hanging programs when trying to write to sysfs files of offlined cores. If we can get that fixed having that in your toolbelt is quite useful. I'm sure there are plenty of games that don't really need all the cores up and you can save some power.
Can you get a simple reproducer for me into a bug report to look at next year?
I will try to. This was relayed to me. Disabling SMT also causes a crash on the Ally when going to sleep.
Quoted 33 lines
Quoted 23 lines
Quoted 2 lines
* change DPM setting in the GPU driver (
power_dpm_force_performance_level)I think we played with this mostly to try to get lower than 800mhz. However, going lower than 800mhz in these APUs causes issues.
Quoted 10 lines
All the core related knobs can be changed on a per-core basis. So for example even on a non-heterogeneous design you could potentially make it perform "like" a hetero design where you set it so that some cores don't go above nominal frequency or the EPP value is tuned less aggressively on some cores.
These knobs can have just as drastic of a result on battery life as adjusting the various power limiting knobs. Most importantly these knobs have architectural limits that you won't be able to override so you can safely change them to min/max and see what happens.
I feel like we are discussing different targets here. When it comes to computing tasks, you have a certain block of work that needs to be done and after that the CPU is free. In this case, programs like tuned (allegedly) optimize these settings so that they take the minimum amount of power to complete that block of work.
Quoted 6 lines
However, games are different. Games have no problem burning power if you let them and they are also playable at a variety of power levels. Typically, unless the user caps the framerate and video quality of the game it will use the full slow temp limit value. Even if they do set that, the game will typically burn 3-4W more than what is needed depending on TDP, EPP etc.
Part of what I'm wondering is if our 4 levels of EPP values "aren't enough" for optimization on a per game basis.
Quoted 6 lines
IMO They're incredibly rigid. I do have a patch that can expose "raw" numbers for amd-pstate like intel-pstate does, but I haven't brought it on the lists yet because I'm still discussing it with others internal to AMD.
EPP is really about responsiveness in games.
EPP performance is so detrimental we hide it. It destroys performance by sucking power from the GPU. EPP balance_performance is only useful in certain emulators that need a lot of CPU. Only balance_power is useful. Then, for TDPs lower than 10, setting EPP to power milks another 1-2W
Quoted 19 lines
Quoted 14 lines
Therefore, the question we ask users is how loud do you want your device to be and how long (in hours) do you want the battery to last. This is done by ppt + the other settings, which are set automatically based on ppt.
Then the users can compromise with what fidelity and fps they get based on their TDP.
Quoted 4 lines
I feel like specifically if you keep EPP at
balance_performance, keepscaling_min_freqat lowest non linear frequency and changescaling_max_freqon a few of the cores you should be able to influence the battery life quite a bit while still keeping the system responsive.Quoted 4 lines
The sweet spot on these APUs is max freq to be nominal (i.e., no boost), EPP at
balance_poweror power for very low tdps, andmin_freqto be 0. Especially formin_freq, setting it to lowest non-linear seems to have no effect.
Quoted 7 lines
Min freq can't go to 0, but maybe you mean the unitless perf value of 0, right?
There is a pretty big current swing you'll have going from perf 0 vs the swing you get from lowest nonlinear perf. It might not be visually noticeable, but I think it would be good to characterize how many joules are used for a given predictable gaming "workload" to decide what to do.
I set min_freq for the CPUs to the minimum one which maybe you are right it is 400mhz. When it comes to games, 1.4GHz (nonlinear) vs 400mhz does not make much of a difference.
Antheas
Re: [RFC 2/2] platform/x86/amd: pmf: Add manual control support
Quoted 94 lines · Antheas Kapenekakis
Quoted 93 lines · Mario Limonciello
Quoted 78 lines · Antheas Kapenekakis
Quoted 66 lines · Mario Limonciello
Quoted 55 lines · Antheas Kapenekakis
Quoted 11 lines · Mario Limonciello
Quoted 8 lines · Antheas Kapenekakis
Hi Mario,
given that there is a Legion Go driver in the works, and Asus already has a driver, the only thing that would be left for locking down ACPI access is manufacturers w/o vendor APIs.So, can we restart the conversation about this driver? It would be nice to get to a place where we can lock down
/dev/memand ACPI by spring.Quoted 5 lines
As Shyam mentioned we don't have control for limits by the PMF driver for this on PMF v2 (Strix) or later platforms.
So if we were to revive this custom discussion it would only be for Phoenix and Hawk Point platforms.
That's unfortunate.
Quoted 10 lines
Quoted 3 lines
Moreover, since the other two proposed drivers use the
firmware_attributesAPI, should this be used here as well?I do feel that if we revive this conversation specifically for Phoenix and Hawk Point platforms yes we should use the same API to expose it to userspace as those other two drivers do.
I'd like Shyam's temperature on this idea though before anyone spends time on it. If he's amenable would you want to work on it?
We currently expect the 2025 lineup to include a lot of Strix Point handhelds, so I'd like a solution that works with that. OneXPlayer released a model already, and GPD is getting ready to ship as well.
Yeah, I could throw some hours to it after I go through some overdue stuff.
Quoted 10 lines
Quoted 6 lines
By the way, you were right about needing a taint for this. Strix Point fails to enter a lower power state during sleep if you set it to lower than 10W. This is not ideal, as hawk point could go down to 5 while still showing a power difference, but I am unsure where this bug should be reported. This is both through ryzenadj/ALIB
Who is to say this is a bug? Abusing a debugging interface with a reverse engineered tool means you might be able to configure a platform out of specifications.
The spec being 10+W would be very undesirable for handhelds with Strix Point, so I'd hope somebody looks into it, esp. if it can be fixed with a BIOS fw update before more handhelds come out. I can raise the minimum TDP to 10W, with some user complaints.
Asus and Lenovo use the same mailbox so they'd share the issue too.
Quoted 8 lines
FYI for a typical handheld with e.g., a 60Wh battery, a 10W envelope results in around 20-22W total consumption which is around 2.5 hours. Hawk Point can be TDP limited down to 16W total consumption (TDP ~7W) and can go down to 8W with frame limiting etc. I do not have numbers for Strix Point yet, but to match Hawk Point it has to allow TDP to go down to 7W. I think for 2025, customer expectation will be 6-8 hours+ at low wattages.
Quoted 8 lines
I've got a fundamental question - why the fixation on PPT?
This just sets "limits" for the package. In Windows it's probably the best knob to tune to adjust performance in an effort to extend battery life, but in Linux we have a lot of other knobs:
* the ability to tune EPP (
energy_performance_preference)
* set min and max CPU frequencies (scaling_min_freq,scaling_max_freq)We use both of these.
Quoted 7 lines
Quoted 1 line
* offline cores at will
if a core is parked and you try to write into its sysfs entrypoints, we found that this might cause a userspace program to hang indefinitely. Since a lot of settings are per core that's problematic and since it does not help much most TDP programs dont offer it anymore.
This sounds like a kernel bug if you're hanging programs when trying to write to sysfs files of offlined cores. If we can get that fixed having that in your toolbelt is quite useful. I'm sure there are plenty of games that don't really need all the cores up and you can save some power.
Quoted 4 lines
Quoted 2 lines
Can you get a simple reproducer for me into a bug report to look at next year?
I will try to. This was relayed to me.
Thanks! If whoever relayed it to you opens the bug report that's totally fine with me too. Just ping me after the new year if I miss it because it will be lost in a giant pile of other stuff.
Quoted 2 lines
Disabling SMT also causes a
crash on the Ally when going to sleep.
Yes; SMT is require to be enabled for s0i3 to work.
That's why the s2idle debugging script flags it.
https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py#L1207
Quoted 39 lines
Quoted 39 lines
Quoted 24 lines
Quoted 3 lines
* change DPM setting in the GPU driver (
power_dpm_force_performance_level)I think we played with this mostly to try to get lower than 800mhz. However, going lower than 800mhz in these APUs causes issues.
Quoted 10 lines
All the core related knobs can be changed on a per-core basis. So for example even on a non-heterogeneous design you could potentially make it perform "like" a hetero design where you set it so that some cores don't go above nominal frequency or the EPP value is tuned less aggressively on some cores.
These knobs can have just as drastic of a result on battery life as adjusting the various power limiting knobs. Most importantly these knobs have architectural limits that you won't be able to override so you can safely change them to min/max and see what happens.
I feel like we are discussing different targets here. When it comes to computing tasks, you have a certain block of work that needs to be done and after that the CPU is free. In this case, programs like tuned (allegedly) optimize these settings so that they take the minimum amount of power to complete that block of work.
Quoted 6 lines
However, games are different. Games have no problem burning power if you let them and they are also playable at a variety of power levels. Typically, unless the user caps the framerate and video quality of the game it will use the full slow temp limit value. Even if they do set that, the game will typically burn 3-4W more than what is needed depending on TDP, EPP etc.
Part of what I'm wondering is if our 4 levels of EPP values "aren't enough" for optimization on a per game basis.
IMO They're incredibly rigid. I do have a patch that can expose "raw" numbers for amd-pstate like intel-pstate does, but I haven't brought it on the lists yet because I'm still discussing it with others internal to AMD.
Quoted 7 lines
Quoted 1 line
EPP is really about responsiveness in games.
EPP performance is so detrimental we hide it. It destroys performance by sucking power from the GPU. EPP
balance_performanceis only useful in certain emulators that need a lot of CPU. Onlybalance_poweris useful. Then, for TDPs lower than 10, setting EPP to power milks another 1-2W
Yes; this is a different conversation once you're talking about the power share between CPU cores and GPU. It's part of why I was talking about core parking when you don't need all the cores.
Hi Mario,
Indeed, the proposal looks good but has a few rough edges that would make it unsuitable to use currently. Well, for the handheld use-case at least.
This relates to issues of auto-discovery and how the kernel taint is applied. For the kernel taint, see my comments on patch 2.
Quoted 6 lines
There are two major ways to tune platform performance in Linux:
* ACPI platform profile
* Manually tuning APU performanceChanging the ACPI platform profile is a "one stop shop" to change performance limits and fan curves all at the same time.
For laptops. A majority of users of handhelds find 3 settings too limiting.
Quoted 2 lines
On AMD systems the manual tuning methods typically involve changing values of settings such as fPPT, sPPT or SPL.
Those names are amd-pmf specific and this proposal does not allow for auto-discovery.
Instead, expose attributes custom_mode and custom_mode_choices, that allow for querying the system for available custom modes and whether userspace can use them.
In this case, the modes for amd-pmf could be amd-pmf-spl and amd-pmf-user.
amd-pmf-spl could export the attrs {spl_min, spl_max, spl} and allow setting TDP using a slider a la Steam Deck. Here, manufacturers should be given complete control, e.g., with a LUT and the kernel should not taint.
amd-pmf-user would expose what is shown in this proposal and taint the kernel. Unfortunately, without manufacturer intervention, this would be the default for the foreseeable future for boutique devices (e.g., GPD, OneXPlayer, Ayaneo).
Quoted 9 lines
The problem with changing these settings manually is that the definition of the ACPI platform profile if supported by the hardware is no longer accurate. At best this can cause misrepresenting the state of the platform to userspace and at worst can cause the state machine into an invalid state.
The existence and continued development of projects such as ryzenadj which manipulate debugging interfaces show there is a demand for manually tuning performance.
-demand- -> requirement. Over 90% of handheld users will end up using a slider.
Quoted 5 lines
Furthermore some systems (such as ASUS and Lenovo handhelds) offer an ACPI-WMI interface for changing these settings. If using anything outside that WMI interface the state will be wrong. If using that WMI interface the platform profile will be wrong.
Quoted 7 lines
This series introduces a "custom" ACPI platform profile and adds support for the AMD PMF driver to use it when a user has enabled manual adjustments.
If agreeable a similar change should be made to asus-armoury and any other drivers that export the ability to change these settings but also a platform profile.
Indeed, it would be nice if such a change could be made for all manufacturer drivers. Much of this proposal would lower the need for something like asus-armoury, as asus-wmi would be fully capable of supporting this with few changes and around 70% of the asus-armoury attrs would then live under /sys/platform.
This also gives us the opportunity for a much needed rename of the variables.
I can speak with the out-of-tree Lenovo Legion Linux's maintainers and see if they would like to collaborate on this as well.
Antheas
For testing purposes, the important part would be implementing dummy attrs for custom_mode, and custom_mode_choices that both return amd-pmf-user or a name you find more agreeable. Otherwise I cannot implement an autodiscovery process.
If that change happens, we can begin testing as soon as the middle of next week.
It does not matter if that name is not final, as it can be aliased in the future.
Antheas
Thanks Mario,
Quoted 27 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
There are two major ways to tune platform performance in Linux:
* ACPI platform profile
* Manually tuning APU performanceChanging the ACPI platform profile is a "one stop shop" to change performance limits and fan curves all at the same time.
On AMD systems the manual tuning methods typically involve changing values of settings such as fPPT, sPPT or SPL.
The problem with changing these settings manually is that the definition of the ACPI platform profile if supported by the hardware is no longer accurate. At best this can cause misrepresenting the state of the platform to userspace and at worst can cause the state machine into an invalid state.
The existence and continued development of projects such as ryzenadj which manipulate debugging interfaces show there is a demand for manually tuning performance.
Furthermore some systems (such as ASUS and Lenovo handhelds) offer an ACPI-WMI interface for changing these settings. If using anything outside that WMI interface the state will be wrong. If using that WMI interface the platform profile will be wrong.
Quoted 8 lines
This series introduces a "custom" ACPI platform profile and adds support for the AMD PMF driver to use it when a user has enabled manual adjustments.
If agreeable a similar change should be made to asus-armoury and any other drivers that export the ability to change these settings but also a platform profile.
As someone who supports customers on Lenovo devices and hits the occasional situation where a user has made strange tweaks to different power related settings, and then complains about power or thermal issues - I love the idea that it can be made clear the system has been 'adjusted' in a non standard way. I can also see why users would want interfaces to do those changes.
Some suggestions:
I'm wondering if we can make it so a driver can register only a 'custom' profile as an extra profile handler?
The thinking here is the custom setting in this series is implemented for the amd sps driver, and therefore on a regular Lenovo laptop wouldn't be used, as the thinkpad_acpi driver will grab the profile slot, Users on Lenovo systems aren't going to be able to get at these extra tweaks (unless they unload thinkpad_acpi, which has other side effects).
If the sps driver can offer a custom mode, separately from thinkpad_acpi, then users can tweak settings to their hearts content but get back to regular mode when done.
I also think there needs to be a way that when you switch from custom back to a 'regular' profile that it would do a clean up of anything tweaked. e.g. when switching away from custom the ppd driver should call a 'custom mode cleanup' function, so things can be undone and returned to how they were when it was started.
Mark
Quoted 34 lines · Mark Pearson
Thanks Mario,
Quoted 31 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
There are two major ways to tune platform performance in Linux:
* ACPI platform profile
* Manually tuning APU performanceChanging the ACPI platform profile is a "one stop shop" to change performance limits and fan curves all at the same time.
On AMD systems the manual tuning methods typically involve changing values of settings such as fPPT, sPPT or SPL.
The problem with changing these settings manually is that the definition of the ACPI platform profile if supported by the hardware is no longer accurate. At best this can cause misrepresenting the state of the platform to userspace and at worst can cause the state machine into an invalid state.
The existence and continued development of projects such as ryzenadj which manipulate debugging interfaces show there is a demand for manually tuning performance.
Furthermore some systems (such as ASUS and Lenovo handhelds) offer an ACPI-WMI interface for changing these settings. If using anything outside that WMI interface the state will be wrong. If using that WMI interface the platform profile will be wrong.
This series introduces a "custom" ACPI platform profile and adds support for the AMD PMF driver to use it when a user has enabled manual adjustments.
Quoted 6 lines
Quoted 4 lines
If agreeable a similar change should be made to asus-armoury and any other drivers that export the ability to change these settings but also a platform profile.
As someone who supports customers on Lenovo devices and hits the occasional situation where a user has made strange tweaks to different power related settings, and then complains about power or thermal issues - I love the idea that it can be made clear the system has been 'adjusted' in a non standard way. I can also see why users would want interfaces to do those changes.
JFYI we're going to do something really similar in amdgpu when people have enabled overclocking. That's part of the inspiration for this RFC.
Quoted 6 lines
Some suggestions:
I'm wondering if we can make it so a driver can register only a 'custom' profile as an extra profile handler?
The thinking here is the custom setting in this series is implemented for the amd sps driver, and therefore on a regular Lenovo laptop wouldn't be used, as the
thinkpad_acpidriver will grab the profile slot, Users on Lenovo systems aren't going to be able to get at these extra tweaks (unless they unloadthinkpad_acpi, which has other side effects).
Well the RFC was just to show it for the AMD PMF driver, but I think that thinkpad_acpi, asus_armoury etc could all potentially implement the 'custom' bit too if they offer an ACPI-WMI interface to similar settings.
Quoted 6 lines
If the sps driver can offer a custom mode, separately from
thinkpad_acpi, then users can tweak settings to their hearts content but get back to regular mode when done.I also think there needs to be a way that when you switch from custom back to a 'regular' profile that it would do a clean up of anything tweaked. e.g. when switching away from custom the ppd driver should call a 'custom mode cleanup' function, so things can be undone and returned to how they were when it was started.
Mark
I guess what you're proposing is that multiple drivers register as profile handlers and they might not all export the same features.
If we did something like this we could instead have the core call callbacks for all platform profile handlers. We could also drop a pile of quirks from amd-pmf where there are some ASUS systems that advertise SPS in in the PMF framework and also asus-wmi provides it.
If I'm following you right, I generally like this idea.
Quoted 40 lines · Mario Limonciello
Quoted 39 lines · Mark Pearson
Thanks Mario,
Quoted 35 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
There are two major ways to tune platform performance in Linux:
* ACPI platform profile
* Manually tuning APU performanceChanging the ACPI platform profile is a "one stop shop" to change performance limits and fan curves all at the same time.
On AMD systems the manual tuning methods typically involve changing values of settings such as fPPT, sPPT or SPL.
The problem with changing these settings manually is that the definition of the ACPI platform profile if supported by the hardware is no longer accurate. At best this can cause misrepresenting the state of the platform to userspace and at worst can cause the state machine into an invalid state.
The existence and continued development of projects such as ryzenadj which manipulate debugging interfaces show there is a demand for manually tuning performance.
Furthermore some systems (such as ASUS and Lenovo handhelds) offer an ACPI-WMI interface for changing these settings. If using anything outside that WMI interface the state will be wrong. If using that WMI interface the platform profile will be wrong.
This series introduces a "custom" ACPI platform profile and adds support for the AMD PMF driver to use it when a user has enabled manual adjustments.
If agreeable a similar change should be made to asus-armoury and any other drivers that export the ability to change these settings but also a platform profile.
Quoted 7 lines
Quoted 1 line
As someone who supports customers on Lenovo devices and hits the occasional situation where a user has made strange tweaks to different power related settings, and then complains about power or thermal issues - I love the idea that it can be made clear the system has been 'adjusted' in a non standard way. I can also see why users would want interfaces to do those changes.
JFYI we're going to do something really similar in amdgpu when people have enabled overclocking. That's part of the inspiration for this RFC.
Nice :)
Quoted 21 lines
Quoted 6 lines
Some suggestions:
I'm wondering if we can make it so a driver can register only a 'custom' profile as an extra profile handler?
The thinking here is the custom setting in this series is implemented for the amd sps driver, and therefore on a regular Lenovo laptop wouldn't be used, as the
thinkpad_acpidriver will grab the profile slot, Users on Lenovo systems aren't going to be able to get at these extra tweaks (unless they unloadthinkpad_acpi, which has other side effects).Well the RFC was just to show it for the AMD PMF driver, but I think that
thinkpad_acpi,asus_armouryetc could all potentially implement the 'custom' bit too if they offer an ACPI-WMI interface to similar settings.Quoted 6 lines
If the sps driver can offer a custom mode, separately from
thinkpad_acpi, then users can tweak settings to their hearts content but get back to regular mode when done.I also think there needs to be a way that when you switch from custom back to a 'regular' profile that it would do a clean up of anything tweaked. e.g. when switching away from custom the ppd driver should call a 'custom mode cleanup' function, so things can be undone and returned to how they were when it was started.
Mark
I guess what you're proposing is that multiple drivers register as profile handlers and they might not all export the same features.
Quoted 6 lines
If we did something like this we could instead have the core call callbacks for all platform profile handlers. We could also drop a pile of quirks from amd-pmf where there are some ASUS systems that advertise SPS in in the PMF framework and also asus-wmi provides it.
If I'm following you right, I generally like this idea.
Yep - that was the idea.
This feels like a step towards giving more control to power users - whilst keeping the basic simple for regular folk.
I can imagine utilities that would use this to enable specific configurations, via the custom profile mode, for many different scenario's; whilst still allowing a user to get back to the tested and vendor approved setting if things go badly.
Mark
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Some suggestions:
I'm wondering if we can make it so a driver can register only a 'custom' profile as an extra profile handler?
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
The thinking here is the custom setting in this series is implemented for the amd sps driver, and therefore on a regular Lenovo laptop wouldn't be used, as the
thinkpad_acpidriver will grab the profile slot, Users on Lenovo systems aren't going to be able to get at these extra tweaks (unless they unloadthinkpad_acpi, which has other side effects).Well the RFC was just to show it for the AMD PMF driver, but I think that
thinkpad_acpi,asus_armouryetc could all potentially implement the 'custom' bit too if they offer an ACPI-WMI interface to similar settings.Quoted 2 lines
If the sps driver can offer a custom mode, separately from
thinkpad_acpi, then users can tweak settings to their hearts content but get back to regular mode when done.
I think I considered that as part of my userspace software and reached the conclusion that if there is an EC, for most users it is best to program it and forgo the extra features. Otherwise they get weird bugs and conflicts, such as incorrect fan curves or their settings being reset randomly.
On the Legion and Thinkpad series, the hardware binds would also cause this (Fn + BMH)/(Legion Go L + Y), and for Legion series specifically, the power button will have the wrong color.
So I do not know if it is worth exploring as having it controllable from userspace in such a clean way. Of course, tinkerers could mess around by disabling modules to try something out and that would work fine, but I do not think it will be usable day to day.
I personally gave up on the idea. However, having a load order and falling back to amd-pmf does have merit. E.g., the legion go will need a quirk for pmf too, and probably most laptop lines going forward. So that should be explored.
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines
I also think there needs to be a way that when you switch from custom back to a 'regular' profile that it would do a clean up of anything tweaked. e.g. when switching away from custom the ppd driver should call a 'custom mode cleanup' function, so things can be undone and returned to how they were when it was started.
Mark
I guess what you're proposing is that multiple drivers register as profile handlers and they might not all export the same features.
If we did something like this we could instead have the core call callbacks for all platform profile handlers. We could also drop a pile of quirks from amd-pmf where there are some ASUS systems that advertise SPS in in the PMF framework and also asus-wmi provides it.
Quoted 7 lines
Quoted 1 line
If I'm following you right, I generally like this idea.
Yep - that was the idea.
This feels like a step towards giving more control to power users - whilst keeping the basic simple for regular folk.
I can imagine utilities that would use this to enable specific configurations, via the custom profile mode, for many different scenario's; whilst still allowing a user to get back to the tested and vendor approved setting if things go badly.
I will note that for handhelds, having a TDP slider is basic functionality. So we need to find a way to give this control to users without tainting the kernel or requiring special workarounds in the case the manufacturer did not provide a WMI interface. This PR is a step in that direction, but then we need to deal with hardware limits and such to make sure it is safe.
As far as fPPT and sPPt go, I will be honest and say I never had a user ask for them. However, unless the driver implements a LUT or some basic logic to enable/disable some sort of boost, they will need to be exposed to sysfs so userspace can do it. It does not mean that userspace will need to show that to users, just that it will do the interpolation to apply the correct boost if that is requested.
Here I will note Legion Space did not do that on the Legion Go on WIndows for the first 5-6 months of its release. This lead to custom mode being completely broken from a user's perspective. Since the device is STT, if the user set the spl to 10W, well sPPT was 32W and fPPT was 43W so the device just kept boosting forever.
However, one of the first BIOS versions added sPPT and fPPT to WMI, so we never had that problem in Linux.
Now, Legion Space added sPPT and fPPT as sliders, which just causes annoyance for users, as they have to edit 3 sliders instead of one to get their desired performance level.
To that end, both Asus and Lenovo offer sPPT and fPPT adjustment, so there is no risk with exposing that to userspace in Linux specifically. As long as the limits are bounded.
Antheas