From: Santosh Shilimkar <santosh.shilimkar@ti.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "Premi, Sanjeev" <premi@ti.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Kevin Hilman <khilman@ti.com>
Subject: Re: [PATCHv2] omap2+: pm: cpufreq: Fix loops_per_jiffy calculation
Date: Fri, 24 Jun 2011 11:48:24 -0700 [thread overview]
Message-ID: <4E04DBF8.1050401@ti.com> (raw)
In-Reply-To: <20110624151201.GO9449@n2100.arm.linux.org.uk>
Russell,
On 6/24/2011 8:12 AM, Russell King - ARM Linux wrote:
> Right, thanks for the file. Here's the patch.
>
[.....]
> Notice how we adjust _both_ the per-cpu loops_per_jiffy, and that we
> adjust them with reference to the initial values.
>
> If you adjust lpj with reference to the last, then you _will_ build up
> a progressively bigger and bigger error in the value over time.
>
Thanks Russell for the change. This change should fix the global
lpj for UP machine as well when build with SMP_ON_UP.
Can you have a look at below complete change which should
make the BOGOMIPS happy on all OMAP2PLUS machines. Generated
against Kevin's cpufreq branch.
url =
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
pm-wip/cpufreq.
Just compile tested with UP and SMP OMAP builds. After your
review, I can give a test.
Regards
Santosh
From 9a6154c0f68e39c4d1fbc4ef3fef5ce577ba87d4 Mon Sep 17 00:00:00 2001
From: Russell King <rmk+kernel@arm.linux.org.uk>
Date: Fri, 24 Jun 2011 10:51:17 -0700
Subject: [PATCH] OMAP2+: CPUfreq: update lpj with refernce value to
avoid progressive error.
Adjust _both_ the per-cpu loops_per_jiffy and global lpj. Calibrate them
with with reference to the initial values to avoid a progressively
bigger and bigger error in the value over time.
While at this also re-use the notifiers for UP/SMP since on
UP machine or UP_ON_SMP policy->cpus mask would contain only
the one CPU.
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
[santosh.shilimkar@ti.com: rebased against omap cpufreq upstream branch]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/omap2plus-cpufreq.c | 48
+++++++++++++++++-------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c
b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 1f3b2e1..434698e 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -38,6 +38,16 @@
#include <mach/hardware.h>
+#ifdef CONFIG_SMP
+struct lpj_info {
+ unsigned long ref;
+ unsigned int freq;
+};
+
+static DEFINE_PER_CPU(struct lpj_info, lpj_ref);
+static struct lpj_info global_lpj_ref;
+#endif
+
static struct cpufreq_frequency_table *freq_table;
static atomic_t freq_table_users = ATOMIC_INIT(0);
static struct clk *mpu_clk;
@@ -96,11 +106,6 @@ static int omap_target(struct cpufreq_policy *policy,
if (freqs.old == freqs.new && policy->cur == freqs.new)
return ret;
- if (!is_smp()) {
- cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
- goto set_freq;
- }
-
/* notifiers */
for_each_cpu(i, policy->cpus) {
freqs.cpu = i;
@@ -114,19 +119,7 @@ set_freq:
ret = clk_set_rate(mpu_clk, freqs.new * 1000);
- /*
- * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
- * won't get updated when UP machine cpufreq build with
- * CONFIG_SMP enabled. Below code is added only to manage that
- * scenario
- */
freqs.new = omap_getspeed(policy->cpu);
- if (!is_smp()) {
- loops_per_jiffy =
- cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
- cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
- goto skip_lpj;
- }
#ifdef CONFIG_SMP
/*
@@ -134,10 +127,24 @@ set_freq:
* cpufreq driver. So, update the per-CPU loops_per_jiffy value
* on frequency transition. We need to update all dependent CPUs.
*/
- for_each_cpu(i, policy->cpus)
+ for_each_cpu(i, policy->cpus) {
+ struct lpj_info *lpj = &per_cpu(lpj_ref, i);
+ if (!lpj->freq) {
+ lpj->ref = per_cpu(cpu_data, i).loops_per_jiffy;
+ lpj->freq = freqs.old;
+ }
+
per_cpu(cpu_data, i).loops_per_jiffy =
- cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
- freqs.old, freqs.new);
+ cpufreq_scale(lpj->ref, lpj->freq, freqs.new);
+ }
+
+ /* And don't forget to adjust the global one */
+ if (!global_lpj_ref.freq) {
+ global_lpj_ref.ref = loops_per_jiffy;
+ global_lpj_ref.freq = freqs.old;
+ }
+ loops_per_jiffy = cpufreq_scale(global_lpj_ref.ref, global_lpj_ref.freq,
+ freqs.new);
#endif
/* notifiers */
@@ -146,7 +153,6 @@ set_freq:
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
}
-skip_lpj:
return ret;
}
--
1.7.4.1
WARNING: multiple messages have this Message-ID (diff)
From: santosh.shilimkar@ti.com (Santosh Shilimkar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2] omap2+: pm: cpufreq: Fix loops_per_jiffy calculation
Date: Fri, 24 Jun 2011 11:48:24 -0700 [thread overview]
Message-ID: <4E04DBF8.1050401@ti.com> (raw)
In-Reply-To: <20110624151201.GO9449@n2100.arm.linux.org.uk>
Russell,
On 6/24/2011 8:12 AM, Russell King - ARM Linux wrote:
> Right, thanks for the file. Here's the patch.
>
[.....]
> Notice how we adjust _both_ the per-cpu loops_per_jiffy, and that we
> adjust them with reference to the initial values.
>
> If you adjust lpj with reference to the last, then you _will_ build up
> a progressively bigger and bigger error in the value over time.
>
Thanks Russell for the change. This change should fix the global
lpj for UP machine as well when build with SMP_ON_UP.
Can you have a look at below complete change which should
make the BOGOMIPS happy on all OMAP2PLUS machines. Generated
against Kevin's cpufreq branch.
url =
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
pm-wip/cpufreq.
Just compile tested with UP and SMP OMAP builds. After your
review, I can give a test.
Regards
Santosh
From 9a6154c0f68e39c4d1fbc4ef3fef5ce577ba87d4 Mon Sep 17 00:00:00 2001
From: Russell King <rmk+kernel@arm.linux.org.uk>
Date: Fri, 24 Jun 2011 10:51:17 -0700
Subject: [PATCH] OMAP2+: CPUfreq: update lpj with refernce value to
avoid progressive error.
Adjust _both_ the per-cpu loops_per_jiffy and global lpj. Calibrate them
with with reference to the initial values to avoid a progressively
bigger and bigger error in the value over time.
While at this also re-use the notifiers for UP/SMP since on
UP machine or UP_ON_SMP policy->cpus mask would contain only
the one CPU.
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
[santosh.shilimkar at ti.com: rebased against omap cpufreq upstream branch]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/omap2plus-cpufreq.c | 48
+++++++++++++++++-------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c
b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 1f3b2e1..434698e 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -38,6 +38,16 @@
#include <mach/hardware.h>
+#ifdef CONFIG_SMP
+struct lpj_info {
+ unsigned long ref;
+ unsigned int freq;
+};
+
+static DEFINE_PER_CPU(struct lpj_info, lpj_ref);
+static struct lpj_info global_lpj_ref;
+#endif
+
static struct cpufreq_frequency_table *freq_table;
static atomic_t freq_table_users = ATOMIC_INIT(0);
static struct clk *mpu_clk;
@@ -96,11 +106,6 @@ static int omap_target(struct cpufreq_policy *policy,
if (freqs.old == freqs.new && policy->cur == freqs.new)
return ret;
- if (!is_smp()) {
- cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
- goto set_freq;
- }
-
/* notifiers */
for_each_cpu(i, policy->cpus) {
freqs.cpu = i;
@@ -114,19 +119,7 @@ set_freq:
ret = clk_set_rate(mpu_clk, freqs.new * 1000);
- /*
- * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
- * won't get updated when UP machine cpufreq build with
- * CONFIG_SMP enabled. Below code is added only to manage that
- * scenario
- */
freqs.new = omap_getspeed(policy->cpu);
- if (!is_smp()) {
- loops_per_jiffy =
- cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
- cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
- goto skip_lpj;
- }
#ifdef CONFIG_SMP
/*
@@ -134,10 +127,24 @@ set_freq:
* cpufreq driver. So, update the per-CPU loops_per_jiffy value
* on frequency transition. We need to update all dependent CPUs.
*/
- for_each_cpu(i, policy->cpus)
+ for_each_cpu(i, policy->cpus) {
+ struct lpj_info *lpj = &per_cpu(lpj_ref, i);
+ if (!lpj->freq) {
+ lpj->ref = per_cpu(cpu_data, i).loops_per_jiffy;
+ lpj->freq = freqs.old;
+ }
+
per_cpu(cpu_data, i).loops_per_jiffy =
- cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
- freqs.old, freqs.new);
+ cpufreq_scale(lpj->ref, lpj->freq, freqs.new);
+ }
+
+ /* And don't forget to adjust the global one */
+ if (!global_lpj_ref.freq) {
+ global_lpj_ref.ref = loops_per_jiffy;
+ global_lpj_ref.freq = freqs.old;
+ }
+ loops_per_jiffy = cpufreq_scale(global_lpj_ref.ref, global_lpj_ref.freq,
+ freqs.new);
#endif
/* notifiers */
@@ -146,7 +153,6 @@ set_freq:
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
}
-skip_lpj:
return ret;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-06-24 18:48 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 13:53 [PATCHv2] omap2+: pm: cpufreq: Fix loops_per_jiffy calculation Sanjeev Premi
2011-06-24 13:53 ` Sanjeev Premi
2011-06-24 13:59 ` Premi, Sanjeev
2011-06-24 13:59 ` Premi, Sanjeev
2011-06-24 14:01 ` Russell King - ARM Linux
2011-06-24 14:01 ` Russell King - ARM Linux
2011-06-24 14:09 ` Premi, Sanjeev
2011-06-24 14:09 ` Premi, Sanjeev
2011-06-24 14:14 ` Russell King - ARM Linux
2011-06-24 14:14 ` Russell King - ARM Linux
2011-06-24 15:12 ` Russell King - ARM Linux
2011-06-24 15:12 ` Russell King - ARM Linux
2011-06-24 15:34 ` Premi, Sanjeev
2011-06-24 15:34 ` Premi, Sanjeev
2011-06-24 17:50 ` Premi, Sanjeev
2011-06-24 17:50 ` Premi, Sanjeev
2011-06-24 18:51 ` Russell King - ARM Linux
2011-06-24 18:51 ` Russell King - ARM Linux
2011-06-24 20:14 ` Kevin Hilman
2011-06-24 20:14 ` Kevin Hilman
2011-06-25 16:20 ` Premi, Sanjeev
2011-06-25 16:20 ` Premi, Sanjeev
2011-06-24 18:48 ` Santosh Shilimkar [this message]
2011-06-24 18:48 ` Santosh Shilimkar
2011-06-25 18:53 ` Premi, Sanjeev
2011-06-25 18:53 ` Premi, Sanjeev
2011-06-25 19:09 ` Russell King - ARM Linux
2011-06-25 19:09 ` Russell King - ARM Linux
2011-06-27 4:54 ` Premi, Sanjeev
2011-06-27 4:54 ` Premi, Sanjeev
2011-06-27 7:40 ` Russell King - ARM Linux
2011-06-27 7:40 ` Russell King - ARM Linux
2011-06-24 14:35 ` Santosh Shilimkar
2011-06-24 14:35 ` Santosh Shilimkar
2011-06-24 14:40 ` Premi, Sanjeev
2011-06-24 14:40 ` Premi, Sanjeev
2011-06-24 14:47 ` Santosh Shilimkar
2011-06-24 14:47 ` Santosh Shilimkar
2011-06-28 22:29 ` Colin Cross
2011-06-28 22:29 ` Colin Cross
2011-06-28 22:45 ` Santosh Shilimkar
2011-06-28 22:45 ` Santosh Shilimkar
2011-06-28 22:56 ` Colin Cross
2011-06-28 22:56 ` Colin Cross
[not found] ` <CAMbhsRRctHC2wSi7cWjO2Fn_rM7=dMtTrt6PbsVehrgx9SKwzw@mail.gmail.com>
2011-06-28 23:00 ` Santosh Shilimkar
2011-06-28 23:00 ` Santosh Shilimkar
2011-06-28 23:04 ` Santosh Shilimkar
2011-06-28 23:04 ` Santosh Shilimkar
2011-06-28 23:03 ` Russell King - ARM Linux
2011-06-28 23:03 ` Russell King - ARM Linux
2011-06-28 23:07 ` Santosh Shilimkar
2011-06-28 23:07 ` Santosh Shilimkar
2011-06-28 22:55 ` Russell King - ARM Linux
2011-06-28 22:55 ` Russell King - ARM Linux
2011-06-28 22:58 ` Colin Cross
2011-06-28 22:58 ` Colin Cross
2011-06-28 23:17 ` Russell King - ARM Linux
2011-06-28 23:17 ` Russell King - ARM Linux
2011-06-28 23:37 ` Colin Cross
2011-06-28 23:37 ` Colin Cross
2011-06-28 23:46 ` Russell King - ARM Linux
2011-06-28 23:46 ` Russell King - ARM Linux
2011-06-28 23:59 ` Colin Cross
2011-06-28 23:59 ` Colin Cross
2011-06-29 14:00 ` Russell King - ARM Linux
2011-06-29 14:00 ` Russell King - ARM Linux
2011-06-29 16:57 ` Colin Cross
2011-06-29 16:57 ` Colin Cross
2011-06-29 18:29 ` Stephen Boyd
2011-06-29 18:29 ` Stephen Boyd
2011-06-29 18:43 ` Russell King - ARM Linux
2011-06-29 18:43 ` Russell King - ARM Linux
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=4E04DBF8.1050401@ti.com \
--to=santosh.shilimkar@ti.com \
--cc=khilman@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=premi@ti.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.