Lines Matching +full:cpu +full:- +full:driver
1 // SPDX-License-Identifier: GPL-2.0-only
3 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
39 value[LINE_LEN - 1] = '\0'; in count_cpus()
40 if (strlen(value) < (LINE_LEN - 2)) in count_cpus()
42 if (strstr(value, "cpu ")) in count_cpus()
44 if (sscanf(value, "cpu%d ", &cpunr) != 1) in count_cpus()
51 /* cpu count starts from 0, on error return 1 (UP) */ in count_cpus()
58 unsigned int cpu, nr_cpus; in proc_cpufreq_output() local
64 printf(_(" minimum CPU frequency - maximum CPU frequency - governor\n")); in proc_cpufreq_output()
67 for (cpu = 0; cpu < nr_cpus; cpu++) { in proc_cpufreq_output()
68 policy = cpufreq_get_policy(cpu); in proc_cpufreq_output()
72 if (cpufreq_get_hardware_limits(cpu, &min, &max)) { in proc_cpufreq_output()
75 min_pctg = (policy->min * 100) / max; in proc_cpufreq_output()
76 max_pctg = (policy->max * 100) / max; in proc_cpufreq_output()
78 printf("CPU%3d %9lu kHz (%3d %%) - %9lu kHz (%3d %%) - %s\n", in proc_cpufreq_output()
79 cpu , policy->min, max ? min_pctg : 0, policy->max, in proc_cpufreq_output()
80 max ? max_pctg : 0, policy->governor); in proc_cpufreq_output()
125 static int get_boost_mode_x86(unsigned int cpu) in get_boost_mode_x86() argument
131 ret = cpufreq_has_x86_boost_support(cpu, &support, &active, &b_states); in get_boost_mode_x86()
134 " on CPU %d -- are you root?\n"), cpu); in get_boost_mode_x86()
154 ret = decode_pstates(cpu, b_states, pstates, &pstate_no); in get_boost_mode_x86()
164 printf(_(" Pstate-Pb%d: %luMHz (boost state)" in get_boost_mode_x86()
167 printf(_(" Pstate-P%d: %luMHz\n"), in get_boost_mode_x86()
168 i - b_states, pstates[i]); in get_boost_mode_x86()
180 intel_turbo_ratio = msr_intel_get_turbo_ratio(cpu); in get_boost_mode_x86()
181 dprint (" Ratio: 0x%llx - bclk: %f\n", in get_boost_mode_x86()
207 static int get_boost_mode_generic(unsigned int cpu) in get_boost_mode_generic() argument
219 /* --boost / -b */
221 static int get_boost_mode(unsigned int cpu) in get_boost_mode() argument
228 return get_boost_mode_x86(cpu); in get_boost_mode()
230 get_boost_mode_generic(cpu); in get_boost_mode()
232 freqs = cpufreq_get_boost_frequencies(cpu); in get_boost_mode()
235 while (freqs->next) { in get_boost_mode()
236 print_speed(freqs->frequency, no_rounding); in get_boost_mode()
238 freqs = freqs->next; in get_boost_mode()
240 print_speed(freqs->frequency, no_rounding); in get_boost_mode()
248 /* --freq / -f */
250 static int get_freq_kernel(unsigned int cpu, unsigned int human) in get_freq_kernel() argument
252 unsigned long freq = cpufreq_get_freq_kernel(cpu); in get_freq_kernel()
253 printf(_(" current CPU frequency: ")); in get_freq_kernel()
256 return -EINVAL; in get_freq_kernel()
267 /* --hwfreq / -w */
269 static int get_freq_hardware(unsigned int cpu, unsigned int human) in get_freq_hardware() argument
274 return -EINVAL; in get_freq_hardware()
276 freq = cpufreq_get_freq_hardware(cpu); in get_freq_hardware()
277 printf(_(" current CPU frequency: ")); in get_freq_hardware()
280 return -EINVAL; in get_freq_hardware()
290 /* --hwlimits / -l */
292 static int get_hardware_limits(unsigned int cpu, unsigned int human) in get_hardware_limits() argument
296 if (cpufreq_get_hardware_limits(cpu, &min, &max)) { in get_hardware_limits()
298 return -EINVAL; in get_hardware_limits()
304 printf(" - "); in get_hardware_limits()
313 /* --driver / -d */
315 static int get_driver(unsigned int cpu) in get_driver() argument
317 char *driver = cpufreq_get_driver(cpu); in get_driver() local
318 if (!driver) { in get_driver()
319 printf(_(" no or unknown cpufreq driver is active on this CPU\n")); in get_driver()
320 return -EINVAL; in get_driver()
322 printf(" driver: %s\n", driver); in get_driver()
323 cpufreq_put_driver(driver); in get_driver()
327 /* --policy / -p */
329 static int get_policy(unsigned int cpu) in get_policy() argument
331 struct cpufreq_policy *policy = cpufreq_get_policy(cpu); in get_policy()
334 return -EINVAL; in get_policy()
337 print_speed(policy->min, no_rounding); in get_policy()
339 print_speed(policy->max, no_rounding); in get_policy()
344 policy->governor); in get_policy()
349 /* --governors / -g */
351 static int get_available_governors(unsigned int cpu) in get_available_governors() argument
354 cpufreq_get_available_governors(cpu); in get_available_governors()
359 return -EINVAL; in get_available_governors()
362 while (governors->next) { in get_available_governors()
363 printf("%s ", governors->governor); in get_available_governors()
364 governors = governors->next; in get_available_governors()
366 printf("%s\n", governors->governor); in get_available_governors()
372 /* --affected-cpus / -a */
374 static int get_affected_cpus(unsigned int cpu) in get_affected_cpus() argument
376 struct cpufreq_affected_cpus *cpus = cpufreq_get_affected_cpus(cpu); in get_affected_cpus()
381 return -EINVAL; in get_affected_cpus()
384 while (cpus->next) { in get_affected_cpus()
385 printf("%d ", cpus->cpu); in get_affected_cpus()
386 cpus = cpus->next; in get_affected_cpus()
388 printf("%d\n", cpus->cpu); in get_affected_cpus()
393 /* --related-cpus / -r */
395 static int get_related_cpus(unsigned int cpu) in get_related_cpus() argument
397 struct cpufreq_affected_cpus *cpus = cpufreq_get_related_cpus(cpu); in get_related_cpus()
402 return -EINVAL; in get_related_cpus()
405 while (cpus->next) { in get_related_cpus()
406 printf("%d ", cpus->cpu); in get_related_cpus()
407 cpus = cpus->next; in get_related_cpus()
409 printf("%d\n", cpus->cpu); in get_related_cpus()
414 /* --stats / -s */
416 static int get_freq_stats(unsigned int cpu, unsigned int human) in get_freq_stats() argument
418 unsigned long total_trans = cpufreq_get_transitions(cpu); in get_freq_stats()
420 struct cpufreq_stats *stats = cpufreq_get_stats(cpu, &total_time); in get_freq_stats()
423 print_speed(stats->frequency, no_rounding); in get_freq_stats()
425 (100.0 * stats->time_in_state) / total_time); in get_freq_stats()
428 stats->frequency, stats->time_in_state); in get_freq_stats()
429 stats = stats->next; in get_freq_stats()
439 /* --epp / -z */
441 static int get_epp(unsigned int cpu, bool interactive) in get_epp() argument
445 epp = cpufreq_get_energy_performance_preference(cpu); in get_epp()
447 return -EINVAL; in get_epp()
456 /* --latency / -y */
458 static int get_latency(unsigned int cpu, unsigned int human) in get_latency() argument
460 unsigned long latency = cpufreq_get_transition_latency(cpu); in get_latency()
462 if (!get_epp(cpu, false)) in get_latency()
463 return -EINVAL; in get_latency()
468 return -EINVAL; in get_latency()
479 /* --performance / -c */
481 static int get_perf_cap(unsigned int cpu) in get_perf_cap() argument
485 amd_pstate_show_perf_and_freq(cpu, no_rounding); in get_perf_cap()
490 static void debug_output_one(unsigned int cpu) in debug_output_one() argument
494 get_driver(cpu); in debug_output_one()
495 get_related_cpus(cpu); in debug_output_one()
496 get_affected_cpus(cpu); in debug_output_one()
497 get_latency(cpu, 1); in debug_output_one()
498 get_epp(cpu, true); in debug_output_one()
499 get_hardware_limits(cpu, 1); in debug_output_one()
501 freqs = cpufreq_get_available_frequencies(cpu); in debug_output_one()
504 while (freqs->next) { in debug_output_one()
505 print_speed(freqs->frequency, no_rounding); in debug_output_one()
507 freqs = freqs->next; in debug_output_one()
509 print_speed(freqs->frequency, no_rounding); in debug_output_one()
514 get_available_governors(cpu); in debug_output_one()
515 get_policy(cpu); in debug_output_one()
516 if (get_freq_hardware(cpu, 1) < 0) in debug_output_one()
517 get_freq_kernel(cpu, 1); in debug_output_one()
518 get_boost_mode(cpu); in debug_output_one()
519 get_perf_cap(cpu); in debug_output_one()
528 {"driver", no_argument, NULL, 'd'},
531 {"related-cpus", no_argument, NULL, 'r'},
532 {"affected-cpus", no_argument, NULL, 'a'},
537 {"no-rounding", no_argument, NULL, 'n'},
548 unsigned int cpu = 0; in cmd_freq_info() local
560 case -1: in cmd_freq_info()
579 output_param = -1; in cmd_freq_info()
587 output_param = -1; in cmd_freq_info()
606 "combined with passing a --cpu argument\n")); in cmd_freq_info()
607 return -EINVAL; in cmd_freq_info()
621 case -1: in cmd_freq_info()
622 printf(_("You can't specify more than one --cpu parameter and/or\n" in cmd_freq_info()
623 "more than one output-specific argument\n")); in cmd_freq_info()
624 return -EINVAL; in cmd_freq_info()
627 return -EINVAL; in cmd_freq_info()
633 for (cpu = bitmask_first(cpus_chosen); in cmd_freq_info()
634 cpu <= bitmask_last(cpus_chosen); cpu++) { in cmd_freq_info()
636 if (!bitmask_isbitset(cpus_chosen, cpu)) in cmd_freq_info()
639 printf(_("analyzing CPU %d:\n"), cpu); in cmd_freq_info()
641 if (sysfs_is_cpu_online(cpu) != 1) { in cmd_freq_info()
649 get_boost_mode(cpu); in cmd_freq_info()
652 debug_output_one(cpu); in cmd_freq_info()
655 ret = get_affected_cpus(cpu); in cmd_freq_info()
658 ret = get_related_cpus(cpu); in cmd_freq_info()
661 ret = get_available_governors(cpu); in cmd_freq_info()
664 ret = get_policy(cpu); in cmd_freq_info()
667 ret = get_driver(cpu); in cmd_freq_info()
670 ret = get_hardware_limits(cpu, human); in cmd_freq_info()
673 ret = get_freq_hardware(cpu, human); in cmd_freq_info()
676 ret = get_freq_kernel(cpu, human); in cmd_freq_info()
679 ret = get_freq_stats(cpu, human); in cmd_freq_info()
682 ret = get_latency(cpu, human); in cmd_freq_info()
685 ret = get_perf_cap(cpu); in cmd_freq_info()
688 ret = get_epp(cpu, true); in cmd_freq_info()