@@ -88,7 +88,6 @@ struct time_in_idle {
88
88
* @policy: cpufreq policy.
89
89
* @node: list_head to link all cpufreq_cooling_device together.
90
90
* @idle_time: idle time stats
91
- * @plat_get_static_power: callback to calculate the static power
92
91
*
93
92
* This structure is required for keeping information of each registered
94
93
* cpufreq_cooling_device.
@@ -104,7 +103,6 @@ struct cpufreq_cooling_device {
104
103
struct cpufreq_policy * policy ;
105
104
struct list_head node ;
106
105
struct time_in_idle * idle_time ;
107
- get_static_t plat_get_static_power ;
108
106
};
109
107
110
108
static DEFINE_IDA (cpufreq_ida );
@@ -318,60 +316,6 @@ static u32 get_load(struct cpufreq_cooling_device *cpufreq_cdev, int cpu,
318
316
return load ;
319
317
}
320
318
321
- /**
322
- * get_static_power() - calculate the static power consumed by the cpus
323
- * @cpufreq_cdev: struct &cpufreq_cooling_device for this cpu cdev
324
- * @tz: thermal zone device in which we're operating
325
- * @freq: frequency in KHz
326
- * @power: pointer in which to store the calculated static power
327
- *
328
- * Calculate the static power consumed by the cpus described by
329
- * @cpu_actor running at frequency @freq. This function relies on a
330
- * platform specific function that should have been provided when the
331
- * actor was registered. If it wasn't, the static power is assumed to
332
- * be negligible. The calculated static power is stored in @power.
333
- *
334
- * Return: 0 on success, -E* on failure.
335
- */
336
- static int get_static_power (struct cpufreq_cooling_device * cpufreq_cdev ,
337
- struct thermal_zone_device * tz , unsigned long freq ,
338
- u32 * power )
339
- {
340
- struct dev_pm_opp * opp ;
341
- unsigned long voltage ;
342
- struct cpufreq_policy * policy = cpufreq_cdev -> policy ;
343
- struct cpumask * cpumask = policy -> related_cpus ;
344
- unsigned long freq_hz = freq * 1000 ;
345
- struct device * dev ;
346
-
347
- if (!cpufreq_cdev -> plat_get_static_power ) {
348
- * power = 0 ;
349
- return 0 ;
350
- }
351
-
352
- dev = get_cpu_device (policy -> cpu );
353
- WARN_ON (!dev );
354
-
355
- opp = dev_pm_opp_find_freq_exact (dev , freq_hz , true);
356
- if (IS_ERR (opp )) {
357
- dev_warn_ratelimited (dev , "Failed to find OPP for frequency %lu: %ld\n" ,
358
- freq_hz , PTR_ERR (opp ));
359
- return - EINVAL ;
360
- }
361
-
362
- voltage = dev_pm_opp_get_voltage (opp );
363
- dev_pm_opp_put (opp );
364
-
365
- if (voltage == 0 ) {
366
- dev_err_ratelimited (dev , "Failed to get voltage for frequency %lu\n" ,
367
- freq_hz );
368
- return - EINVAL ;
369
- }
370
-
371
- return cpufreq_cdev -> plat_get_static_power (cpumask , tz -> passive_delay ,
372
- voltage , power );
373
- }
374
-
375
319
/**
376
320
* get_dynamic_power() - calculate the dynamic power
377
321
* @cpufreq_cdev: &cpufreq_cooling_device for this cdev
@@ -491,8 +435,8 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
491
435
u32 * power )
492
436
{
493
437
unsigned long freq ;
494
- int i = 0 , cpu , ret ;
495
- u32 static_power , dynamic_power , total_load = 0 ;
438
+ int i = 0 , cpu ;
439
+ u32 total_load = 0 ;
496
440
struct cpufreq_cooling_device * cpufreq_cdev = cdev -> devdata ;
497
441
struct cpufreq_policy * policy = cpufreq_cdev -> policy ;
498
442
u32 * load_cpu = NULL ;
@@ -522,22 +466,15 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
522
466
523
467
cpufreq_cdev -> last_load = total_load ;
524
468
525
- dynamic_power = get_dynamic_power (cpufreq_cdev , freq );
526
- ret = get_static_power (cpufreq_cdev , tz , freq , & static_power );
527
- if (ret ) {
528
- kfree (load_cpu );
529
- return ret ;
530
- }
469
+ * power = get_dynamic_power (cpufreq_cdev , freq );
531
470
532
471
if (load_cpu ) {
533
472
trace_thermal_power_cpu_get_power (policy -> related_cpus , freq ,
534
- load_cpu , i , dynamic_power ,
535
- static_power );
473
+ load_cpu , i , * power );
536
474
537
475
kfree (load_cpu );
538
476
}
539
477
540
- * power = static_power + dynamic_power ;
541
478
return 0 ;
542
479
}
543
480
@@ -561,8 +498,6 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
561
498
unsigned long state , u32 * power )
562
499
{
563
500
unsigned int freq , num_cpus ;
564
- u32 static_power , dynamic_power ;
565
- int ret ;
566
501
struct cpufreq_cooling_device * cpufreq_cdev = cdev -> devdata ;
567
502
568
503
/* Request state should be less than max_level */
@@ -572,13 +507,9 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
572
507
num_cpus = cpumask_weight (cpufreq_cdev -> policy -> cpus );
573
508
574
509
freq = cpufreq_cdev -> freq_table [state ].frequency ;
575
- dynamic_power = cpu_freq_to_power (cpufreq_cdev , freq ) * num_cpus ;
576
- ret = get_static_power (cpufreq_cdev , tz , freq , & static_power );
577
- if (ret )
578
- return ret ;
510
+ * power = cpu_freq_to_power (cpufreq_cdev , freq ) * num_cpus ;
579
511
580
- * power = static_power + dynamic_power ;
581
- return ret ;
512
+ return 0 ;
582
513
}
583
514
584
515
/**
@@ -606,21 +537,14 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
606
537
unsigned long * state )
607
538
{
608
539
unsigned int cur_freq , target_freq ;
609
- int ret ;
610
- s32 dyn_power ;
611
- u32 last_load , normalised_power , static_power ;
540
+ u32 last_load , normalised_power ;
612
541
struct cpufreq_cooling_device * cpufreq_cdev = cdev -> devdata ;
613
542
struct cpufreq_policy * policy = cpufreq_cdev -> policy ;
614
543
615
544
cur_freq = cpufreq_quick_get (policy -> cpu );
616
- ret = get_static_power (cpufreq_cdev , tz , cur_freq , & static_power );
617
- if (ret )
618
- return ret ;
619
-
620
- dyn_power = power - static_power ;
621
- dyn_power = dyn_power > 0 ? dyn_power : 0 ;
545
+ power = power > 0 ? power : 0 ;
622
546
last_load = cpufreq_cdev -> last_load ?: 1 ;
623
- normalised_power = (dyn_power * 100 ) / last_load ;
547
+ normalised_power = (power * 100 ) / last_load ;
624
548
target_freq = cpu_power_to_freq (cpufreq_cdev , normalised_power );
625
549
626
550
* state = get_level (cpufreq_cdev , target_freq );
@@ -671,8 +595,6 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
671
595
* @policy: cpufreq policy
672
596
* Normally this should be same as cpufreq policy->related_cpus.
673
597
* @capacitance: dynamic power coefficient for these cpus
674
- * @plat_static_func: function to calculate the static power consumed by these
675
- * cpus (optional)
676
598
*
677
599
* This interface function registers the cpufreq cooling device with the name
678
600
* "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
@@ -684,8 +606,7 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
684
606
*/
685
607
static struct thermal_cooling_device *
686
608
__cpufreq_cooling_register (struct device_node * np ,
687
- struct cpufreq_policy * policy , u32 capacitance ,
688
- get_static_t plat_static_func )
609
+ struct cpufreq_policy * policy , u32 capacitance )
689
610
{
690
611
struct thermal_cooling_device * cdev ;
691
612
struct cpufreq_cooling_device * cpufreq_cdev ;
@@ -755,8 +676,6 @@ __cpufreq_cooling_register(struct device_node *np,
755
676
}
756
677
757
678
if (capacitance ) {
758
- cpufreq_cdev -> plat_get_static_power = plat_static_func ;
759
-
760
679
ret = update_freq_table (cpufreq_cdev , capacitance );
761
680
if (ret ) {
762
681
cdev = ERR_PTR (ret );
@@ -813,7 +732,7 @@ __cpufreq_cooling_register(struct device_node *np,
813
732
struct thermal_cooling_device *
814
733
cpufreq_cooling_register (struct cpufreq_policy * policy )
815
734
{
816
- return __cpufreq_cooling_register (NULL , policy , 0 , NULL );
735
+ return __cpufreq_cooling_register (NULL , policy , 0 );
817
736
}
818
737
EXPORT_SYMBOL_GPL (cpufreq_cooling_register );
819
738
@@ -853,8 +772,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy)
853
772
of_property_read_u32 (np , "dynamic-power-coefficient" ,
854
773
& capacitance );
855
774
856
- cdev = __cpufreq_cooling_register (np , policy , capacitance ,
857
- NULL );
775
+ cdev = __cpufreq_cooling_register (np , policy , capacitance );
858
776
if (IS_ERR (cdev )) {
859
777
pr_err ("cpu_cooling: cpu%d is not running as cooling device: %ld\n" ,
860
778
policy -> cpu , PTR_ERR (cdev ));
0 commit comments