All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: kevin <khilman@ti.com>
Cc: linux-omap <linux-omap@vger.kernel.org>, Nishanth Menon <nm@ti.com>
Subject: [PM-WIP_CPUFREQ][PATCH 5/6 v2] OMAP2+: cpufreq: use cpufreq_frequency_table_target
Date: Wed, 18 May 2011 02:37:45 -0500	[thread overview]
Message-ID: <1305704266-17623-6-git-send-email-nm@ti.com> (raw)
In-Reply-To: <[PM-WIP_CPUFREQ][PATCH 0/5] Cleanups for cpufreq>

Use cpufreq_frequency_table_target for finding the proper target
instead of seeing if the frequency requested is divisible alone.
if we have a frequency table, we should restrict ourselves to
selecting the "approved" frequencies alone and only in the case
where the frequency table is not available should we attempt at
closest roundable clock frequency.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/omap2plus-cpufreq.c |   38 ++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 854f4b3..d0b4f97 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -77,24 +77,42 @@ static int omap_target(struct cpufreq_policy *policy,
 		       unsigned int target_freq,
 		       unsigned int relation)
 {
-	int i, ret = 0;
+	unsigned int i;
+	int ret = 0;
 	struct cpufreq_freqs freqs;
 
 	/* Changes not allowed until all CPUs are online */
 	if (is_smp() && (num_online_cpus() < NR_CPUS))
 		return ret;
 
-	/*
-	 * Ensure desired rate is within allowed range.  Some govenors
-	 * (ondemand) will just pass target_freq=0 to get the minimum.
-	 */
-	if (target_freq < policy->min)
-		target_freq = policy->min;
-	if (target_freq > policy->max)
-		target_freq = policy->max;
+	if (freq_table) {
+		ret = cpufreq_frequency_table_target(policy, freq_table,
+				target_freq, relation, &i);
+		if (ret) {
+			pr_debug("%s: cpu%d: no freq match for %d(ret=%d)\n",
+				__func__, policy->cpu, target_freq, ret);
+			return ret;
+		}
+		freqs.new = freq_table[i].frequency;
+	} else {
+		/*
+		 * Ensure desired rate is within allowed range. Some govenors
+		 * (ondemand) will just pass target_freq=0 to get the minimum.
+		 */
+		if (target_freq < policy->min)
+			target_freq = policy->min;
+		if (target_freq > policy->max)
+			target_freq = policy->max;
+
+		freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
+	}
+	if (!freqs.new) {
+		pr_err("%s: cpu%d: no match for freq %d\n", __func__,
+			policy->cpu, target_freq);
+		return -EINVAL;
+	}
 
 	freqs.old = omap_getspeed(policy->cpu);
-	freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
 	freqs.cpu = policy->cpu;
 
 	if (freqs.old == freqs.new)
-- 
1.7.1


  parent reply	other threads:[~2011-05-18  7:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <[PM-WIP_CPUFREQ][PATCH 0/5] Cleanups for cpufreq>
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 0/6 v2] Cleanups for cpufreq Nishanth Menon
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 1/6 v2] OMAP2+: cpufreq: free up table on exit Nishanth Menon
2011-05-19 10:26   ` Kevin Hilman
2011-05-19 13:48     ` Menon, Nishanth
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 2/6 v2] OMAP2+: cpufreq: handle invalid cpufreq table Nishanth Menon
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 3/6 v2] OMAP2+: cpufreq: minor comment cleanup Nishanth Menon
2011-05-18 20:08   ` Todd Poynor
2011-05-18 20:34     ` Menon, Nishanth
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 4/6 v2] OMAP2: cpufreq: use clk_init_cpufreq_table if OPPs not available Nishanth Menon
2011-05-19 13:12   ` Kevin Hilman
2011-05-19 13:51     ` Menon, Nishanth
2011-05-25  0:01       ` Kevin Hilman
2011-05-25  7:44         ` Menon, Nishanth
2011-05-18  7:37 ` Nishanth Menon [this message]
2011-05-18  7:37 ` [PM-WIP_CPUFREQ][PATCH 6/6 v2] OMAP2+: cpufreq: fix freq_table leak Nishanth Menon

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=1305704266-17623-6-git-send-email-nm@ti.com \
    --to=nm@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-omap@vger.kernel.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.