@@ -84,43 +84,6 @@ static void proc_cpufreq_output(void)
8484}
8585
8686static int no_rounding ;
87- static void print_speed (unsigned long speed )
88- {
89- unsigned long tmp ;
90-
91- if (no_rounding ) {
92- if (speed > 1000000 )
93- printf ("%u.%06u GHz" , ((unsigned int ) speed /1000000 ),
94- ((unsigned int ) speed %1000000 ));
95- else if (speed > 1000 )
96- printf ("%u.%03u MHz" , ((unsigned int ) speed /1000 ),
97- (unsigned int ) (speed %1000 ));
98- else
99- printf ("%lu kHz" , speed );
100- } else {
101- if (speed > 1000000 ) {
102- tmp = speed %10000 ;
103- if (tmp >= 5000 )
104- speed += 10000 ;
105- printf ("%u.%02u GHz" , ((unsigned int ) speed /1000000 ),
106- ((unsigned int ) (speed %1000000 )/10000 ));
107- } else if (speed > 100000 ) {
108- tmp = speed %1000 ;
109- if (tmp >= 500 )
110- speed += 1000 ;
111- printf ("%u MHz" , ((unsigned int ) speed /1000 ));
112- } else if (speed > 1000 ) {
113- tmp = speed %100 ;
114- if (tmp >= 50 )
115- speed += 100 ;
116- printf ("%u.%01u MHz" , ((unsigned int ) speed /1000 ),
117- ((unsigned int ) (speed %1000 )/100 ));
118- }
119- }
120-
121- return ;
122- }
123-
12487static void print_duration (unsigned long duration )
12588{
12689 unsigned long tmp ;
@@ -183,9 +146,12 @@ static int get_boost_mode_x86(unsigned int cpu)
183146 printf (_ (" Supported: %s\n" ), support ? _ ("yes" ) : _ ("no" ));
184147 printf (_ (" Active: %s\n" ), active ? _ ("yes" ) : _ ("no" ));
185148
186- if ((cpupower_cpu_info .vendor == X86_VENDOR_AMD &&
187- cpupower_cpu_info .family >= 0x10 ) ||
188- 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 ) {
189155 ret = decode_pstates (cpu , b_states , pstates , & pstate_no );
190156 if (ret )
191157 return ret ;
@@ -254,11 +220,11 @@ static int get_boost_mode(unsigned int cpu)
254220 if (freqs ) {
255221 printf (_ (" boost frequency steps: " ));
256222 while (freqs -> next ) {
257- print_speed (freqs -> frequency );
223+ print_speed (freqs -> frequency , no_rounding );
258224 printf (", " );
259225 freqs = freqs -> next ;
260226 }
261- print_speed (freqs -> frequency );
227+ print_speed (freqs -> frequency , no_rounding );
262228 printf ("\n" );
263229 cpufreq_put_available_frequencies (freqs );
264230 }
@@ -277,7 +243,7 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human)
277243 return - EINVAL ;
278244 }
279245 if (human ) {
280- print_speed (freq );
246+ print_speed (freq , no_rounding );
281247 } else
282248 printf ("%lu" , freq );
283249 printf (_ (" (asserted by call to kernel)\n" ));
@@ -296,7 +262,7 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
296262 return - EINVAL ;
297263 }
298264 if (human ) {
299- print_speed (freq );
265+ print_speed (freq , no_rounding );
300266 } else
301267 printf ("%lu" , freq );
302268 printf (_ (" (asserted by call to hardware)\n" ));
@@ -316,9 +282,9 @@ static int get_hardware_limits(unsigned int cpu, unsigned int human)
316282
317283 if (human ) {
318284 printf (_ (" hardware limits: " ));
319- print_speed (min );
285+ print_speed (min , no_rounding );
320286 printf (" - " );
321- print_speed (max );
287+ print_speed (max , no_rounding );
322288 printf ("\n" );
323289 } else {
324290 printf ("%lu %lu\n" , min , max );
@@ -350,9 +316,9 @@ static int get_policy(unsigned int cpu)
350316 return - EINVAL ;
351317 }
352318 printf (_ (" current policy: frequency should be within " ));
353- print_speed (policy -> min );
319+ print_speed (policy -> min , no_rounding );
354320 printf (_ (" and " ));
355- print_speed (policy -> max );
321+ print_speed (policy -> max , no_rounding );
356322
357323 printf (".\n " );
358324 printf (_ ("The governor \"%s\" may decide which speed to use\n"
@@ -436,7 +402,7 @@ static int get_freq_stats(unsigned int cpu, unsigned int human)
436402 struct cpufreq_stats * stats = cpufreq_get_stats (cpu , & total_time );
437403 while (stats ) {
438404 if (human ) {
439- print_speed (stats -> frequency );
405+ print_speed (stats -> frequency , no_rounding );
440406 printf (":%.2f%%" ,
441407 (100.0 * stats -> time_in_state ) / total_time );
442408 } else
@@ -472,6 +438,17 @@ static int get_latency(unsigned int cpu, unsigned int human)
472438 return 0 ;
473439}
474440
441+ /* --performance / -c */
442+
443+ static int get_perf_cap (unsigned int cpu )
444+ {
445+ if (cpupower_cpu_info .vendor == X86_VENDOR_AMD &&
446+ cpupower_cpu_info .caps & CPUPOWER_CAP_AMD_PSTATE )
447+ amd_pstate_show_perf_and_freq (cpu , no_rounding );
448+
449+ return 0 ;
450+ }
451+
475452static void debug_output_one (unsigned int cpu )
476453{
477454 struct cpufreq_available_frequencies * freqs ;
@@ -486,11 +463,11 @@ static void debug_output_one(unsigned int cpu)
486463 if (freqs ) {
487464 printf (_ (" available frequency steps: " ));
488465 while (freqs -> next ) {
489- print_speed (freqs -> frequency );
466+ print_speed (freqs -> frequency , no_rounding );
490467 printf (", " );
491468 freqs = freqs -> next ;
492469 }
493- print_speed (freqs -> frequency );
470+ print_speed (freqs -> frequency , no_rounding );
494471 printf ("\n" );
495472 cpufreq_put_available_frequencies (freqs );
496473 }
@@ -500,6 +477,7 @@ static void debug_output_one(unsigned int cpu)
500477 if (get_freq_hardware (cpu , 1 ) < 0 )
501478 get_freq_kernel (cpu , 1 );
502479 get_boost_mode (cpu );
480+ get_perf_cap (cpu );
503481}
504482
505483static struct option info_opts [] = {
@@ -518,6 +496,7 @@ static struct option info_opts[] = {
518496 {"proc" , no_argument , NULL , 'o' },
519497 {"human" , no_argument , NULL , 'm' },
520498 {"no-rounding" , no_argument , NULL , 'n' },
499+ {"performance" , no_argument , NULL , 'c' },
521500 { },
522501};
523502
@@ -531,7 +510,7 @@ int cmd_freq_info(int argc, char **argv)
531510 int output_param = 0 ;
532511
533512 do {
534- ret = getopt_long (argc , argv , "oefwldpgrasmybn " , info_opts ,
513+ ret = getopt_long (argc , argv , "oefwldpgrasmybnc " , info_opts ,
535514 NULL );
536515 switch (ret ) {
537516 case '?' :
@@ -554,6 +533,7 @@ int cmd_freq_info(int argc, char **argv)
554533 case 'e' :
555534 case 's' :
556535 case 'y' :
536+ case 'c' :
557537 if (output_param ) {
558538 output_param = -1 ;
559539 cont = 0 ;
@@ -660,6 +640,9 @@ int cmd_freq_info(int argc, char **argv)
660640 case 'y' :
661641 ret = get_latency (cpu , human );
662642 break ;
643+ case 'c' :
644+ ret = get_perf_cap (cpu );
645+ break ;
663646 }
664647 if (ret )
665648 return ret ;
0 commit comments