All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: rjw@sisk.pl
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Eric Miao <eric.y.miao@gmail.com>
Subject: [PATCH 26/34] cpufreq: pxa: remove calls to cpufreq_notify_transition()
Date: Fri, 16 Aug 2013 07:55:23 +0530	[thread overview]
Message-ID: <28fce5fee42ed283ec0d176c2e7be41e4eca79a4.1376619363.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1376619363.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1376619363.git.viresh.kumar@linaro.org>

Most of the drivers do following in their ->target_index() routines:

	struct cpufreq_freqs freqs;
	freqs.old = old freq...
	freqs.new = new freq...

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

	/* Change rate here */

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

This is replicated over all cpufreq drivers today and there doesn't exists a
good enough reason why this shouldn't be moved to cpufreq core instead.

Earlier patches have added support in cpufreq core to do cpufreq notification on
frequency change, this one removes it from this driver.

Some related minor cleanups are also done along with it.

Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 27 ++++++---------------------
 drivers/cpufreq/pxa3xx-cpufreq.c | 12 ------------
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 183bc13..0a0f436 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -271,7 +271,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
 	struct cpufreq_frequency_table *pxa_freqs_table;
 	pxa_freqs_t *pxa_freq_settings;
-	struct cpufreq_freqs freqs;
 	unsigned long flags;
 	unsigned int new_freq_cpu, new_freq_mem;
 	unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -282,24 +281,17 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 
 	new_freq_cpu = pxa_freq_settings[idx].khz;
 	new_freq_mem = pxa_freq_settings[idx].membus;
-	freqs.old = policy->cur;
-	freqs.new = new_freq_cpu;
 
 	if (freq_debug)
 		pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n",
-			 freqs.new / 1000, (pxa_freq_settings[idx].div2) ?
+			 new_freq_cpu / 1000, (pxa_freq_settings[idx].div2) ?
 			 (new_freq_mem / 2000) : (new_freq_mem / 1000));
 
-	if (vcc_core && freqs.new > freqs.old)
+	if (vcc_core && new_freq_cpu > policy->cur) {
 		ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);
-	if (ret)
-		return ret;
-	/*
-	 * Tell everyone what we're about to do...
-	 * you should add a notify client with any platform specific
-	 * Vcc changing capability
-	 */
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+		if (ret)
+			return ret;
+	}
 
 	/* Calculate the next MDREFR.  If we're slowing down the SDRAM clock
 	 * we need to preset the smaller DRI before the change.	 If we're
@@ -350,13 +342,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 	local_irq_restore(flags);
 
 	/*
-	 * Tell everyone what we've just done...
-	 * you should add a notify client with any platform specific
-	 * SDRAM refresh timer adjustments
-	 */
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
-	/*
 	 * Even if voltage setting fails, we don't report it, as the frequency
 	 * change succeeded. The voltage reduction is not a critical failure,
 	 * only power savings will suffer from this.
@@ -365,7 +350,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 	 * bug is triggered (seems a deadlock). Should anybody find out where,
 	 * the "return 0" should become a "return ret".
 	 */
-	if (vcc_core && freqs.new < freqs.old)
+	if (vcc_core && new_freq_cpu < policy->cur)
 		ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);
 
 	return 0;
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 132e37d..9384004 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -158,7 +158,6 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
 static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
 {
 	struct pxa3xx_freq_info *next;
-	struct cpufreq_freqs freqs;
 	unsigned long flags;
 
 	if (policy->cpu != 0)
@@ -166,22 +165,11 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
 
 	next = &pxa3xx_freqs[index];
 
-	freqs.old = policy->cur;
-	freqs.new = next->cpufreq_mhz * 1000;
-
-	pr_debug("CPU frequency from %d MHz to %d MHz%s\n",
-			freqs.old / 1000, freqs.new / 1000,
-			(freqs.old == freqs.new) ? " (skipped)" : "");
-
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
 	local_irq_save(flags);
 	__update_core_freq(next);
 	__update_bus_freq(next);
 	local_irq_restore(flags);
 
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
 	return 0;
 }
 
-- 
1.7.12.rc2.18.g61b472e


WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 26/34] cpufreq: pxa: remove calls to cpufreq_notify_transition()
Date: Fri, 16 Aug 2013 07:55:23 +0530	[thread overview]
Message-ID: <28fce5fee42ed283ec0d176c2e7be41e4eca79a4.1376619363.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1376619363.git.viresh.kumar@linaro.org>

Most of the drivers do following in their ->target_index() routines:

	struct cpufreq_freqs freqs;
	freqs.old = old freq...
	freqs.new = new freq...

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

	/* Change rate here */

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

This is replicated over all cpufreq drivers today and there doesn't exists a
good enough reason why this shouldn't be moved to cpufreq core instead.

Earlier patches have added support in cpufreq core to do cpufreq notification on
frequency change, this one removes it from this driver.

Some related minor cleanups are also done along with it.

Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 27 ++++++---------------------
 drivers/cpufreq/pxa3xx-cpufreq.c | 12 ------------
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 183bc13..0a0f436 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -271,7 +271,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
 	struct cpufreq_frequency_table *pxa_freqs_table;
 	pxa_freqs_t *pxa_freq_settings;
-	struct cpufreq_freqs freqs;
 	unsigned long flags;
 	unsigned int new_freq_cpu, new_freq_mem;
 	unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -282,24 +281,17 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 
 	new_freq_cpu = pxa_freq_settings[idx].khz;
 	new_freq_mem = pxa_freq_settings[idx].membus;
-	freqs.old = policy->cur;
-	freqs.new = new_freq_cpu;
 
 	if (freq_debug)
 		pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n",
-			 freqs.new / 1000, (pxa_freq_settings[idx].div2) ?
+			 new_freq_cpu / 1000, (pxa_freq_settings[idx].div2) ?
 			 (new_freq_mem / 2000) : (new_freq_mem / 1000));
 
-	if (vcc_core && freqs.new > freqs.old)
+	if (vcc_core && new_freq_cpu > policy->cur) {
 		ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);
-	if (ret)
-		return ret;
-	/*
-	 * Tell everyone what we're about to do...
-	 * you should add a notify client with any platform specific
-	 * Vcc changing capability
-	 */
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+		if (ret)
+			return ret;
+	}
 
 	/* Calculate the next MDREFR.  If we're slowing down the SDRAM clock
 	 * we need to preset the smaller DRI before the change.	 If we're
@@ -350,13 +342,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 	local_irq_restore(flags);
 
 	/*
-	 * Tell everyone what we've just done...
-	 * you should add a notify client with any platform specific
-	 * SDRAM refresh timer adjustments
-	 */
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
-	/*
 	 * Even if voltage setting fails, we don't report it, as the frequency
 	 * change succeeded. The voltage reduction is not a critical failure,
 	 * only power savings will suffer from this.
@@ -365,7 +350,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 	 * bug is triggered (seems a deadlock). Should anybody find out where,
 	 * the "return 0" should become a "return ret".
 	 */
-	if (vcc_core && freqs.new < freqs.old)
+	if (vcc_core && new_freq_cpu < policy->cur)
 		ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);
 
 	return 0;
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 132e37d..9384004 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -158,7 +158,6 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
 static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
 {
 	struct pxa3xx_freq_info *next;
-	struct cpufreq_freqs freqs;
 	unsigned long flags;
 
 	if (policy->cpu != 0)
@@ -166,22 +165,11 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
 
 	next = &pxa3xx_freqs[index];
 
-	freqs.old = policy->cur;
-	freqs.new = next->cpufreq_mhz * 1000;
-
-	pr_debug("CPU frequency from %d MHz to %d MHz%s\n",
-			freqs.old / 1000, freqs.new / 1000,
-			(freqs.old == freqs.new) ? " (skipped)" : "");
-
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
 	local_irq_save(flags);
 	__update_core_freq(next);
 	__update_bus_freq(next);
 	local_irq_restore(flags);
 
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
 	return 0;
 }
 
-- 
1.7.12.rc2.18.g61b472e

  parent reply	other threads:[~2013-08-16  2:29 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  2:24 [PATCH 00/34] CPUFreq: Move freq change notifications out of drivers Viresh Kumar
2013-08-16  2:36 ` Viresh Kumar
2013-08-16  2:24 ` Viresh Kumar
2013-08-16  2:24 ` Viresh Kumar
2013-08-16  2:24 ` [PATCH 01/34] cpufreq: move freq change notifications to cpufreq core Viresh Kumar
2013-08-16  2:36   ` Viresh Kumar
2013-08-16  2:24   ` Viresh Kumar
2013-08-16  2:24   ` Viresh Kumar
2013-08-16  2:24 ` [PATCH 02/34] cpufreq: acpi: remove calls to cpufreq_notify_transition() Viresh Kumar
2013-08-16  2:24   ` Viresh Kumar
     [not found]   ` <CAOLK0pz7e8nQVnZY0a-j_Fd_kFOqF8ZS4tRfYw1S+25Lv8GoFQ@mail.gmail.com>
     [not found]     ` <CAOLK0pyVDSc6x1u8Ro6ng1dH8ELqc3P9jPHamgiXBn6sWDgm8w@mail.gmail.com>
2013-08-16  7:59       ` Viresh Kumar
2013-08-16  7:59         ` Viresh Kumar
2013-08-16  7:59         ` Viresh Kumar
2013-08-16 15:30         ` Lan Tianyu
2013-08-16 15:30           ` Lan Tianyu
2013-08-16 15:30           ` Lan Tianyu
2013-08-16  2:25 ` [PATCH 03/34] cpufreq: arm_big_little: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 04/34] cpufreq: at32ap: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  5:58   ` Hans-Christian Egtvedt
2013-08-16  5:58     ` Hans-Christian Egtvedt
2013-08-16  2:25 ` [PATCH 05/34] cpufreq: blackfin: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 06/34] cpufreq: cpu0: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 07/34] cpufreq: cris: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2017-10-10  7:57   ` Jesper Nilsson
2017-10-10  7:57     ` Jesper Nilsson
2017-10-10  7:57     ` Jesper Nilsson
2017-10-10  9:13     ` Viresh Kumar
2017-10-10  9:13       ` Viresh Kumar
2017-10-10  9:13       ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 08/34] cpufreq: davinci: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 09/34] cpufreq: dbx500: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 10/34] cpufreq: e_powersaver: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 11/34] cpufreq: elanfreq: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 12/34] cpufreq: exynos: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 13/34] cpufreq: exynos5440: set CPUFREQ_NO_NOTIFICATION flag Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-18 10:54   ` amit daniel kachhap
2013-08-18 10:54     ` amit daniel kachhap
2013-08-18 21:57     ` Kukjin Kim
2013-08-18 21:57       ` Kukjin Kim
2013-08-19  3:42     ` amit daniel kachhap
2013-08-19  3:42       ` amit daniel kachhap
2013-08-19  4:40       ` Viresh Kumar
2013-08-19  4:40         ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 14/34] cpufreq: ia64-acpi: remove calls to cpufreq_notify_transition() Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 15/34] cpufreq: imx6q: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 16/34] cpufreq: kirkwood: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 17/34] cpufreq: longhaul: set CPUFREQ_NO_NOTIFICATION flag Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 18/34] cpufreq: loongson2: remove calls to cpufreq_notify_transition() Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 19/34] cpufreq: maple: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 20/34] cpufreq: omap: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 21/34] cpufreq: p4-clockmod: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 22/34] cpufreq: pasemi: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 23/34] cpufreq: pmac: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 24/34] cpufreq: powernow: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 25/34] cpufreq: ppc: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` Viresh Kumar [this message]
2013-08-16  2:25   ` [PATCH 26/34] cpufreq: pxa: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 27/34] cpufreq: s3c: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 28/34] cpufreq: s5pv210: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 29/34] cpufreq: sa11x0: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 30/34] cpufreq: sc520: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 31/34] cpufreq: sparc: " Viresh Kumar
2013-08-16  2:37   ` Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 32/34] cpufreq: SPEAr: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 33/34] cpufreq: speedstep: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 34/34] cpufreq: tegra: " Viresh Kumar
2013-08-16  2:25   ` Viresh Kumar

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=28fce5fee42ed283ec0d176c2e7be41e4eca79a4.1376619363.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=eric.y.miao@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@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.