summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2018-04-09 15:22:36 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2018-04-09 15:22:36 +0200
commitf125db1dd49449cec7d72138579dd5cda514ddaa (patch)
tree63f0ca8777be5422caef692267f6697a6d033201
parentc043d2d61a23fd866066dd002ee2e79a37d7b28e (diff)
Change opp at compute capacity equalitythermal/idle-inject-combo-v3-v4.15-rc2
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--drivers/thermal/cpu_cooling.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index b0365415e575..653d5b739408 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -1663,8 +1663,39 @@ static int cpu_cooling_set_cur_state(struct thermal_cooling_device *cdev,
*/
opp_power = cpufreq_cdev->freq_table[opp_index].power * num_cpus;
- idle_state = ((opp_power - power) * 100) / power;
+ idle_state = ((opp_power - power) * 100) / opp_power;
+ pr_info("State=%lu, max power=%u, requested power=%u, opp(%d) power=%u, idle ratio=%d\n",
+ state, cpu_cdev->max_power, power, opp_index, opp_power, idle_state);
+
+ /*
+ * Compute the capacity of the cluster based on the ratio
+ * busy/idle and the current OPP's capacity
+ */
+ if (idle_state) {
+ u32 opp_capacity = cpufreq_cdev->freq_table[opp_index].capacity;
+ u32 below_opp_capacity = cpufreq_cdev->freq_table[opp_index + 1].capacity;
+ u32 capacity = ((opp_capacity * (100 - idle_state)) / 100);
+
+ pr_info("Opp capacity=%u, idle inject capacity=%u, below opp capacity=%u\n",
+ opp_capacity, capacity, below_opp_capacity);
+
+ if (!capacity)
+ pr_warning("Capacity is zero\n");
+ else {
+ /*
+ * At this point, it is not worth to stay at
+ * this level of OPP, as the capacity is less
+ * or equal of the OPP below, go to the lower
+ * OPP and reset the idle state_ratio
+ */
+ if (capacity <= below_opp_capacity) {
+ idle_state = 0;
+ opp_index++;
+ }
+ }
+ }
+
/*
* Catch unexpected situation where we are out of bound of the
* idle state percentage values.