Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625379

[PATCH] thermal: fix cpu cooling initialization

From Lukasz Luba <lukasz.luba@arm.com>
Newsgroups linux.kernel
Subject [PATCH] thermal: fix cpu cooling initialization
Date 2017-04-18 17:00 +0200
Message-ID <txCLL-7nt-27@gated-at.bofh.it> (permalink)
References <tx81j-5DY-3@gated-at.bofh.it> <txiN3-3w9-11@gated-at.bofh.it> <txyIa-54q-13@gated-at.bofh.it> <txCC6-7kc-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 00/17] thermal: cpu_cooling: improve interaction with cpufreq core Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 06/17] thermal: cpu_cooling: get rid of a variable in cpufreq_set_cur_state() Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 09/17] thermal: cpu_cooling: store cpufreq policy Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 07/17] thermal: cpu_cooling: use cpufreq_policy to register cooling device Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 04/17] thermal: cpu_cooling: replace cool_dev with cdev Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 10/17] thermal: cpu_cooling: OPPs are registered for all CPUs Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 02/17] thermal: cpu_cooling: rearrange globals Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  [PATCH V2 12/17] thermal: cpu_cooling: merge frequency and power tables Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-17 08:10 +0200
  Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Eduardo Valentin <edubezval@gmail.com> - 2017-04-17 19:40 +0200
    Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Eduardo Valentin <edubezval@gmail.com> - 2017-04-17 20:00 +0200
      Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Lukasz Luba <lukasz.luba@arm.com> - 2017-04-18 09:30 +0200
    Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-18 12:40 +0200
      Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Lukasz Luba <lukasz.luba@arm.com> - 2017-04-18 16:50 +0200
        [PATCH] thermal: fix cpu cooling initialization Lukasz Luba <lukasz.luba@arm.com> - 2017-04-18 17:00 +0200
        Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-19 07:30 +0200
          Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-24 12:50 +0200
          Re: [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with  cpufreq core Lukasz Luba <lukasz.luba@arm.com> - 2017-04-24 12:50 +0200

csiph-web