linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: rjw@sisk.pl, daniel.lezcano@linaro.org
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH V2 15/16] cpuidle: don't call poll_idle_init() for every cpu
Date: Thu,  3 Oct 2013 21:26:54 +0530	[thread overview]
Message-ID: <ee9b99a281df92e71b75ff786336a54b5f9b428e.1380815504.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1380815504.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1380815504.git.viresh.kumar@linaro.org>

poll_idle_init() just initializes drv->states[0] and so that is required to be
done only once for each driver. Currently it is called from
cpuidle_enable_device() which is called for every CPU that the driver supports.
And that is not required. Move it to a better place and call it from
__cpuidle_register_driver() so that it is initialized only once.

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpuidle/cpuidle.c | 41 -----------------------------------------
 drivers/cpuidle/driver.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 1a6e9f5..1caf95d 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -227,45 +227,6 @@ void cpuidle_resume(void)
 	mutex_unlock(&cpuidle_lock);
 }
 
-#ifdef CONFIG_ARCH_HAS_CPU_RELAX
-static int poll_idle(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index)
-{
-	ktime_t	t1, t2;
-	s64 diff;
-
-	t1 = ktime_get();
-	local_irq_enable();
-	while (!need_resched())
-		cpu_relax();
-
-	t2 = ktime_get();
-	diff = ktime_to_us(ktime_sub(t2, t1));
-	if (diff > INT_MAX)
-		diff = INT_MAX;
-
-	dev->last_residency = (int) diff;
-
-	return index;
-}
-
-static void poll_idle_init(struct cpuidle_driver *drv)
-{
-	struct cpuidle_state *state = &drv->states[0];
-
-	snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
-	snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
-	state->exit_latency = 0;
-	state->target_residency = 0;
-	state->power_usage = -1;
-	state->flags = 0;
-	state->enter = poll_idle;
-	state->disabled = false;
-}
-#else
-static void poll_idle_init(struct cpuidle_driver *drv) {}
-#endif /* CONFIG_ARCH_HAS_CPU_RELAX */
-
 /**
  * cpuidle_enable_device - enables idle PM for a CPU
  * @dev: the CPU
@@ -295,8 +256,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 	if (!dev->state_count)
 		dev->state_count = drv->state_count;
 
-	poll_idle_init(drv);
-
 	ret = cpuidle_add_device_sysfs(dev);
 	if (ret)
 		return ret;
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 662d934..d5b5294 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -10,6 +10,7 @@
 
 #include <linux/mutex.h>
 #include <linux/module.h>
+#include <linux/sched.h>
 #include <linux/cpuidle.h>
 #include <linux/cpumask.h>
 #include <linux/clockchips.h>
@@ -177,6 +178,45 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv)
 	}
 }
 
+#ifdef CONFIG_ARCH_HAS_CPU_RELAX
+static int poll_idle(struct cpuidle_device *dev,
+		struct cpuidle_driver *drv, int index)
+{
+	ktime_t	t1, t2;
+	s64 diff;
+
+	t1 = ktime_get();
+	local_irq_enable();
+	while (!need_resched())
+		cpu_relax();
+
+	t2 = ktime_get();
+	diff = ktime_to_us(ktime_sub(t2, t1));
+	if (diff > INT_MAX)
+		diff = INT_MAX;
+
+	dev->last_residency = (int) diff;
+
+	return index;
+}
+
+static void poll_idle_init(struct cpuidle_driver *drv)
+{
+	struct cpuidle_state *state = &drv->states[0];
+
+	snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
+	snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
+	state->exit_latency = 0;
+	state->target_residency = 0;
+	state->power_usage = -1;
+	state->flags = 0;
+	state->enter = poll_idle;
+	state->disabled = false;
+}
+#else
+static void poll_idle_init(struct cpuidle_driver *drv) {}
+#endif /* !CONFIG_ARCH_HAS_CPU_RELAX */
+
 /**
  * __cpuidle_register_driver: register the driver
  * @drv: a valid pointer to a struct cpuidle_driver
@@ -210,6 +250,8 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
 		on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer,
 				 (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1);
 
+	poll_idle_init(drv);
+
 	return 0;
 }
 
-- 
1.7.12.rc2.18.g61b472e

  parent reply	other threads:[~2013-10-03 15:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03 15:56 [PATCH V2 00/16] CPUIdle: Minor cleanups for 3.13 Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 01/16] cpuidle: fix indentation of cpumask Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 02/16] cpuidle: Fix comments in cpuidle core Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 03/16] cpuidle: make __cpuidle_get_cpu_driver() inline Viresh Kumar
2013-10-03 20:14   ` Paul Walmsley
2013-10-03 15:56 ` [PATCH V2 04/16] cpuidle: make __cpuidle_device_init() return void Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 05/16] cpuidle: make __cpuidle_driver_init() " Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 06/16] cpuidle: rearrange code in __cpuidle_driver_init() Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 07/16] cpuidle: rearrange __cpuidle_register_device() to keep minimal exit points Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 08/16] cpuidle: merge two if() statements for checking error cases Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 09/16] cpuidle: reduce code duplication inside cpuidle_idle_call() Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 10/16] cpuidle: replace multiline statements with single line in cpuidle_idle_call() Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 11/16] cpuidle: call cpuidle_get_driver() from after taking cpuidle_driver_lock Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 12/16] cpuidle: use drv instead of cpuidle_driver in show_current_driver() Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 13/16] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Viresh Kumar
2013-11-20  8:03   ` Viresh Kumar
2013-11-20  8:03     ` Viresh Kumar
2013-11-21  1:05       ` Rafael J. Wysocki
2013-11-21  3:24         ` Viresh Kumar
2013-10-03 15:56 ` [PATCH V2 14/16] cpuidle: don't calculate time-diff if entered_state < 0 Viresh Kumar
2013-11-20  8:04   ` Viresh Kumar
2013-11-21  1:06     ` Rafael J. Wysocki
2013-10-03 15:56 ` Viresh Kumar [this message]
2013-10-03 15:56 ` [PATCH V2 16/16] cpuidle: remove cpuidle_unregister_governor() Viresh Kumar
2013-10-03 21:07 ` [PATCH V2 00/16] CPUIdle: Minor cleanups for 3.13 Kevin Hilman
2013-10-04  5:23   ` Viresh Kumar
2013-10-23  5:41 ` 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=ee9b99a281df92e71b75ff786336a54b5f9b428e.1380815504.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linaro-kernel@lists.linaro.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 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).