diff options
author | Wyes Karny <wyes.karny@amd.com> | 2023-06-19 22:05:02 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-07-19 01:06:56 +0300 |
commit | df8776b03689987e3239f3c010b6dc6ab4185d30 (patch) | |
tree | 1812288f1136c673c8a056140599441d1230b2a0 /tools/power/cpupower/utils/helpers/misc.c | |
parent | f2ab5557119a5ccd0ceaf7ecdca00ab782cd76c5 (diff) | |
download | linux-df8776b03689987e3239f3c010b6dc6ab4185d30.tar.xz |
cpupower: Add support for amd_pstate mode change
amd_pstate supports changing of its mode dynamically via `status` sysfs
file. Add the same capability in cpupower. To change the mode to active
mode use below command:
cpupower set --amd-pstate-mode active
Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Wyes Karny <wyes.karny@amd.com>
Tested-by: Perry Yuan <Perry.Yuan@amd.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/power/cpupower/utils/helpers/misc.c')
-rw-r--r-- | tools/power/cpupower/utils/helpers/misc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 583df38ab13c..075c136a100c 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -106,6 +106,24 @@ int cpupower_set_epp(unsigned int cpu, char *epp) return 0; } +int cpupower_set_amd_pstate_mode(char *mode) +{ + char path[SYSFS_PATH_MAX]; + char linebuf[20] = {}; + + snprintf(path, sizeof(path), PATH_TO_CPU "amd_pstate/status"); + + if (!is_valid_path(path)) + return -1; + + snprintf(linebuf, sizeof(linebuf), "%s\n", mode); + + if (cpupower_write_sysfs(path, linebuf, 20) <= 0) + return -1; + + return 0; +} + bool cpupower_amd_pstate_enabled(void) { char *driver = cpufreq_get_driver(0); |