aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power/cpupower/utils/helpers/misc.c
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2022-02-22 23:34:18 +0800
committerShuah Khan <skhan@linuxfoundation.org>2022-02-22 18:36:32 -0700
commit46c273a0958274f1e1e69f3540ae827a92e0660f (patch)
tree47dfc4b60693250f3330a02e402ed4882df21648 /tools/power/cpupower/utils/helpers/misc.c
parentcpupower: Add AMD P-State capability flag (diff)
downloadlinux-dev-46c273a0958274f1e1e69f3540ae827a92e0660f.tar.xz
linux-dev-46c273a0958274f1e1e69f3540ae827a92e0660f.zip
cpupower: Add the function to check AMD P-State enabled
The processor with AMD P-State function also supports legacy ACPI hardware P-States feature as well. Once driver sets AMD P-State eanbled, the processor will respond the finer grain AMD P-State feature instead of legacy ACPI P-States. So it introduces the cpupower_amd_pstate_enabled() to check whether the current kernel enables AMD P-State or AMD CPUFreq module. Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r--tools/power/cpupower/utils/helpers/misc.c18
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 fc6e34511721..0c483cdefcc2 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -3,9 +3,11 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include "helpers/helpers.h"
#include "helpers/sysfs.h"
+#include "cpufreq.h"
#if defined(__i386__) || defined(__x86_64__)
@@ -83,6 +85,22 @@ int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val)
return 0;
}
+bool cpupower_amd_pstate_enabled(void)
+{
+ char *driver = cpufreq_get_driver(0);
+ bool ret = false;
+
+ if (!driver)
+ return ret;
+
+ if (!strcmp(driver, "amd-pstate"))
+ ret = true;
+
+ cpufreq_put_driver(driver);
+
+ return ret;
+}
+
#endif /* #if defined(__i386__) || defined(__x86_64__) */
/* get_cpustate