All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: edubezval@gmail.com
Cc: linaro-kernel@lists.linaro.org, rui.zhang@intel.com,
	linux-pm@vger.kernel.org, radivoje.jovanovic@linux.intel.com,
	punit.agrawal@arm.com, Viresh Kumar <viresh.kumar@linaro.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 6/6] thermal/cpu_cooling: update policy limits if clipped_freq < policy->max
Date: Thu, 30 Jul 2015 12:40:35 +0530	[thread overview]
Message-ID: <5a3411e7341a4208d0d67c0c5ea2208a4c5ee658.1438239727.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1438239727.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1438239727.git.viresh.kumar@linaro.org>

policy->max is the maximum allowed frequency defined by user and
clipped_freq is the maximum that thermal constraints allow.

If clipped_freq is lower than policy->max, then we need to readjust
policy->max.

But, if clipped_freq is greater than policy->max, we don't need to do
anything. We used to call cpufreq_verify_within_limits() in this case,
but it doesn't change anything in this case.

Lets skip this unnecessary call and write a comment that explains this.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 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 9209c324a7fc..d9a603588cb5 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -226,9 +226,20 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
 		if (!cpumask_test_cpu(policy->cpu, &cpufreq_dev->allowed_cpus))
 			continue;
 
+		/*
+		 * policy->max is the maximum allowed frequency defined by user
+		 * and clipped_freq is the maximum that thermal constraints
+		 * allow.
+		 *
+		 * If clipped_freq is lower than policy->max, then we need to
+		 * readjust policy->max.
+		 *
+		 * But, if clipped_freq is greater than policy->max, we don't
+		 * need to do anything.
+		 */
 		clipped_freq = cpufreq_dev->clipped_freq;
 
-		if (policy->max != clipped_freq)
+		if (policy->max > clipped_freq)
 			cpufreq_verify_within_limits(policy, 0, clipped_freq);
 		break;
 	}
-- 
2.4.0


WARNING: multiple messages have this Message-ID (diff)
From: Viresh Kumar <viresh.kumar@linaro.org>
To: edubezval@gmail.com
Cc: linaro-kernel@lists.linaro.org, rui.zhang@intel.com,
	linux-pm@vger.kernel.org, radivoje.jovanovic@linux.intel.com,
	punit.agrawal@arm.com, Viresh Kumar <viresh.kumar@linaro.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: [PATCH 6/6] thermal/cpu_cooling: update policy limits if clipped_freq < policy->max
Date: Thu, 30 Jul 2015 12:40:35 +0530	[thread overview]
Message-ID: <5a3411e7341a4208d0d67c0c5ea2208a4c5ee658.1438239727.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1438239727.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1438239727.git.viresh.kumar@linaro.org>

policy->max is the maximum allowed frequency defined by user and
clipped_freq is the maximum that thermal constraints allow.

If clipped_freq is lower than policy->max, then we need to readjust
policy->max.

But, if clipped_freq is greater than policy->max, we don't need to do
anything. We used to call cpufreq_verify_within_limits() in this case,
but it doesn't change anything in this case.

Lets skip this unnecessary call and write a comment that explains this.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 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 9209c324a7fc..d9a603588cb5 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -226,9 +226,20 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
 		if (!cpumask_test_cpu(policy->cpu, &cpufreq_dev->allowed_cpus))
 			continue;
 
+		/*
+		 * policy->max is the maximum allowed frequency defined by user
+		 * and clipped_freq is the maximum that thermal constraints
+		 * allow.
+		 *
+		 * If clipped_freq is lower than policy->max, then we need to
+		 * readjust policy->max.
+		 *
+		 * But, if clipped_freq is greater than policy->max, we don't
+		 * need to do anything.
+		 */
 		clipped_freq = cpufreq_dev->clipped_freq;
 
-		if (policy->max != clipped_freq)
+		if (policy->max > clipped_freq)
 			cpufreq_verify_within_limits(policy, 0, clipped_freq);
 		break;
 	}
-- 
2.4.0

  parent reply	other threads:[~2015-07-30  7:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  7:10 [PATCH 0/6] thermal/cpu_cooling: Minor cleanups Viresh Kumar
2015-07-30  7:10 ` [PATCH 1/6] thermal/cpu_cooling: No need to initialize max_freq to 0 Viresh Kumar
2015-07-30  7:10   ` Viresh Kumar
2015-07-30  7:10 ` [PATCH 2/6] thermal/cpu_cooling: quit early after updating policy Viresh Kumar
2015-07-30  7:10   ` Viresh Kumar
2015-07-30  7:10 ` [PATCH 3/6] thermal/cpu_cooling: convert 'switch' block to 'if' block in notifier Viresh Kumar
2015-07-30  7:10   ` Viresh Kumar
2015-07-30  7:10 ` [PATCH 4/6] thermal/cpu_cooling: rename cpufreq_val as clipped_freq Viresh Kumar
2015-07-30  7:10   ` Viresh Kumar
2015-07-30  7:10 ` [PATCH 5/6] thermal/cpu_cooling: rename max_freq as clipped_freq in notifier Viresh Kumar
2015-07-30  7:10   ` Viresh Kumar
2015-07-30  7:10 ` Viresh Kumar [this message]
2015-07-30  7:10   ` [PATCH 6/6] thermal/cpu_cooling: update policy limits if clipped_freq < policy->max Viresh Kumar
2015-08-04  8:56 ` [PATCH 0/6] thermal/cpu_cooling: Minor cleanups Viresh Kumar
2015-08-12 10:17   ` Viresh Kumar
2015-08-14  4:59     ` Eduardo Valentin

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=5a3411e7341a4208d0d67c0c5ea2208a4c5ee658.1438239727.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=punit.agrawal@arm.com \
    --cc=radivoje.jovanovic@linux.intel.com \
    --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 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.