All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Cross <ccross@android.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-pm@lists.linux-foundation.org
Cc: Kevin Hilman <khilman@ti.com>, Len Brown <len.brown@intel.com>,
	Amit Kucheria <amit.kucheria@linaro.org>,
	Colin Cross <ccross@android.com>,
	linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org,
	Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH 1/3] cpuidle: refactor out cpuidle_enter_state
Date: Tue, 20 Dec 2011 16:09:05 -0800	[thread overview]
Message-ID: <1324426147-16735-2-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1324426147-16735-1-git-send-email-ccross@android.com>

Split the code to enter a state and update the stats into a helper
function, cpuidle_enter_state, and export it.  This function will
be called by the coupled state code to handle entering the safe
state and the final coupled state.

Signed-off-by: Colin Cross <ccross@android.com>
---
 drivers/cpuidle/cpuidle.c |   43 +++++++++++++++++++++++++++++--------------
 drivers/cpuidle/cpuidle.h |    2 ++
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 06ce268..1486b3c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -54,6 +54,34 @@ static void cpuidle_kick_cpus(void) {}
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 /**
+ * cpuidle_enter_state
+ *
+ * enter the state and update stats
+ */
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state)
+{
+	int entered_state;
+	struct cpuidle_state *target_state;
+
+	target_state = &drv->states[next_state];
+
+	entered_state = target_state->enter(dev, drv, next_state);
+
+	if (entered_state >= 0) {
+		/* Update cpuidle counters */
+		/* This can be moved to within driver enter routine
+		 * but that results in multiple copies of same code.
+		 */
+		dev->states_usage[entered_state].time +=
+				(unsigned long long)dev->last_residency;
+		dev->states_usage[entered_state].usage++;
+	}
+
+	return entered_state;
+}
+
+/**
  * cpuidle_idle_call - the main idle loop
  *
  * NOTE: no locks or semaphores should be used here
@@ -63,7 +91,6 @@ int cpuidle_idle_call(void)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
 	struct cpuidle_driver *drv = cpuidle_get_driver();
-	struct cpuidle_state *target_state;
 	int next_state, entered_state;
 
 	if (off)
@@ -92,26 +119,14 @@ int cpuidle_idle_call(void)
 		return 0;
 	}
 
-	target_state = &drv->states[next_state];
-
 	trace_power_start(POWER_CSTATE, next_state, dev->cpu);
 	trace_cpu_idle(next_state, dev->cpu);
 
-	entered_state = target_state->enter(dev, drv, next_state);
+	entered_state = cpuidle_enter_state(dev, drv, next_state);
 
 	trace_power_end(dev->cpu);
 	trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
 
-	if (entered_state >= 0) {
-		/* Update cpuidle counters */
-		/* This can be moved to within driver enter routine
-		 * but that results in multiple copies of same code.
-		 */
-		dev->states_usage[entered_state].time +=
-				(unsigned long long)dev->last_residency;
-		dev->states_usage[entered_state].usage++;
-	}
-
 	/* give the governor an opportunity to reflect on the outcome */
 	if (cpuidle_curr_governor->reflect)
 		cpuidle_curr_governor->reflect(dev, entered_state);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 38c3fd8..dd2df8f 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -14,6 +14,8 @@ extern struct list_head cpuidle_detected_devices;
 extern struct mutex cpuidle_lock;
 extern spinlock_t cpuidle_driver_lock;
 extern int cpuidle_disabled(void);
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state);
 
 /* idle loop */
 extern void cpuidle_install_idle_handler(void);
-- 
1.7.4.1

WARNING: multiple messages have this Message-ID (diff)
From: Colin Cross <ccross@android.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-pm@lists.linux-foundation.org
Cc: Len Brown <len.brown@intel.com>, Kevin Hilman <khilman@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Amit Kucheria <amit.kucheria@linaro.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Trinabh Gupta <g.trinabh@gmail.com>,
	Deepthi Dharwar <deepthi@linux.vnet.ibm.com>,
	linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
	Colin Cross <ccross@android.com>
Subject: [PATCH 1/3] cpuidle: refactor out cpuidle_enter_state
Date: Tue, 20 Dec 2011 16:09:05 -0800	[thread overview]
Message-ID: <1324426147-16735-2-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1324426147-16735-1-git-send-email-ccross@android.com>

Split the code to enter a state and update the stats into a helper
function, cpuidle_enter_state, and export it.  This function will
be called by the coupled state code to handle entering the safe
state and the final coupled state.

Signed-off-by: Colin Cross <ccross@android.com>
---
 drivers/cpuidle/cpuidle.c |   43 +++++++++++++++++++++++++++++--------------
 drivers/cpuidle/cpuidle.h |    2 ++
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 06ce268..1486b3c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -54,6 +54,34 @@ static void cpuidle_kick_cpus(void) {}
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 /**
+ * cpuidle_enter_state
+ *
+ * enter the state and update stats
+ */
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state)
+{
+	int entered_state;
+	struct cpuidle_state *target_state;
+
+	target_state = &drv->states[next_state];
+
+	entered_state = target_state->enter(dev, drv, next_state);
+
+	if (entered_state >= 0) {
+		/* Update cpuidle counters */
+		/* This can be moved to within driver enter routine
+		 * but that results in multiple copies of same code.
+		 */
+		dev->states_usage[entered_state].time +=
+				(unsigned long long)dev->last_residency;
+		dev->states_usage[entered_state].usage++;
+	}
+
+	return entered_state;
+}
+
+/**
  * cpuidle_idle_call - the main idle loop
  *
  * NOTE: no locks or semaphores should be used here
@@ -63,7 +91,6 @@ int cpuidle_idle_call(void)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
 	struct cpuidle_driver *drv = cpuidle_get_driver();
-	struct cpuidle_state *target_state;
 	int next_state, entered_state;
 
 	if (off)
@@ -92,26 +119,14 @@ int cpuidle_idle_call(void)
 		return 0;
 	}
 
-	target_state = &drv->states[next_state];
-
 	trace_power_start(POWER_CSTATE, next_state, dev->cpu);
 	trace_cpu_idle(next_state, dev->cpu);
 
-	entered_state = target_state->enter(dev, drv, next_state);
+	entered_state = cpuidle_enter_state(dev, drv, next_state);
 
 	trace_power_end(dev->cpu);
 	trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
 
-	if (entered_state >= 0) {
-		/* Update cpuidle counters */
-		/* This can be moved to within driver enter routine
-		 * but that results in multiple copies of same code.
-		 */
-		dev->states_usage[entered_state].time +=
-				(unsigned long long)dev->last_residency;
-		dev->states_usage[entered_state].usage++;
-	}
-
 	/* give the governor an opportunity to reflect on the outcome */
 	if (cpuidle_curr_governor->reflect)
 		cpuidle_curr_governor->reflect(dev, entered_state);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 38c3fd8..dd2df8f 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -14,6 +14,8 @@ extern struct list_head cpuidle_detected_devices;
 extern struct mutex cpuidle_lock;
 extern spinlock_t cpuidle_driver_lock;
 extern int cpuidle_disabled(void);
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state);
 
 /* idle loop */
 extern void cpuidle_install_idle_handler(void);
-- 
1.7.4.1


WARNING: multiple messages have this Message-ID (diff)
From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] cpuidle: refactor out cpuidle_enter_state
Date: Tue, 20 Dec 2011 16:09:05 -0800	[thread overview]
Message-ID: <1324426147-16735-2-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1324426147-16735-1-git-send-email-ccross@android.com>

Split the code to enter a state and update the stats into a helper
function, cpuidle_enter_state, and export it.  This function will
be called by the coupled state code to handle entering the safe
state and the final coupled state.

Signed-off-by: Colin Cross <ccross@android.com>
---
 drivers/cpuidle/cpuidle.c |   43 +++++++++++++++++++++++++++++--------------
 drivers/cpuidle/cpuidle.h |    2 ++
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 06ce268..1486b3c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -54,6 +54,34 @@ static void cpuidle_kick_cpus(void) {}
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 /**
+ * cpuidle_enter_state
+ *
+ * enter the state and update stats
+ */
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state)
+{
+	int entered_state;
+	struct cpuidle_state *target_state;
+
+	target_state = &drv->states[next_state];
+
+	entered_state = target_state->enter(dev, drv, next_state);
+
+	if (entered_state >= 0) {
+		/* Update cpuidle counters */
+		/* This can be moved to within driver enter routine
+		 * but that results in multiple copies of same code.
+		 */
+		dev->states_usage[entered_state].time +=
+				(unsigned long long)dev->last_residency;
+		dev->states_usage[entered_state].usage++;
+	}
+
+	return entered_state;
+}
+
+/**
  * cpuidle_idle_call - the main idle loop
  *
  * NOTE: no locks or semaphores should be used here
@@ -63,7 +91,6 @@ int cpuidle_idle_call(void)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
 	struct cpuidle_driver *drv = cpuidle_get_driver();
-	struct cpuidle_state *target_state;
 	int next_state, entered_state;
 
 	if (off)
@@ -92,26 +119,14 @@ int cpuidle_idle_call(void)
 		return 0;
 	}
 
-	target_state = &drv->states[next_state];
-
 	trace_power_start(POWER_CSTATE, next_state, dev->cpu);
 	trace_cpu_idle(next_state, dev->cpu);
 
-	entered_state = target_state->enter(dev, drv, next_state);
+	entered_state = cpuidle_enter_state(dev, drv, next_state);
 
 	trace_power_end(dev->cpu);
 	trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
 
-	if (entered_state >= 0) {
-		/* Update cpuidle counters */
-		/* This can be moved to within driver enter routine
-		 * but that results in multiple copies of same code.
-		 */
-		dev->states_usage[entered_state].time +=
-				(unsigned long long)dev->last_residency;
-		dev->states_usage[entered_state].usage++;
-	}
-
 	/* give the governor an opportunity to reflect on the outcome */
 	if (cpuidle_curr_governor->reflect)
 		cpuidle_curr_governor->reflect(dev, entered_state);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 38c3fd8..dd2df8f 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -14,6 +14,8 @@ extern struct list_head cpuidle_detected_devices;
 extern struct mutex cpuidle_lock;
 extern spinlock_t cpuidle_driver_lock;
 extern int cpuidle_disabled(void);
+int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
+		int next_state);
 
 /* idle loop */
 extern void cpuidle_install_idle_handler(void);
-- 
1.7.4.1

  reply	other threads:[~2011-12-21  0:09 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21  0:09 [PATCH 0/3] coupled cpuidle state support Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09 ` Colin Cross [this message]
2011-12-21  0:09   ` [PATCH 1/3] cpuidle: refactor out cpuidle_enter_state Colin Cross
2011-12-21  0:09   ` Colin Cross
2012-01-04 14:08   ` Jean Pihet
2012-01-04 14:08     ` [linux-pm] " Jean Pihet
2012-01-04 14:08     ` Jean Pihet
     [not found] ` <1324426147-16735-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2011-12-21  0:09   ` [PATCH 2/3] cpuidle: fix error handling in __cpuidle_register_device Colin Cross
2011-12-21  0:09     ` Colin Cross
2011-12-21  0:09     ` Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09 ` [PATCH 3/3] cpuidle: add support for states that affect multiple cpus Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09   ` Colin Cross
2011-12-21  9:02 ` [PATCH 0/3] coupled cpuidle state support Arjan van de Ven
2011-12-21  9:02 ` Arjan van de Ven
2011-12-21  9:02   ` Arjan van de Ven
     [not found]   ` <4EF1A0B4.5080307-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-21  9:40     ` Colin Cross
2011-12-21  9:40       ` Colin Cross
2011-12-21  9:40       ` Colin Cross
2011-12-21  9:44       ` Arjan van de Ven
2011-12-21  9:44         ` Arjan van de Ven
2011-12-21  9:44         ` Arjan van de Ven
     [not found]         ` <4EF1AA8A.8060304-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-21  9:55           ` Colin Cross
2011-12-21  9:55             ` Colin Cross
2011-12-21  9:55             ` Colin Cross
2011-12-21 12:12             ` Arjan van de Ven
2011-12-21 12:12             ` Arjan van de Ven
2011-12-21 12:12               ` Arjan van de Ven
2011-12-21 19:05               ` Colin Cross
2011-12-21 19:05                 ` Colin Cross
2011-12-21 19:05                 ` Colin Cross
     [not found]                 ` <CAMbhsRRnKoR3YPWrZzVynVe+dcuU5v0siYvmp2vbBcS1hquC7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-21 19:36                   ` Arjan van de Ven
2011-12-21 19:36                     ` Arjan van de Ven
2011-12-21 19:36                     ` Arjan van de Ven
2011-12-21 19:42                     ` Colin Cross
2011-12-21 19:42                       ` [linux-pm] " Colin Cross
2011-12-21 19:42                       ` Colin Cross
     [not found]                       ` <CAMbhsRSPCo9MSGp57Fv0sRdYUFcdwx8jEz1-CfX8LdKf8X4MVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-22  8:35                         ` Shilimkar, Santosh
2011-12-22  8:35                           ` Shilimkar, Santosh
2011-12-22  8:35                           ` Shilimkar, Santosh
2011-12-22  8:53                           ` Arjan van de Ven
2011-12-22  8:53                             ` [linux-pm] " Arjan van de Ven
2011-12-22  8:53                             ` Arjan van de Ven
2011-12-22  9:30                             ` Shilimkar, Santosh
2011-12-22  9:30                             ` [linux-pm] " Shilimkar, Santosh
2011-12-22  9:30                               ` Shilimkar, Santosh
2011-12-22 21:20                             ` Colin Cross
     [not found]                             ` <4EF2F01E.8060307-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-22 21:20                               ` [linux-pm] " Colin Cross
2011-12-22 21:20                                 ` Colin Cross
2011-12-22 21:20                                 ` Colin Cross
2011-12-22  8:35                       ` Shilimkar, Santosh
2011-12-21 19:36                 ` Arjan van de Ven
     [not found]               ` <4EF1CD49.9020800-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2012-03-14  0:39                 ` Colin Cross
2012-03-14  0:39                   ` Colin Cross
2012-03-14  0:39                   ` Colin Cross
2011-12-21  9:55         ` Colin Cross
2011-12-21  9:40   ` Colin Cross
2012-01-04  0:41 ` Kevin Hilman
2012-01-04  0:41   ` Kevin Hilman
2012-01-04  0:41   ` Kevin Hilman
2012-01-04 17:27   ` Shilimkar, Santosh
2012-01-04 17:27   ` Shilimkar, Santosh
2012-01-04 17:27     ` Shilimkar, Santosh
2012-01-20  8:46 ` Daniel Lezcano
2012-01-20  8:46   ` Daniel Lezcano
2012-01-20  8:46   ` Daniel Lezcano
2012-01-20 20:40   ` Colin Cross
2012-01-20 20:40     ` Colin Cross
2012-01-20 20:40     ` Colin Cross
2012-01-25 14:04     ` Daniel Lezcano
2012-01-25 14:04       ` Daniel Lezcano
2012-01-31 14:13       ` Daniel Lezcano
2012-01-31 14:13         ` Daniel Lezcano
     [not found]     ` <CAMbhsRTbVqV6p0py9NGZrpFPf2yvp-B0dr+o-m7qbdja_-Lfzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-27  8:54       ` [linux-pm] " Vincent Guittot
2012-01-27  8:54         ` Vincent Guittot
2012-01-27  8:54         ` Vincent Guittot
2012-01-27 17:32         ` Colin Cross
2012-01-27 17:32           ` Colin Cross
2012-01-27 17:32           ` Colin Cross
     [not found]           ` <CAMbhsRQYVXTZ2pX4mBrM6=SyGTqn_GY8xsW4rt_e21zerEzctA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 12:13             ` Vincent Guittot
2012-02-01 12:13               ` Vincent Guittot
2012-02-01 12:13               ` Vincent Guittot
2012-02-01 14:59               ` Lorenzo Pieralisi
2012-02-01 14:59                 ` [linux-pm] " Lorenzo Pieralisi
2012-02-01 14:59                 ` Lorenzo Pieralisi
2012-02-01 17:30                 ` Colin Cross
2012-02-01 17:30                   ` Colin Cross
2012-02-01 17:30                   ` Colin Cross
2012-02-01 18:07                   ` Lorenzo Pieralisi
2012-02-01 18:07                     ` [linux-pm] " Lorenzo Pieralisi
2012-02-01 18:07                     ` Lorenzo Pieralisi
2012-02-03  1:19                     ` Colin Cross
2012-02-03  1:19                       ` [linux-pm] " Colin Cross
2012-02-03  1:19                       ` Colin Cross
2012-03-13 23:52   ` Kevin Hilman
2012-03-13 23:52     ` Kevin Hilman
     [not found]     ` <8762e8kqi6.fsf-l0cyMroinI0@public.gmane.org>
2012-03-14  0:28       ` Colin Cross
2012-03-14  0:28         ` Colin Cross
2012-03-14  0:28         ` Colin Cross
2012-03-14  0:47         ` Colin Cross
2012-03-14  0:47           ` Colin Cross
2012-03-14  0:47           ` Colin Cross
     [not found]           ` <CAMbhsRRD2bdkcUZvScb-cF05e=R3h69bNVaTPFX4jBKBBOjuMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-14 14:23             ` [linux-pm] " Kevin Hilman
2012-03-14 14:23               ` Kevin Hilman
2012-03-14 14:23               ` Kevin Hilman
2012-03-14  2:04     ` Arjan van de Ven
2012-03-14  2:04       ` Arjan van de Ven
2012-03-14  2:04       ` Arjan van de Ven
2012-03-14  2:21       ` Colin Cross
2012-03-14  2:21         ` Colin Cross
2012-03-14  2:21         ` Colin Cross

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=1324426147-16735-2-git-send-email-ccross@android.com \
    --to=ccross@android.com \
    --cc=amit.kucheria@linaro.org \
    --cc=arjan@linux.intel.com \
    --cc=khilman@ti.com \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-tegra@vger.kernel.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 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.