aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-05-09 19:19:52 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-05-14 15:37:52 -0400
commit0d94039fabccaa81d87eafdac509d0dda4df2f7b (patch)
tree3b7697a35df7ca25b0e9d013b68a2e2702ddb465
parent827a5aefc542b8fb17c00de06118e5cd0e3800f2 (diff)
cpuidle: Select a different state on tick_broadcast_enter() failures
If tick_broadcast_enter() fails in cpuidle_enter_state(), try to find another idle state to enter instead of invoking default_idle_call() immediately and returning -EBUSY which should increase the chances of saving some energy in those cases. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com> Tested-by: Preeti U Murthy <preeti@linux.vnet.ibm.com> Tested-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Kevin Hilman <khilman@linaro.org>
-rw-r--r--drivers/cpuidle/cpuidle.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a7b9e679a2ef..af6dd599c464 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -73,7 +73,10 @@ int cpuidle_play_dead(void)
73} 73}
74 74
75static int find_deepest_state(struct cpuidle_driver *drv, 75static int find_deepest_state(struct cpuidle_driver *drv,
76 struct cpuidle_device *dev, bool freeze) 76 struct cpuidle_device *dev,
77 unsigned int max_latency,
78 unsigned int forbidden_flags,
79 bool freeze)
77{ 80{
78 unsigned int latency_req = 0; 81 unsigned int latency_req = 0;
79 int i, ret = freeze ? -1 : CPUIDLE_DRIVER_STATE_START - 1; 82 int i, ret = freeze ? -1 : CPUIDLE_DRIVER_STATE_START - 1;
@@ -83,6 +86,8 @@ static int find_deepest_state(struct cpuidle_driver *drv,
83 struct cpuidle_state_usage *su = &dev->states_usage[i]; 86 struct cpuidle_state_usage *su = &dev->states_usage[i];
84 87
85 if (s->disabled || su->disable || s->exit_latency <= latency_req 88 if (s->disabled || su->disable || s->exit_latency <= latency_req
89 || s->exit_latency > max_latency
90 || (s->flags & forbidden_flags)
86 || (freeze && !s->enter_freeze)) 91 || (freeze && !s->enter_freeze))
87 continue; 92 continue;
88 93
@@ -100,7 +105,7 @@ static int find_deepest_state(struct cpuidle_driver *drv,
100int cpuidle_find_deepest_state(struct cpuidle_driver *drv, 105int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
101 struct cpuidle_device *dev) 106 struct cpuidle_device *dev)
102{ 107{
103 return find_deepest_state(drv, dev, false); 108 return find_deepest_state(drv, dev, UINT_MAX, 0, false);
104} 109}
105 110
106static void enter_freeze_proper(struct cpuidle_driver *drv, 111static void enter_freeze_proper(struct cpuidle_driver *drv,
@@ -139,7 +144,7 @@ int cpuidle_enter_freeze(struct cpuidle_driver *drv, struct cpuidle_device *dev)
139 * that interrupts won't be enabled when it exits and allows the tick to 144 * that interrupts won't be enabled when it exits and allows the tick to
140 * be frozen safely. 145 * be frozen safely.
141 */ 146 */
142 index = find_deepest_state(drv, dev, true); 147 index = find_deepest_state(drv, dev, UINT_MAX, 0, true);
143 if (index >= 0) 148 if (index >= 0)
144 enter_freeze_proper(drv, dev, index); 149 enter_freeze_proper(drv, dev, index);
145 150
@@ -168,8 +173,13 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
168 * CPU as a broadcast timer, this call may fail if it is not available. 173 * CPU as a broadcast timer, this call may fail if it is not available.
169 */ 174 */
170 if (broadcast && tick_broadcast_enter()) { 175 if (broadcast && tick_broadcast_enter()) {
171 default_idle_call(); 176 index = find_deepest_state(drv, dev, target_state->exit_latency,
172 return -EBUSY; 177 CPUIDLE_FLAG_TIMER_STOP, false);
178 if (index < 0) {
179 default_idle_call();
180 return -EBUSY;
181 }
182 target_state = &drv->states[index];
173 } 183 }
174 184
175 /* Take note of the planned idle state. */ 185 /* Take note of the planned idle state. */