diff options
| -rw-r--r-- | tools/power/cpupower/lib/cpufreq.c | 19 | ||||
| -rw-r--r-- | tools/power/cpupower/lib/cpufreq.h | 16 | ||||
| -rw-r--r-- | tools/power/cpupower/utils/cpufreq-info.c | 42 |
3 files changed, 50 insertions, 27 deletions
diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index 0c0f3e3f0d80..80650497fb80 100644 --- a/tools/power/cpupower/lib/cpufreq.c +++ b/tools/power/cpupower/lib/cpufreq.c | |||
| @@ -333,17 +333,20 @@ void cpufreq_put_available_governors(struct cpufreq_available_governors *any) | |||
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | 335 | ||
| 336 | struct cpufreq_available_frequencies | 336 | struct cpufreq_frequencies |
| 337 | *cpufreq_get_available_frequencies(unsigned int cpu) | 337 | *cpufreq_get_frequencies(const char *type, unsigned int cpu) |
| 338 | { | 338 | { |
| 339 | struct cpufreq_available_frequencies *first = NULL; | 339 | struct cpufreq_frequencies *first = NULL; |
| 340 | struct cpufreq_available_frequencies *current = NULL; | 340 | struct cpufreq_frequencies *current = NULL; |
| 341 | char one_value[SYSFS_PATH_MAX]; | 341 | char one_value[SYSFS_PATH_MAX]; |
| 342 | char linebuf[MAX_LINE_LEN]; | 342 | char linebuf[MAX_LINE_LEN]; |
| 343 | char fname[MAX_LINE_LEN]; | ||
| 343 | unsigned int pos, i; | 344 | unsigned int pos, i; |
| 344 | unsigned int len; | 345 | unsigned int len; |
| 345 | 346 | ||
| 346 | len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies", | 347 | snprintf(fname, MAX_LINE_LEN, "scaling_%s_frequencies", type); |
| 348 | |||
| 349 | len = sysfs_cpufreq_read_file(cpu, fname, | ||
| 347 | linebuf, sizeof(linebuf)); | 350 | linebuf, sizeof(linebuf)); |
| 348 | if (len == 0) | 351 | if (len == 0) |
| 349 | return NULL; | 352 | return NULL; |
| @@ -389,9 +392,9 @@ struct cpufreq_available_frequencies | |||
| 389 | return NULL; | 392 | return NULL; |
| 390 | } | 393 | } |
| 391 | 394 | ||
| 392 | void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies | 395 | void cpufreq_put_frequencies(struct cpufreq_frequencies *any) |
| 393 | *any) { | 396 | { |
| 394 | struct cpufreq_available_frequencies *tmp, *next; | 397 | struct cpufreq_frequencies *tmp, *next; |
| 395 | 398 | ||
| 396 | if (!any) | 399 | if (!any) |
| 397 | return; | 400 | return; |
diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h index 60beaf5ed2ea..775738269cbf 100644 --- a/tools/power/cpupower/lib/cpufreq.h +++ b/tools/power/cpupower/lib/cpufreq.h | |||
| @@ -28,10 +28,10 @@ struct cpufreq_available_governors { | |||
| 28 | struct cpufreq_available_governors *first; | 28 | struct cpufreq_available_governors *first; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | struct cpufreq_available_frequencies { | 31 | struct cpufreq_frequencies { |
| 32 | unsigned long frequency; | 32 | unsigned long frequency; |
| 33 | struct cpufreq_available_frequencies *next; | 33 | struct cpufreq_frequencies *next; |
| 34 | struct cpufreq_available_frequencies *first; | 34 | struct cpufreq_frequencies *first; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | 37 | ||
| @@ -129,14 +129,14 @@ void cpufreq_put_available_governors( | |||
| 129 | * | 129 | * |
| 130 | * Only present on _some_ ->target() cpufreq drivers. For information purposes | 130 | * Only present on _some_ ->target() cpufreq drivers. For information purposes |
| 131 | * only. Please free allocated memory by calling | 131 | * only. Please free allocated memory by calling |
| 132 | * cpufreq_put_available_frequencies after use. | 132 | * cpufreq_put_frequencies after use. |
| 133 | */ | 133 | */ |
| 134 | 134 | ||
| 135 | struct cpufreq_available_frequencies | 135 | struct cpufreq_frequencies |
| 136 | *cpufreq_get_available_frequencies(unsigned int cpu); | 136 | *cpufreq_get_frequencies(const char *type, unsigned int cpu); |
| 137 | 137 | ||
| 138 | void cpufreq_put_available_frequencies( | 138 | void cpufreq_put_frequencies( |
| 139 | struct cpufreq_available_frequencies *first); | 139 | struct cpufreq_frequencies *first); |
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | /* determine affected CPUs | 142 | /* determine affected CPUs |
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index c3f39d5128ee..10290b308797 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c | |||
| @@ -161,19 +161,12 @@ static void print_duration(unsigned long duration) | |||
| 161 | return; | 161 | return; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | /* --boost / -b */ | 164 | static int get_boost_mode_x86(unsigned int cpu) |
| 165 | |||
| 166 | static int get_boost_mode(unsigned int cpu) | ||
| 167 | { | 165 | { |
| 168 | int support, active, b_states = 0, ret, pstate_no, i; | 166 | int support, active, b_states = 0, ret, pstate_no, i; |
| 169 | /* ToDo: Make this more global */ | 167 | /* ToDo: Make this more global */ |
| 170 | unsigned long pstates[MAX_HW_PSTATES] = {0,}; | 168 | unsigned long pstates[MAX_HW_PSTATES] = {0,}; |
| 171 | 169 | ||
| 172 | if (cpupower_cpu_info.vendor != X86_VENDOR_AMD && | ||
| 173 | cpupower_cpu_info.vendor != X86_VENDOR_HYGON && | ||
| 174 | cpupower_cpu_info.vendor != X86_VENDOR_INTEL) | ||
| 175 | return 0; | ||
| 176 | |||
| 177 | ret = cpufreq_has_boost_support(cpu, &support, &active, &b_states); | 170 | ret = cpufreq_has_boost_support(cpu, &support, &active, &b_states); |
| 178 | if (ret) { | 171 | if (ret) { |
| 179 | printf(_("Error while evaluating Boost Capabilities" | 172 | printf(_("Error while evaluating Boost Capabilities" |
| @@ -248,6 +241,33 @@ static int get_boost_mode(unsigned int cpu) | |||
| 248 | return 0; | 241 | return 0; |
| 249 | } | 242 | } |
| 250 | 243 | ||
| 244 | /* --boost / -b */ | ||
| 245 | |||
| 246 | static int get_boost_mode(unsigned int cpu) | ||
| 247 | { | ||
| 248 | struct cpufreq_frequencies *freqs; | ||
| 249 | |||
| 250 | if (cpupower_cpu_info.vendor == X86_VENDOR_AMD || | ||
| 251 | cpupower_cpu_info.vendor == X86_VENDOR_HYGON || | ||
| 252 | cpupower_cpu_info.vendor == X86_VENDOR_INTEL) | ||
| 253 | return get_boost_mode_x86(cpu); | ||
| 254 | |||
| 255 | freqs = cpufreq_get_frequencies("boost", cpu); | ||
| 256 | if (freqs) { | ||
| 257 | printf(_(" boost frequency steps: ")); | ||
| 258 | while (freqs->next) { | ||
| 259 | print_speed(freqs->frequency); | ||
| 260 | printf(", "); | ||
| 261 | freqs = freqs->next; | ||
| 262 | } | ||
| 263 | print_speed(freqs->frequency); | ||
| 264 | printf("\n"); | ||
| 265 | cpufreq_put_frequencies(freqs); | ||
| 266 | } | ||
| 267 | |||
| 268 | return 0; | ||
| 269 | } | ||
| 270 | |||
| 251 | /* --freq / -f */ | 271 | /* --freq / -f */ |
| 252 | 272 | ||
| 253 | static int get_freq_kernel(unsigned int cpu, unsigned int human) | 273 | static int get_freq_kernel(unsigned int cpu, unsigned int human) |
| @@ -456,7 +476,7 @@ static int get_latency(unsigned int cpu, unsigned int human) | |||
| 456 | 476 | ||
| 457 | static void debug_output_one(unsigned int cpu) | 477 | static void debug_output_one(unsigned int cpu) |
| 458 | { | 478 | { |
| 459 | struct cpufreq_available_frequencies *freqs; | 479 | struct cpufreq_frequencies *freqs; |
| 460 | 480 | ||
| 461 | get_driver(cpu); | 481 | get_driver(cpu); |
| 462 | get_related_cpus(cpu); | 482 | get_related_cpus(cpu); |
| @@ -464,7 +484,7 @@ static void debug_output_one(unsigned int cpu) | |||
| 464 | get_latency(cpu, 1); | 484 | get_latency(cpu, 1); |
| 465 | get_hardware_limits(cpu, 1); | 485 | get_hardware_limits(cpu, 1); |
| 466 | 486 | ||
| 467 | freqs = cpufreq_get_available_frequencies(cpu); | 487 | freqs = cpufreq_get_frequencies("available", cpu); |
| 468 | if (freqs) { | 488 | if (freqs) { |
| 469 | printf(_(" available frequency steps: ")); | 489 | printf(_(" available frequency steps: ")); |
| 470 | while (freqs->next) { | 490 | while (freqs->next) { |
| @@ -474,7 +494,7 @@ static void debug_output_one(unsigned int cpu) | |||
| 474 | } | 494 | } |
| 475 | print_speed(freqs->frequency); | 495 | print_speed(freqs->frequency); |
| 476 | printf("\n"); | 496 | printf("\n"); |
| 477 | cpufreq_put_available_frequencies(freqs); | 497 | cpufreq_put_frequencies(freqs); |
| 478 | } | 498 | } |
| 479 | 499 | ||
| 480 | get_available_governors(cpu); | 500 | get_available_governors(cpu); |
