diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-09 19:18:46 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-14 15:37:47 -0400 |
commit | 827a5aefc542b8fb17c00de06118e5cd0e3800f2 (patch) | |
tree | 5728ec6fb8a0b67057e35d131ed2a2d7d67b2a69 | |
parent | faad38492814112e3e7ce94d90123bbe301fff33 (diff) |
sched / idle: Call default_idle_call() from cpuidle_enter_state()
The check of the cpuidle_enter() return value against -EBUSY
made in call_cpuidle() will not be necessary any more if
cpuidle_enter_state() calls default_idle_call() directly when it
is about to return -EBUSY, so make that happen and eliminate the
check.
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.c | 4 | ||||
-rw-r--r-- | include/linux/cpuidle.h | 1 | ||||
-rw-r--r-- | kernel/sched/idle.c | 20 |
3 files changed, 11 insertions, 14 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 9306dd5f460e..a7b9e679a2ef 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -167,8 +167,10 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, | |||
167 | * local timer will be shut down. If a local timer is used from another | 167 | * local timer will be shut down. If a local timer is used from another |
168 | * CPU as a broadcast timer, this call may fail if it is not available. | 168 | * CPU as a broadcast timer, this call may fail if it is not available. |
169 | */ | 169 | */ |
170 | if (broadcast && tick_broadcast_enter()) | 170 | if (broadcast && tick_broadcast_enter()) { |
171 | default_idle_call(); | ||
171 | return -EBUSY; | 172 | return -EBUSY; |
173 | } | ||
172 | 174 | ||
173 | /* Take note of the planned idle state. */ | 175 | /* Take note of the planned idle state. */ |
174 | sched_idle_set_state(target_state); | 176 | sched_idle_set_state(target_state); |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 301eaaab40e3..c7a63643658e 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -202,6 +202,7 @@ static inline struct cpuidle_driver *cpuidle_get_cpu_driver( | |||
202 | 202 | ||
203 | /* kernel/sched/idle.c */ | 203 | /* kernel/sched/idle.c */ |
204 | extern void sched_idle_set_state(struct cpuidle_state *idle_state); | 204 | extern void sched_idle_set_state(struct cpuidle_state *idle_state); |
205 | extern void default_idle_call(void); | ||
205 | 206 | ||
206 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | 207 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED |
207 | void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a); | 208 | void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a); |
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 5d9f549fffa8..594275ed2620 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c | |||
@@ -76,12 +76,13 @@ void __weak arch_cpu_idle(void) | |||
76 | local_irq_enable(); | 76 | local_irq_enable(); |
77 | } | 77 | } |
78 | 78 | ||
79 | static void default_idle_call(void) | 79 | /** |
80 | * default_idle_call - Default CPU idle routine. | ||
81 | * | ||
82 | * To use when the cpuidle framework cannot be used. | ||
83 | */ | ||
84 | void default_idle_call(void) | ||
80 | { | 85 | { |
81 | /* | ||
82 | * We can't use the cpuidle framework, let's use the default idle | ||
83 | * routine. | ||
84 | */ | ||
85 | if (current_clr_polling_and_test()) | 86 | if (current_clr_polling_and_test()) |
86 | local_irq_enable(); | 87 | local_irq_enable(); |
87 | else | 88 | else |
@@ -91,8 +92,6 @@ static void default_idle_call(void) | |||
91 | static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, | 92 | static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, |
92 | int next_state) | 93 | int next_state) |
93 | { | 94 | { |
94 | int entered_state; | ||
95 | |||
96 | /* Fall back to the default arch idle method on errors. */ | 95 | /* Fall back to the default arch idle method on errors. */ |
97 | if (next_state < 0) { | 96 | if (next_state < 0) { |
98 | default_idle_call(); | 97 | default_idle_call(); |
@@ -114,12 +113,7 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, | |||
114 | * This function will block until an interrupt occurs and will take | 113 | * This function will block until an interrupt occurs and will take |
115 | * care of re-enabling the local interrupts | 114 | * care of re-enabling the local interrupts |
116 | */ | 115 | */ |
117 | entered_state = cpuidle_enter(drv, dev, next_state); | 116 | return cpuidle_enter(drv, dev, next_state); |
118 | |||
119 | if (entered_state == -EBUSY) | ||
120 | default_idle_call(); | ||
121 | |||
122 | return entered_state; | ||
123 | } | 117 | } |
124 | 118 | ||
125 | /** | 119 | /** |