All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Javi Merino <javi.merino@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Amit Daniel Kachhap <amit.kachhap@gmail.com>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org,
	Rafael Wysocki <rjw@rjwysocki.net>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>
Subject: [PATCH V2 10/17] thermal: cpu_cooling: OPPs are registered for all CPUs
Date: Mon, 17 Apr 2017 11:31:55 +0530	[thread overview]
Message-ID: <b4328955153ba42daa5da3a5e4874199156df20e.1492408342.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1492408342.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1492408342.git.viresh.kumar@linaro.org>

The OPPs are registered for all CPUs of a cpufreq policy now and we
don't need to run the loop in build_dyn_power_table(). Just check for
the policy->cpu and we should be fine.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/thermal/cpu_cooling.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index bc018c628c93..3c6b63e7a257 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -83,7 +83,7 @@ struct power_table {
  * @dyn_power_table: array of struct power_table for frequency to power
  *	conversion, sorted in ascending order.
  * @dyn_power_table_entries: number of entries in the @dyn_power_table array
- * @cpu_dev: the first cpu_device from @allowed_cpus that has OPPs registered
+ * @cpu_dev: the cpu_device of policy->cpu.
  * @plat_get_static_power: callback to calculate the static power
  *
  * This structure is required for keeping information of each registered
@@ -207,24 +207,20 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_cdev,
 	struct power_table *power_table;
 	struct dev_pm_opp *opp;
 	struct device *dev = NULL;
-	int num_opps = 0, cpu, i, ret = 0;
+	int num_opps = 0, cpu = cpufreq_cdev->policy->cpu, i, ret = 0;
 	unsigned long freq;
 
-	for_each_cpu(cpu, &cpufreq_cdev->allowed_cpus) {
-		dev = get_cpu_device(cpu);
-		if (!dev) {
-			dev_warn(&cpufreq_cdev->cdev->device,
-				 "No cpu device for cpu %d\n", cpu);
-			continue;
-		}
-
-		num_opps = dev_pm_opp_get_opp_count(dev);
-		if (num_opps > 0)
-			break;
-		else if (num_opps < 0)
-			return num_opps;
+	dev = get_cpu_device(cpu);
+	if (unlikely(!dev)) {
+		dev_warn(&cpufreq_cdev->cdev->device,
+			 "No cpu device for cpu %d\n", cpu);
+		return -ENODEV;
 	}
 
+	num_opps = dev_pm_opp_get_opp_count(dev);
+	if (num_opps < 0)
+		return num_opps;
+
 	if (num_opps == 0)
 		return -EINVAL;
 
-- 
2.12.0.432.g71c3a4f4ba37

  parent reply	other threads:[~2017-04-17  6:05 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17  6:01 [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with cpufreq core Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 01/17] thermal: cpu_cooling: Avoid accessing potentially freed structures Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 02/17] thermal: cpu_cooling: rearrange globals Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 03/17] thermal: cpu_cooling: Name cpufreq cooling devices as cpufreq_cdev Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 04/17] thermal: cpu_cooling: replace cool_dev with cdev Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 05/17] thermal: cpu_cooling: remove cpufreq_cooling_get_level() Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 06/17] thermal: cpu_cooling: get rid of a variable in cpufreq_set_cur_state() Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 07/17] thermal: cpu_cooling: use cpufreq_policy to register cooling device Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 08/17] cpufreq: create cpufreq_table_count_valid_entries() Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 09/17] thermal: cpu_cooling: store cpufreq policy Viresh Kumar
2017-04-17  6:01 ` Viresh Kumar [this message]
2017-04-17  6:01 ` [PATCH V2 11/17] thermal: cpu_cooling: get rid of 'allowed_cpus' Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 12/17] thermal: cpu_cooling: merge frequency and power tables Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 13/17] thermal: cpu_cooling: create structure for idle time stats Viresh Kumar
2017-04-17  6:01 ` [PATCH V2 14/17] thermal: cpu_cooling: get_level() can't fail Viresh Kumar
2017-04-17  6:02 ` [PATCH V2 15/17] thermal: cpu_cooling: don't store cpu_dev in cpufreq_cdev Viresh Kumar
2017-04-17  6:02 ` [PATCH V2 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power() Viresh Kumar
2017-04-17  6:02 ` [PATCH V2 17/17] thermal: cpu_cooling: Rearrange struct cpufreq_cooling_device Viresh Kumar
2017-04-17 17:34 ` [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with cpufreq core Eduardo Valentin
2017-04-17 17:51   ` Eduardo Valentin
2017-04-18  7:23     ` Lukasz Luba
2017-04-18 10:38   ` Viresh Kumar
2017-04-18 14:40     ` Lukasz Luba
2017-04-18 14:51       ` [PATCH] thermal: fix cpu cooling initialization Lukasz Luba
2017-04-19  5:22       ` [PATCH V2 00/17] thermal: cpu_cooling: improve interaction with cpufreq core Viresh Kumar
2017-04-24 10:43         ` Lukasz Luba
2017-04-24 10:44           ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4328955153ba42daa5da3a5e4874199156df20e.1492408342.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=amit.kachhap@gmail.com \
    --cc=edubezval@gmail.com \
    --cc=javi.merino@kernel.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.