From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/3] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp
Date: Fri, 10 Aug 2012 13:37:23 +0800 [thread overview]
Message-ID: <1344577046-14847-2-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1344577046-14847-1-git-send-email-shawn.guo@linaro.org>
From: Richard Zhao <richard.zhao@linaro.org>
If CONFIG_SMP, cpufreq skips loops_per_jiffy update, because different
arch has different per-cpu loops_per_jiffy definition.
Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
arch/arm/kernel/smp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index ebd8ad2..8e03567 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -25,6 +25,7 @@
#include <linux/percpu.h>
#include <linux/clockchips.h>
#include <linux/completion.h>
+#include <linux/cpufreq.h>
#include <linux/atomic.h>
#include <asm/cacheflush.h>
@@ -584,3 +585,56 @@ int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}
+
+#ifdef CONFIG_CPU_FREQ
+
+static DEFINE_PER_CPU(unsigned long, l_p_j_ref);
+static DEFINE_PER_CPU(unsigned long, l_p_j_ref_freq);
+static unsigned long global_l_p_j_ref;
+static unsigned long global_l_p_j_ref_freq;
+
+static int cpufreq_callback(struct notifier_block *nb,
+ unsigned long val, void *data)
+{
+ struct cpufreq_freqs *freq = data;
+ int cpu = freq->cpu;
+
+ if (freq->flags & CPUFREQ_CONST_LOOPS)
+ return NOTIFY_OK;
+
+ if (!per_cpu(l_p_j_ref, cpu)) {
+ per_cpu(l_p_j_ref, cpu) =
+ per_cpu(cpu_data, cpu).loops_per_jiffy;
+ per_cpu(l_p_j_ref_freq, cpu) = freq->old;
+ if (!global_l_p_j_ref) {
+ global_l_p_j_ref = loops_per_jiffy;
+ global_l_p_j_ref_freq = freq->old;
+ }
+ }
+
+ if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) ||
+ (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
+ (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
+ loops_per_jiffy = cpufreq_scale(global_l_p_j_ref,
+ global_l_p_j_ref_freq,
+ freq->new);
+ per_cpu(cpu_data, cpu).loops_per_jiffy =
+ cpufreq_scale(per_cpu(l_p_j_ref, cpu),
+ per_cpu(l_p_j_ref_freq, cpu),
+ freq->new);
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block cpufreq_notifier = {
+ .notifier_call = cpufreq_callback,
+};
+
+static int __init register_cpufreq_notifier(void)
+{
+ return cpufreq_register_notifier(&cpufreq_notifier,
+ CPUFREQ_TRANSITION_NOTIFIER);
+}
+core_initcall(register_cpufreq_notifier);
+
+#endif
--
1.7.5.4
next prev parent reply other threads:[~2012-08-10 5:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 5:37 [PATCH v3 0/3] Add a generic cpufreq-cpu0 driver Shawn Guo
2012-08-10 5:37 ` Shawn Guo [this message]
2012-09-04 23:27 ` [PATCH v3 1/3] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Rafael J. Wysocki
2012-09-06 22:35 ` Stephen Warren
2012-09-07 2:58 ` Shawn Guo
2012-09-07 16:55 ` Stephen Warren
2012-09-10 1:17 ` Shawn Guo
2012-09-10 17:17 ` Stephen Warren
2012-09-11 11:59 ` Prashant Gaikwad
2012-09-11 15:16 ` Stephen Warren
2012-08-10 5:37 ` [PATCH v3 2/3] PM / OPP: Initialize OPP table from device tree Shawn Guo
2012-08-16 21:05 ` Rafael J. Wysocki
2012-08-17 0:52 ` Shawn Guo
2012-08-17 1:53 ` Rob Herring
2012-09-04 23:27 ` Rafael J. Wysocki
2012-08-10 5:37 ` [PATCH v3 3/3] cpufreq: Add a generic cpufreq-cpu0 driver Shawn Guo
2012-09-04 23:18 ` Rafael J. Wysocki
2012-09-05 1:12 ` Shawn Guo
2012-09-05 4:53 ` AnilKumar, Chimata
2012-09-05 5:02 ` Shilimkar, Santosh
2012-09-05 13:38 ` Rafael J. Wysocki
2012-09-05 13:59 ` Shawn Guo
2012-09-05 20:18 ` Rafael J. Wysocki
2012-09-06 7:29 ` Shawn Guo
2012-09-06 19:59 ` Rafael J. Wysocki
2012-08-31 6:42 ` [PATCH v3 0/3] " Shawn Guo
2012-09-01 5:53 ` Rafael J. Wysocki
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=1344577046-14847-2-git-send-email-shawn.guo@linaro.org \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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 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).