linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuidle: Do not use CPUIDLE_DRIVER_STATE_START in cpuidle.c
@ 2015-05-27  1:36 Rafael J. Wysocki
  2015-05-27  8:22 ` Daniel Lezcano
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2015-05-27  1:36 UTC (permalink / raw)
  To: Linux PM list, Daniel Lezcano
  Cc: Linux Kernel Mailing List, Peter Zijlstra, Len Brown, Preeti U Murthy

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The CPUIDLE_DRIVER_STATE_START symbol is defined as 1 only if
CONFIG_ARCH_HAS_CPU_RELAX is set, otherwise it is defined as 0.
However, if CONFIG_ARCH_HAS_CPU_RELAX is set, the first (index 0)
entry in the cpuidle driver's table of states is overwritten with
the default "poll" entry by the core.  The "state" defined by the
"poll" entry doesn't provide ->enter_dead and ->enter_freeze
callbacks and its exit_latency is 0.

For this reason, it is not necessary to use CPUIDLE_DRIVER_STATE_START
in cpuidle_play_dead() (->enter_dead is NULL, so the "poll state"
will be skipped by the loop) and in find_deepest_state() (since
exit_latency is 0, the "poll state" will become the default if the
"s->exit_latency <= latency_req" check is replaced with
"s->exit_latency < latency_req" which may only matter for drivers
providing different states with the same exit_latency).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpuidle/cpuidle.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-pm/drivers/cpuidle/cpuidle.c
===================================================================
--- linux-pm.orig/drivers/cpuidle/cpuidle.c
+++ linux-pm/drivers/cpuidle/cpuidle.c
@@ -65,7 +65,7 @@ int cpuidle_play_dead(void)
 		return -ENODEV;
 
 	/* Find lowest-power state that supports long-term idle */
-	for (i = drv->state_count - 1; i >= CPUIDLE_DRIVER_STATE_START; i--)
+	for (i = drv->state_count - 1; i >= 0; i--)
 		if (drv->states[i].enter_dead)
 			return drv->states[i].enter_dead(dev, i);
 
@@ -79,13 +79,13 @@ static int find_deepest_state(struct cpu
 			      bool freeze)
 {
 	unsigned int latency_req = 0;
-	int i, ret = freeze ? -1 : CPUIDLE_DRIVER_STATE_START - 1;
+	int i, ret = -ENXIO;
 
-	for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
+	for (i = 0; i < drv->state_count; i++) {
 		struct cpuidle_state *s = &drv->states[i];
 		struct cpuidle_state_usage *su = &dev->states_usage[i];
 
-		if (s->disabled || su->disable || s->exit_latency <= latency_req
+		if (s->disabled || su->disable || s->exit_latency < latency_req
 		    || s->exit_latency > max_latency
 		    || (s->flags & forbidden_flags)
 		    || (freeze && !cpuidle_has_enter_freeze(s)))


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-05-28  1:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27  1:36 [PATCH] cpuidle: Do not use CPUIDLE_DRIVER_STATE_START in cpuidle.c Rafael J. Wysocki
2015-05-27  8:22 ` Daniel Lezcano
2015-05-27 11:31 ` Preeti U Murthy
2015-05-27 12:25   ` Daniel Lezcano
2015-05-27 13:57     ` Rafael J. Wysocki
2015-05-27 16:19       ` Preeti U Murthy
2015-05-28  0:51         ` Rafael J. Wysocki
2015-05-28  2:09 ` [PATCH v2] " Rafael J. Wysocki
2015-05-28  1:58   ` Preeti U Murthy

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).