aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2012-05-07 20:57:39 -0400
committerLen Brown <len.brown@intel.com>2012-06-02 00:48:31 -0400
commit56cfbf74a17c40f3a741398103c9f5d5a6806715 (patch)
tree80adac252b5c485df28f3469e314a66d562a5d4c /drivers/cpuidle
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
cpuidle: refactor out cpuidle_enter_state
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. Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Tested-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Colin Cross <ccross@android.com> Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/cpuidle.c42
-rw-r--r--drivers/cpuidle/cpuidle.h2
2 files changed, 31 insertions, 13 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 2f0083a51a9a..3e3e3e4d9581 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -103,6 +103,34 @@ int cpuidle_play_dead(void)
103} 103}
104 104
105/** 105/**
106 * cpuidle_enter_state - enter the state and update stats
107 * @dev: cpuidle device for this cpu
108 * @drv: cpuidle driver for this cpu
109 * @next_state: index into drv->states of the state to enter
110 */
111int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
112 int next_state)
113{
114 int entered_state;
115
116 entered_state = cpuidle_enter_ops(dev, drv, next_state);
117
118 if (entered_state >= 0) {
119 /* Update cpuidle counters */
120 /* This can be moved to within driver enter routine
121 * but that results in multiple copies of same code.
122 */
123 dev->states_usage[entered_state].time +=
124 (unsigned long long)dev->last_residency;
125 dev->states_usage[entered_state].usage++;
126 } else {
127 dev->last_residency = 0;
128 }
129
130 return entered_state;
131}
132
133/**
106 * cpuidle_idle_call - the main idle loop 134 * cpuidle_idle_call - the main idle loop
107 * 135 *
108 * NOTE: no locks or semaphores should be used here 136 * NOTE: no locks or semaphores should be used here
@@ -143,23 +171,11 @@ int cpuidle_idle_call(void)
143 trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu); 171 trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu);
144 trace_cpu_idle_rcuidle(next_state, dev->cpu); 172 trace_cpu_idle_rcuidle(next_state, dev->cpu);
145 173
146 entered_state = cpuidle_enter_ops(dev, drv, next_state); 174 entered_state = cpuidle_enter_state(dev, drv, next_state);
147 175
148 trace_power_end_rcuidle(dev->cpu); 176 trace_power_end_rcuidle(dev->cpu);
149 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); 177 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
150 178
151 if (entered_state >= 0) {
152 /* Update cpuidle counters */
153 /* This can be moved to within driver enter routine
154 * but that results in multiple copies of same code.
155 */
156 dev->states_usage[entered_state].time +=
157 (unsigned long long)dev->last_residency;
158 dev->states_usage[entered_state].usage++;
159 } else {
160 dev->last_residency = 0;
161 }
162
163 /* give the governor an opportunity to reflect on the outcome */ 179 /* give the governor an opportunity to reflect on the outcome */
164 if (cpuidle_curr_governor->reflect) 180 if (cpuidle_curr_governor->reflect)
165 cpuidle_curr_governor->reflect(dev, entered_state); 181 cpuidle_curr_governor->reflect(dev, entered_state);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 7db186685c27..d8a3ccce8281 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -14,6 +14,8 @@ extern struct list_head cpuidle_detected_devices;
14extern struct mutex cpuidle_lock; 14extern struct mutex cpuidle_lock;
15extern spinlock_t cpuidle_driver_lock; 15extern spinlock_t cpuidle_driver_lock;
16extern int cpuidle_disabled(void); 16extern int cpuidle_disabled(void);
17extern int cpuidle_enter_state(struct cpuidle_device *dev,
18 struct cpuidle_driver *drv, int next_state);
17 19
18/* idle loop */ 20/* idle loop */
19extern void cpuidle_install_idle_handler(void); 21extern void cpuidle_install_idle_handler(void);