lkml.org 
[lkml]   [2017]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] thermal: fix cpu cooling initialization
This patch fixes issues with incorrect initialization
during cpu cooling registration.
The 'policy' and 'freq_table' must be initialized in cpufreq_cooling_device
before usage.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
drivers/thermal/cpu_cooling.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

This patch fixes some issues to the patch set posted by Viresh.
I have tested it on Juno r2.

Regards,
Lukasz

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 99ffd9f..c682e25 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -691,6 +691,9 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
struct thermal_cooling_device_ops *cooling_ops;
bool first;

+ if (WARN_ON(!policy))
+ return ERR_PTR(-EINVAL);
+
i = cpufreq_table_count_valid_entries(policy);
if (!i) {
pr_debug("%s: CPUFreq table not found or has no valid entries\n",
@@ -711,6 +714,7 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
goto free_cdev;
}

+ cpufreq_cdev->policy = policy;
/* max_level is an index, not a counter */
cpufreq_cdev->max_level = i - 1;

@@ -721,6 +725,18 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
goto free_idle_time;
}

+ /* Fill freq-table in descending order of frequencies */
+ for (i = 0, freq = -1; i <= cpufreq_cdev->max_level; i++) {
+ freq = find_next_max(policy->freq_table, freq);
+ cpufreq_cdev->freq_table[i].frequency = freq;
+
+ /* Warn for duplicate entries */
+ if (!freq)
+ pr_warn("%s: table has duplicate entries\n", __func__);
+ else
+ pr_debug("%s: freq:%u KHz\n", __func__, freq);
+ }
+
if (capacitance) {
cpufreq_cdev->plat_get_static_power = plat_static_func;

@@ -742,18 +758,6 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,
}
cpufreq_cdev->id = ret;

- /* Fill freq-table in descending order of frequencies */
- for (i = 0, freq = -1; i <= cpufreq_cdev->max_level; i++) {
- freq = find_next_max(policy->freq_table, freq);
- cpufreq_cdev->freq_table[i].frequency = freq;
-
- /* Warn for duplicate entries */
- if (!freq)
- pr_warn("%s: table has duplicate entries\n", __func__);
- else
- pr_debug("%s: freq:%u KHz\n", __func__, freq);
- }
-
snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
cpufreq_cdev->id);

--
1.9.1
\
 
 \ /
  Last update: 2017-04-18 16:52    [W:0.079 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site