Skip to content

Commit 84fe2ca

Browse files
vireshkrafaeljw
authored andcommitted
cpu_cooling: Drop static-power related stuff
No one has used it for the last two and half years (since it was introduced by commit c36cf07 (thermal: cpu_cooling: implement the power cooling device API), get rid of it. Acked-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3ebb62f commit 84fe2ca

File tree

3 files changed

+16
-103
lines changed

3 files changed

+16
-103
lines changed

drivers/thermal/cpu_cooling.c

Lines changed: 12 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct time_in_idle {
8888
* @policy: cpufreq policy.
8989
* @node: list_head to link all cpufreq_cooling_device together.
9090
* @idle_time: idle time stats
91-
* @plat_get_static_power: callback to calculate the static power
9291
*
9392
* This structure is required for keeping information of each registered
9493
* cpufreq_cooling_device.
@@ -104,7 +103,6 @@ struct cpufreq_cooling_device {
104103
struct cpufreq_policy *policy;
105104
struct list_head node;
106105
struct time_in_idle *idle_time;
107-
get_static_t plat_get_static_power;
108106
};
109107

110108
static DEFINE_IDA(cpufreq_ida);
@@ -318,60 +316,6 @@ static u32 get_load(struct cpufreq_cooling_device *cpufreq_cdev, int cpu,
318316
return load;
319317
}
320318

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-
375319
/**
376320
* get_dynamic_power() - calculate the dynamic power
377321
* @cpufreq_cdev: &cpufreq_cooling_device for this cdev
@@ -491,8 +435,8 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
491435
u32 *power)
492436
{
493437
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;
496440
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
497441
struct cpufreq_policy *policy = cpufreq_cdev->policy;
498442
u32 *load_cpu = NULL;
@@ -522,22 +466,15 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
522466

523467
cpufreq_cdev->last_load = total_load;
524468

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);
531470

532471
if (load_cpu) {
533472
trace_thermal_power_cpu_get_power(policy->related_cpus, freq,
534-
load_cpu, i, dynamic_power,
535-
static_power);
473+
load_cpu, i, *power);
536474

537475
kfree(load_cpu);
538476
}
539477

540-
*power = static_power + dynamic_power;
541478
return 0;
542479
}
543480

@@ -561,8 +498,6 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
561498
unsigned long state, u32 *power)
562499
{
563500
unsigned int freq, num_cpus;
564-
u32 static_power, dynamic_power;
565-
int ret;
566501
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
567502

568503
/* Request state should be less than max_level */
@@ -572,13 +507,9 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
572507
num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus);
573508

574509
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;
579511

580-
*power = static_power + dynamic_power;
581-
return ret;
512+
return 0;
582513
}
583514

584515
/**
@@ -606,21 +537,14 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
606537
unsigned long *state)
607538
{
608539
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;
612541
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
613542
struct cpufreq_policy *policy = cpufreq_cdev->policy;
614543

615544
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;
622546
last_load = cpufreq_cdev->last_load ?: 1;
623-
normalised_power = (dyn_power * 100) / last_load;
547+
normalised_power = (power * 100) / last_load;
624548
target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power);
625549

626550
*state = get_level(cpufreq_cdev, target_freq);
@@ -671,8 +595,6 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
671595
* @policy: cpufreq policy
672596
* Normally this should be same as cpufreq policy->related_cpus.
673597
* @capacitance: dynamic power coefficient for these cpus
674-
* @plat_static_func: function to calculate the static power consumed by these
675-
* cpus (optional)
676598
*
677599
* This interface function registers the cpufreq cooling device with the name
678600
* "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,
684606
*/
685607
static struct thermal_cooling_device *
686608
__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)
689610
{
690611
struct thermal_cooling_device *cdev;
691612
struct cpufreq_cooling_device *cpufreq_cdev;
@@ -755,8 +676,6 @@ __cpufreq_cooling_register(struct device_node *np,
755676
}
756677

757678
if (capacitance) {
758-
cpufreq_cdev->plat_get_static_power = plat_static_func;
759-
760679
ret = update_freq_table(cpufreq_cdev, capacitance);
761680
if (ret) {
762681
cdev = ERR_PTR(ret);
@@ -813,7 +732,7 @@ __cpufreq_cooling_register(struct device_node *np,
813732
struct thermal_cooling_device *
814733
cpufreq_cooling_register(struct cpufreq_policy *policy)
815734
{
816-
return __cpufreq_cooling_register(NULL, policy, 0, NULL);
735+
return __cpufreq_cooling_register(NULL, policy, 0);
817736
}
818737
EXPORT_SYMBOL_GPL(cpufreq_cooling_register);
819738

@@ -853,8 +772,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy)
853772
of_property_read_u32(np, "dynamic-power-coefficient",
854773
&capacitance);
855774

856-
cdev = __cpufreq_cooling_register(np, policy, capacitance,
857-
NULL);
775+
cdev = __cpufreq_cooling_register(np, policy, capacitance);
858776
if (IS_ERR(cdev)) {
859777
pr_err("cpu_cooling: cpu%d is not running as cooling device: %ld\n",
860778
policy->cpu, PTR_ERR(cdev));

include/linux/cpu_cooling.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030

3131
struct cpufreq_policy;
3232

33-
typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
34-
unsigned long voltage, u32 *power);
35-
3633
#ifdef CONFIG_CPU_THERMAL
3734
/**
3835
* cpufreq_cooling_register - function to create cpufreq cooling device.

include/trace/events/thermal.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,16 @@ TRACE_EVENT(thermal_zone_trip,
9494
#ifdef CONFIG_CPU_THERMAL
9595
TRACE_EVENT(thermal_power_cpu_get_power,
9696
TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load,
97-
size_t load_len, u32 dynamic_power, u32 static_power),
97+
size_t load_len, u32 dynamic_power),
9898

99-
TP_ARGS(cpus, freq, load, load_len, dynamic_power, static_power),
99+
TP_ARGS(cpus, freq, load, load_len, dynamic_power),
100100

101101
TP_STRUCT__entry(
102102
__bitmask(cpumask, num_possible_cpus())
103103
__field(unsigned long, freq )
104104
__dynamic_array(u32, load, load_len)
105105
__field(size_t, load_len )
106106
__field(u32, dynamic_power )
107-
__field(u32, static_power )
108107
),
109108

110109
TP_fast_assign(
@@ -115,13 +114,12 @@ TRACE_EVENT(thermal_power_cpu_get_power,
115114
load_len * sizeof(*load));
116115
__entry->load_len = load_len;
117116
__entry->dynamic_power = dynamic_power;
118-
__entry->static_power = static_power;
119117
),
120118

121-
TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d static_power=%d",
119+
TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d",
122120
__get_bitmask(cpumask), __entry->freq,
123121
__print_array(__get_dynamic_array(load), __entry->load_len, 4),
124-
__entry->dynamic_power, __entry->static_power)
122+
__entry->dynamic_power)
125123
);
126124

127125
TRACE_EVENT(thermal_power_cpu_limit,

0 commit comments

Comments
 (0)