Skip to content

Commit d8363e2

Browse files
huangruishuahkh
authored andcommitted
cpupower: Add function to print AMD P-State performance capabilities
AMD P-State kernel module is using the fine grain frequency instead of acpi hardware pstate. So add a function to print performance and frequency values. Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 35fdf42 commit d8363e2

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

tools/power/cpupower/utils/cpufreq-info.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ static int get_boost_mode_x86(unsigned int cpu)
146146
printf(_(" Supported: %s\n"), support ? _("yes") : _("no"));
147147
printf(_(" Active: %s\n"), active ? _("yes") : _("no"));
148148

149-
if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
150-
cpupower_cpu_info.family >= 0x10) ||
151-
cpupower_cpu_info.vendor == X86_VENDOR_HYGON) {
149+
if (cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
150+
cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE) {
151+
return 0;
152+
} else if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
153+
cpupower_cpu_info.family >= 0x10) ||
154+
cpupower_cpu_info.vendor == X86_VENDOR_HYGON) {
152155
ret = decode_pstates(cpu, b_states, pstates, &pstate_no);
153156
if (ret)
154157
return ret;

tools/power/cpupower/utils/helpers/amd.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,34 @@ void amd_pstate_boost_init(unsigned int cpu, int *support, int *active)
193193
*active = cpuinfo_max == amd_pstate_max ? 1 : 0;
194194
}
195195

196+
void amd_pstate_show_perf_and_freq(unsigned int cpu, int no_rounding)
197+
{
198+
printf(_(" AMD PSTATE Highest Performance: %lu. Maximum Frequency: "),
199+
amd_pstate_get_data(cpu, AMD_PSTATE_HIGHEST_PERF));
200+
/*
201+
* If boost isn't active, the cpuinfo_max doesn't indicate real max
202+
* frequency. So we read it back from amd-pstate sysfs entry.
203+
*/
204+
print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_MAX_FREQ), no_rounding);
205+
printf(".\n");
206+
207+
printf(_(" AMD PSTATE Nominal Performance: %lu. Nominal Frequency: "),
208+
acpi_cppc_get_data(cpu, NOMINAL_PERF));
209+
print_speed(acpi_cppc_get_data(cpu, NOMINAL_FREQ) * 1000,
210+
no_rounding);
211+
printf(".\n");
212+
213+
printf(_(" AMD PSTATE Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "),
214+
acpi_cppc_get_data(cpu, LOWEST_NONLINEAR_PERF));
215+
print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_LOWEST_NONLINEAR_FREQ),
216+
no_rounding);
217+
printf(".\n");
218+
219+
printf(_(" AMD PSTATE Lowest Performance: %lu. Lowest Frequency: "),
220+
acpi_cppc_get_data(cpu, LOWEST_PERF));
221+
print_speed(acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000, no_rounding);
222+
printf(".\n");
223+
}
224+
196225
/* AMD P-State Helper Functions ************************************/
197226
#endif /* defined(__i386__) || defined(__x86_64__) */

tools/power/cpupower/utils/helpers/helpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ extern int cpufreq_has_boost_support(unsigned int cpu, int *support,
142142
bool cpupower_amd_pstate_enabled(void);
143143
void amd_pstate_boost_init(unsigned int cpu,
144144
int *support, int *active);
145+
void amd_pstate_show_perf_and_freq(unsigned int cpu,
146+
int no_rounding);
145147

146148
/* AMD P-State stuff **************************/
147149

@@ -182,6 +184,9 @@ static inline bool cpupower_amd_pstate_enabled(void)
182184
static inline void amd_pstate_boost_init(unsigned int cpu, int *support,
183185
int *active)
184186
{}
187+
static inline void amd_pstate_show_perf_and_freq(unsigned int cpu,
188+
int no_rounding)
189+
{}
185190

186191
/* cpuid and cpuinfo helpers **************************/
187192

0 commit comments

Comments
 (0)