All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shawn Guo <shawn.guo@linaro.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Kevin Hilman <khilman@ti.com>, Nishanth Menon <nm@ti.com>,
	Richard Zhao <richard.zhao@freescale.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Mike Turquette <mturquette@linaro.org>,
	devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	cpufreq@vger.kernel.org, Richard Zhao <richard.zhao@linaro.org>
Subject: [PATCH 1/3] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp
Date: Thu, 19 Jul 2012 23:54:39 +0800	[thread overview]
Message-ID: <1342713281-31114-2-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1342713281-31114-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>
---
 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 2c7217d..83412d2 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>
@@ -583,3 +584,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



WARNING: multiple messages have this Message-ID (diff)
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp
Date: Thu, 19 Jul 2012 23:54:39 +0800	[thread overview]
Message-ID: <1342713281-31114-2-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1342713281-31114-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>
---
 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 2c7217d..83412d2 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>
@@ -583,3 +584,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

  reply	other threads:[~2012-07-19 15:54 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 15:54 [PATCH 0/3] Add a generic cpufreq-cpu0 driver Shawn Guo
2012-07-19 15:54 ` Shawn Guo
2012-07-19 15:54 ` Shawn Guo [this message]
2012-07-19 15:54   ` [PATCH 1/3] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Shawn Guo
2012-07-20  6:36   ` Shilimkar, Santosh
2012-07-20  6:36     ` Shilimkar, Santosh
2012-07-20  7:56     ` Shawn Guo
2012-07-20  7:56       ` Shawn Guo
2012-07-20  8:27       ` Shilimkar, Santosh
2012-07-20  8:27         ` Shilimkar, Santosh
2012-07-19 15:54 ` [PATCH 2/3] PM / OPP: Initialize OPP table from device tree Shawn Guo
2012-07-19 15:54   ` Shawn Guo
2012-07-20  6:00   ` Menon, Nishanth
2012-07-20  6:00     ` Menon, Nishanth
2012-07-20  8:46     ` Shawn Guo
2012-07-20  8:46       ` Shawn Guo
2012-07-20  9:04       ` Menon, Nishanth
2012-07-20  9:04         ` Menon, Nishanth
2012-07-19 15:54 ` [PATCH 3/3] cpufreq: Add a generic cpufreq-cpu0 driver Shawn Guo
2012-07-19 15:54   ` Shawn Guo
2012-07-20  6:52   ` Shilimkar, Santosh
2012-07-20  6:52     ` Shilimkar, Santosh
     [not found]     ` <CAMQu2gw32LogXJJa+K5ZjmCZzBNK3FY2wYwZXU8fsftsVzEO2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-20 12:33       ` Shawn Guo
2012-07-20 12:33         ` Shawn Guo
2012-07-20 15:50         ` Turquette, Mike
2012-07-20 15:50           ` Turquette, Mike
2012-07-21  5:04           ` Shilimkar, Santosh
2012-07-21  5:04             ` Shilimkar, Santosh
2012-07-21  6:38             ` Shawn Guo
2012-07-21  6:38               ` Shawn Guo
2012-07-27  2:04               ` Richard Zhao
2012-07-27  2:04                 ` Richard Zhao
2012-07-30  4:57                 ` Shawn Guo
2012-07-30  4:57                   ` Shawn Guo
2012-07-20 12:51   ` Richard Zhao
2012-07-20 12:51     ` Richard Zhao
2012-07-20 13:15     ` Shawn Guo
2012-07-20 13:15       ` Shawn Guo
     [not found]   ` <1342713281-31114-4-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-07-26 13:11     ` Mark Brown
2012-07-26 13:11       ` Mark Brown
     [not found]       ` <20120726131121.GB7306-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-27  2:13         ` Richard Zhao
2012-07-27  2:13           ` Richard Zhao
2012-07-27 10:08           ` Mark Brown
2012-07-27 10:08             ` Mark Brown
2012-07-30  6:52       ` Shawn Guo
2012-07-30  6:52         ` Shawn Guo
2012-07-30  8:20         ` Shawn Guo
2012-07-30  8:20           ` Shawn Guo
2012-07-30 18:55           ` Mark Brown
2012-07-30 18:55             ` Mark Brown
2012-07-30 18:53         ` Mark Brown
2012-07-30 18:53           ` Mark Brown
2012-07-31  4:20           ` Shawn Guo
2012-07-31  4:20             ` Shawn Guo
2012-07-31 13:40             ` Mark Brown
2012-07-31 13:40               ` Mark Brown
2012-07-27  6:33   ` Richard Zhao
2012-07-27  6:33     ` Richard Zhao
2012-07-30  8:17     ` Shawn Guo
2012-07-30  8:17       ` Shawn Guo
2012-07-30  8:50       ` Richard Zhao
2012-07-30  8:50         ` Richard Zhao
2012-07-30  9:24         ` Shawn Guo
2012-07-30  9:24           ` Shawn Guo
2012-07-19 18:39 ` [PATCH 0/3] " Rafael J. Wysocki
2012-07-19 18:39   ` Rafael J. Wysocki
2012-07-20  0:29   ` Shawn Guo
2012-07-20  0:29     ` Shawn Guo

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=1342713281-31114-2-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@linaro.org \
    --cc=nm@ti.com \
    --cc=richard.zhao@freescale.com \
    --cc=richard.zhao@linaro.org \
    --cc=rjw@sisk.pl \
    /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.