Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Huang Rui and committed by
Shuah Khan
d8363e29 35fdf42d

+40 -3
+6 -3
tools/power/cpupower/utils/cpufreq-info.c
··· 146 146 printf(_(" Supported: %s\n"), support ? _("yes") : _("no")); 147 147 printf(_(" Active: %s\n"), active ? _("yes") : _("no")); 148 148 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) { 152 155 ret = decode_pstates(cpu, b_states, pstates, &pstate_no); 153 156 if (ret) 154 157 return ret;
+29
tools/power/cpupower/utils/helpers/amd.c
··· 193 193 *active = cpuinfo_max == amd_pstate_max ? 1 : 0; 194 194 } 195 195 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 + 196 225 /* AMD P-State Helper Functions ************************************/ 197 226 #endif /* defined(__i386__) || defined(__x86_64__) */
+5
tools/power/cpupower/utils/helpers/helpers.h
··· 142 142 bool cpupower_amd_pstate_enabled(void); 143 143 void amd_pstate_boost_init(unsigned int cpu, 144 144 int *support, int *active); 145 + void amd_pstate_show_perf_and_freq(unsigned int cpu, 146 + int no_rounding); 145 147 146 148 /* AMD P-State stuff **************************/ 147 149 ··· 183 181 { return false; } 184 182 static inline void amd_pstate_boost_init(unsigned int cpu, int *support, 185 183 int *active) 184 + {} 185 + static inline void amd_pstate_show_perf_and_freq(unsigned int cpu, 186 + int no_rounding) 186 187 {} 187 188 188 189 /* cpuid and cpuinfo helpers **************************/