linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kapileshwar Singh <kapileshwar.singh@arm.com>
To: linux-pm@vger.kernel.org
Cc: edubezval@gmail.com, rui.zhang@intel.com, Javi.Merino@arm.com,
	Punit.Agrawal@arm.com, kapileshwar.singh@arm.com
Subject: [PATCH v2 2/2] thermal: cpu_cooling: Fix power calculation when CPUs are offline
Date: Mon, 16 Mar 2015 12:00:51 +0000	[thread overview]
Message-ID: <1426507251-26613-3-git-send-email-kapileshwar.singh@arm.com> (raw)
In-Reply-To: <1426507251-26613-1-git-send-email-kapileshwar.singh@arm.com>

Ensure that the CPU for which the frequency is being requested
is online. If none of the CPUs are online the requested power is
returned as 0.

Acked-by: Javi Merino <javi.merino@arm.com>
Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com>
---
 drivers/thermal/cpu_cooling.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 2e15133b4793..07a9629edf4b 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -555,7 +555,18 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
 	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
 	u32 *load_cpu = NULL;
 
-	freq = cpufreq_quick_get(cpumask_any(&cpufreq_device->allowed_cpus));
+	cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask);
+
+	/*
+	 * All the CPUs are offline, thus the requested power by
+	 * the cdev is 0
+	 */
+	if (cpu >= nr_cpu_ids) {
+		*power = 0;
+		return 0;
+	}
+
+	freq = cpufreq_quick_get(cpu);
 
 	if (trace_thermal_power_cpu_get_power_enabled()) {
 		u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus);
-- 
1.7.9.5


  parent reply	other threads:[~2015-03-16 12:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 12:00 thermal: cpu_cooling: Power calculation when CPUs are hotplugged Kapileshwar Singh
2015-03-16 12:00 ` [PATCH v2 1/2] thermal: cpu_cooling: Remove cpu_dev update on policy CPU update Kapileshwar Singh
2015-03-16 12:00 ` Kapileshwar Singh [this message]
2015-03-25 15:55 ` thermal: cpu_cooling: Power calculation when CPUs are hotplugged Kapileshwar Singh

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=1426507251-26613-3-git-send-email-kapileshwar.singh@arm.com \
    --to=kapileshwar.singh@arm.com \
    --cc=Javi.Merino@arm.com \
    --cc=Punit.Agrawal@arm.com \
    --cc=edubezval@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).