@@ -245,149 +245,21 @@ static int get_boost_mode(unsigned int cpu)
245
245
return 0 ;
246
246
}
247
247
248
- static void debug_output_one (unsigned int cpu )
249
- {
250
- char * driver ;
251
- struct cpufreq_affected_cpus * cpus ;
252
- struct cpufreq_available_frequencies * freqs ;
253
- unsigned long min , max , freq_kernel , freq_hardware ;
254
- unsigned long total_trans , latency ;
255
- unsigned long long total_time ;
256
- struct cpufreq_policy * policy ;
257
- struct cpufreq_available_governors * governors ;
258
- struct cpufreq_stats * stats ;
259
-
260
- if (cpufreq_cpu_exists (cpu ))
261
- return ;
262
-
263
- freq_kernel = cpufreq_get_freq_kernel (cpu );
264
- freq_hardware = cpufreq_get_freq_hardware (cpu );
265
-
266
- driver = cpufreq_get_driver (cpu );
267
- if (!driver ) {
268
- printf (_ (" no or unknown cpufreq driver is active on this CPU\n" ));
269
- } else {
270
- printf (_ (" driver: %s\n" ), driver );
271
- cpufreq_put_driver (driver );
272
- }
273
-
274
- cpus = cpufreq_get_related_cpus (cpu );
275
- if (cpus ) {
276
- printf (_ (" CPUs which run at the same hardware frequency: " ));
277
- while (cpus -> next ) {
278
- printf ("%d " , cpus -> cpu );
279
- cpus = cpus -> next ;
280
- }
281
- printf ("%d\n" , cpus -> cpu );
282
- cpufreq_put_related_cpus (cpus );
283
- }
284
-
285
- cpus = cpufreq_get_affected_cpus (cpu );
286
- if (cpus ) {
287
- printf (_ (" CPUs which need to have their frequency coordinated by software: " ));
288
- while (cpus -> next ) {
289
- printf ("%d " , cpus -> cpu );
290
- cpus = cpus -> next ;
291
- }
292
- printf ("%d\n" , cpus -> cpu );
293
- cpufreq_put_affected_cpus (cpus );
294
- }
295
-
296
- latency = cpufreq_get_transition_latency (cpu );
297
- if (latency ) {
298
- printf (_ (" maximum transition latency: " ));
299
- print_duration (latency );
300
- printf (".\n" );
301
- }
302
-
303
- if (!(cpufreq_get_hardware_limits (cpu , & min , & max ))) {
304
- printf (_ (" hardware limits: " ));
305
- print_speed (min );
306
- printf (" - " );
307
- print_speed (max );
308
- printf ("\n" );
309
- }
310
-
311
- freqs = cpufreq_get_available_frequencies (cpu );
312
- if (freqs ) {
313
- printf (_ (" available frequency steps: " ));
314
- while (freqs -> next ) {
315
- print_speed (freqs -> frequency );
316
- printf (", " );
317
- freqs = freqs -> next ;
318
- }
319
- print_speed (freqs -> frequency );
320
- printf ("\n" );
321
- cpufreq_put_available_frequencies (freqs );
322
- }
323
-
324
- governors = cpufreq_get_available_governors (cpu );
325
- if (governors ) {
326
- printf (_ (" available cpufreq governors: " ));
327
- while (governors -> next ) {
328
- printf ("%s, " , governors -> governor );
329
- governors = governors -> next ;
330
- }
331
- printf ("%s\n" , governors -> governor );
332
- cpufreq_put_available_governors (governors );
333
- }
334
-
335
- policy = cpufreq_get_policy (cpu );
336
- if (policy ) {
337
- printf (_ (" current policy: frequency should be within " ));
338
- print_speed (policy -> min );
339
- printf (_ (" and " ));
340
- print_speed (policy -> max );
341
-
342
- printf (".\n " );
343
- printf (_ ("The governor \"%s\" may"
344
- " decide which speed to use\n within this range.\n" ),
345
- policy -> governor );
346
- cpufreq_put_policy (policy );
347
- }
348
-
349
- if (freq_kernel || freq_hardware ) {
350
- printf (_ (" current CPU frequency is " ));
351
- if (freq_hardware ) {
352
- print_speed (freq_hardware );
353
- printf (_ (" (asserted by call to hardware)" ));
354
- } else
355
- print_speed (freq_kernel );
356
- printf (".\n" );
357
- }
358
- stats = cpufreq_get_stats (cpu , & total_time );
359
- if (stats ) {
360
- printf (_ (" cpufreq stats: " ));
361
- while (stats ) {
362
- print_speed (stats -> frequency );
363
- printf (":%.2f%%" , (100.0 * stats -> time_in_state ) / total_time );
364
- stats = stats -> next ;
365
- if (stats )
366
- printf (", " );
367
- }
368
- cpufreq_put_stats (stats );
369
- total_trans = cpufreq_get_transitions (cpu );
370
- if (total_trans )
371
- printf (" (%lu)\n" , total_trans );
372
- else
373
- printf ("\n" );
374
- }
375
- get_boost_mode (cpu );
376
-
377
- }
378
-
379
248
/* --freq / -f */
380
249
381
250
static int get_freq_kernel (unsigned int cpu , unsigned int human )
382
251
{
383
252
unsigned long freq = cpufreq_get_freq_kernel (cpu );
384
- if (!freq )
253
+ printf (_ (" current CPU frequency: " ));
254
+ if (!freq ) {
255
+ printf (_ (" Unable to call to kernel\n" ));
385
256
return - EINVAL ;
257
+ }
386
258
if (human ) {
387
259
print_speed (freq );
388
- printf ("\n" );
389
260
} else
390
- printf ("%lu\n" , freq );
261
+ printf ("%lu" , freq );
262
+ printf (_ (" (asserted by call to kernel)\n" ));
391
263
return 0 ;
392
264
}
393
265
@@ -397,13 +269,16 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human)
397
269
static int get_freq_hardware (unsigned int cpu , unsigned int human )
398
270
{
399
271
unsigned long freq = cpufreq_get_freq_hardware (cpu );
400
- if (!freq )
272
+ printf (_ (" current CPU frequency: " ));
273
+ if (!freq ) {
274
+ printf ("Unable to call hardware\n" );
401
275
return - EINVAL ;
276
+ }
402
277
if (human ) {
403
278
print_speed (freq );
404
- printf ("\n" );
405
279
} else
406
- printf ("%lu\n" , freq );
280
+ printf ("%lu" , freq );
281
+ printf (_ (" (asserted by call to hardware)\n" ));
407
282
return 0 ;
408
283
}
409
284
@@ -412,9 +287,17 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
412
287
static int get_hardware_limits (unsigned int cpu )
413
288
{
414
289
unsigned long min , max ;
415
- if (cpufreq_get_hardware_limits (cpu , & min , & max ))
290
+
291
+ printf (_ (" hardware limits: " ));
292
+ if (cpufreq_get_hardware_limits (cpu , & min , & max )) {
293
+ printf (_ ("Not Available\n" ));
416
294
return - EINVAL ;
417
- printf ("%lu %lu\n" , min , max );
295
+ }
296
+
297
+ print_speed (min );
298
+ printf (" - " );
299
+ print_speed (max );
300
+ printf ("\n" );
418
301
return 0 ;
419
302
}
420
303
@@ -423,9 +306,11 @@ static int get_hardware_limits(unsigned int cpu)
423
306
static int get_driver (unsigned int cpu )
424
307
{
425
308
char * driver = cpufreq_get_driver (cpu );
426
- if (!driver )
309
+ if (!driver ) {
310
+ printf (_ (" no or unknown cpufreq driver is active on this CPU\n" ));
427
311
return - EINVAL ;
428
- printf ("%s\n" , driver );
312
+ }
313
+ printf (" driver: %s\n" , driver );
429
314
cpufreq_put_driver (driver );
430
315
return 0 ;
431
316
}
@@ -435,9 +320,19 @@ static int get_driver(unsigned int cpu)
435
320
static int get_policy (unsigned int cpu )
436
321
{
437
322
struct cpufreq_policy * policy = cpufreq_get_policy (cpu );
438
- if (!policy )
323
+ if (!policy ) {
324
+ printf (_ (" Unable to determine current policy\n" ));
439
325
return - EINVAL ;
440
- printf ("%lu %lu %s\n" , policy -> min , policy -> max , policy -> governor );
326
+ }
327
+ printf (_ (" current policy: frequency should be within " ));
328
+ print_speed (policy -> min );
329
+ printf (_ (" and " ));
330
+ print_speed (policy -> max );
331
+
332
+ printf (".\n " );
333
+ printf (_ ("The governor \"%s\" may decide which speed to use\n"
334
+ " within this range.\n" ),
335
+ policy -> governor );
441
336
cpufreq_put_policy (policy );
442
337
return 0 ;
443
338
}
@@ -448,8 +343,12 @@ static int get_available_governors(unsigned int cpu)
448
343
{
449
344
struct cpufreq_available_governors * governors =
450
345
cpufreq_get_available_governors (cpu );
451
- if (!governors )
346
+
347
+ printf (_ (" available cpufreq governors: " ));
348
+ if (!governors ) {
349
+ printf (_ ("Not Available\n" ));
452
350
return - EINVAL ;
351
+ }
453
352
454
353
while (governors -> next ) {
455
354
printf ("%s " , governors -> governor );
@@ -466,8 +365,12 @@ static int get_available_governors(unsigned int cpu)
466
365
static int get_affected_cpus (unsigned int cpu )
467
366
{
468
367
struct cpufreq_affected_cpus * cpus = cpufreq_get_affected_cpus (cpu );
469
- if (!cpus )
368
+
369
+ printf (_ (" CPUs which need to have their frequency coordinated by software: " ));
370
+ if (!cpus ) {
371
+ printf (_ ("Not Available\n" ));
470
372
return - EINVAL ;
373
+ }
471
374
472
375
while (cpus -> next ) {
473
376
printf ("%d " , cpus -> cpu );
@@ -483,8 +386,12 @@ static int get_affected_cpus(unsigned int cpu)
483
386
static int get_related_cpus (unsigned int cpu )
484
387
{
485
388
struct cpufreq_affected_cpus * cpus = cpufreq_get_related_cpus (cpu );
486
- if (!cpus )
389
+
390
+ printf (_ (" CPUs which run at the same hardware frequency: " ));
391
+ if (!cpus ) {
392
+ printf (_ ("Not Available\n" ));
487
393
return - EINVAL ;
394
+ }
488
395
489
396
while (cpus -> next ) {
490
397
printf ("%d " , cpus -> cpu );
@@ -525,8 +432,12 @@ static int get_freq_stats(unsigned int cpu, unsigned int human)
525
432
static int get_latency (unsigned int cpu , unsigned int human )
526
433
{
527
434
unsigned long latency = cpufreq_get_transition_latency (cpu );
528
- if (!latency )
435
+
436
+ printf (_ (" maximum transition latency: " ));
437
+ if (!latency ) {
438
+ printf (_ (" Cannot determine latency.\n" ));
529
439
return - EINVAL ;
440
+ }
530
441
531
442
if (human ) {
532
443
print_duration (latency );
@@ -536,6 +447,36 @@ static int get_latency(unsigned int cpu, unsigned int human)
536
447
return 0 ;
537
448
}
538
449
450
+ static void debug_output_one (unsigned int cpu )
451
+ {
452
+ struct cpufreq_available_frequencies * freqs ;
453
+
454
+ get_driver (cpu );
455
+ get_related_cpus (cpu );
456
+ get_affected_cpus (cpu );
457
+ get_latency (cpu , 1 );
458
+ get_hardware_limits (cpu );
459
+
460
+ freqs = cpufreq_get_available_frequencies (cpu );
461
+ if (freqs ) {
462
+ printf (_ (" available frequency steps: " ));
463
+ while (freqs -> next ) {
464
+ print_speed (freqs -> frequency );
465
+ printf (", " );
466
+ freqs = freqs -> next ;
467
+ }
468
+ print_speed (freqs -> frequency );
469
+ printf ("\n" );
470
+ cpufreq_put_available_frequencies (freqs );
471
+ }
472
+
473
+ get_available_governors (cpu );
474
+ get_policy (cpu );
475
+ if (get_freq_hardware (cpu , 1 ) < 0 )
476
+ get_freq_kernel (cpu , 1 );
477
+ get_boost_mode (cpu );
478
+ }
479
+
539
480
static struct option info_opts [] = {
540
481
{"debug" , no_argument , NULL , 'e' },
541
482
{"boost" , no_argument , NULL , 'b' },
0 commit comments