diff options
author | Sanjeev Premi <premi@ti.com> | 2010-01-28 12:46:43 -0500 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2010-02-23 14:05:00 -0500 |
commit | 6af83b38613da58a221e56af676097575ce2c763 (patch) | |
tree | da9cbc660ff2c7267782c57bf1cf5e655bf1983c /arch/arm/mach-omap2/cpuidle34xx.c | |
parent | 80c20d543d142ee54ec85259b77aaf0b83c32db5 (diff) |
OMAP3: cpuidle: Update statistics for correct state
When 'enable_off_mode' is 0, the target power state for MPU
and CORE was locally changed to PWRDM_POWER_RET but, the
statistics are updated for idle state originally selected
by the governor.
This patch 'invalidates' the idle states that lead either of
MPU or Core to PWRDM_POWER_OFF state when 'enable_off_mode'
is '0'. The states are valid once 'enable_off_mode' is set
to '1'.
Added function next_valid_state() to check if current state
is valid; else get the next valid state. It is called from
omap3_enter_idle_bm().
Signed-off-by: Sanjeev Premi <premi@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-omap2/cpuidle34xx.c')
-rw-r--r-- | arch/arm/mach-omap2/cpuidle34xx.c | 98 |
1 files changed, 90 insertions, 8 deletions
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c index 12f0cbfc2894..ff1ad3d06ce1 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c | |||
@@ -45,6 +45,8 @@ | |||
45 | #define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core RET */ | 45 | #define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core RET */ |
46 | #define OMAP3_STATE_C7 6 /* C7 - MPU OFF + Core OFF */ | 46 | #define OMAP3_STATE_C7 6 /* C7 - MPU OFF + Core OFF */ |
47 | 47 | ||
48 | #define OMAP3_STATE_MAX OMAP3_STATE_C7 | ||
49 | |||
48 | struct omap3_processor_cx { | 50 | struct omap3_processor_cx { |
49 | u8 valid; | 51 | u8 valid; |
50 | u8 type; | 52 | u8 type; |
@@ -104,13 +106,6 @@ static int omap3_enter_idle(struct cpuidle_device *dev, | |||
104 | local_irq_disable(); | 106 | local_irq_disable(); |
105 | local_fiq_disable(); | 107 | local_fiq_disable(); |
106 | 108 | ||
107 | if (!enable_off_mode) { | ||
108 | if (mpu_state < PWRDM_POWER_RET) | ||
109 | mpu_state = PWRDM_POWER_RET; | ||
110 | if (core_state < PWRDM_POWER_RET) | ||
111 | core_state = PWRDM_POWER_RET; | ||
112 | } | ||
113 | |||
114 | pwrdm_set_next_pwrst(mpu_pd, mpu_state); | 109 | pwrdm_set_next_pwrst(mpu_pd, mpu_state); |
115 | pwrdm_set_next_pwrst(core_pd, core_state); | 110 | pwrdm_set_next_pwrst(core_pd, core_state); |
116 | 111 | ||
@@ -141,6 +136,67 @@ return_sleep_time: | |||
141 | } | 136 | } |
142 | 137 | ||
143 | /** | 138 | /** |
139 | * next_valid_state - Find next valid c-state | ||
140 | * @dev: cpuidle device | ||
141 | * @state: Currently selected c-state | ||
142 | * | ||
143 | * If the current state is valid, it is returned back to the caller. | ||
144 | * Else, this function searches for a lower c-state which is still | ||
145 | * valid (as defined in omap3_power_states[]). | ||
146 | */ | ||
147 | static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev, | ||
148 | struct cpuidle_state *curr) | ||
149 | { | ||
150 | struct cpuidle_state *next = NULL; | ||
151 | struct omap3_processor_cx *cx; | ||
152 | |||
153 | cx = (struct omap3_processor_cx *)cpuidle_get_statedata(curr); | ||
154 | |||
155 | /* Check if current state is valid */ | ||
156 | if (cx->valid) { | ||
157 | return curr; | ||
158 | } else { | ||
159 | u8 idx = OMAP3_STATE_MAX; | ||
160 | |||
161 | /* | ||
162 | * Reach the current state starting at highest C-state | ||
163 | */ | ||
164 | for (; idx >= OMAP3_STATE_C1; idx--) { | ||
165 | if (&dev->states[idx] == curr) { | ||
166 | next = &dev->states[idx]; | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Should never hit this condition. | ||
173 | */ | ||
174 | WARN_ON(next == NULL); | ||
175 | |||
176 | /* | ||
177 | * Drop to next valid state. | ||
178 | * Start search from the next (lower) state. | ||
179 | */ | ||
180 | idx--; | ||
181 | for (; idx >= OMAP3_STATE_C1; idx--) { | ||
182 | struct omap3_processor_cx *cx; | ||
183 | |||
184 | cx = cpuidle_get_statedata(&dev->states[idx]); | ||
185 | if (cx->valid) { | ||
186 | next = &dev->states[idx]; | ||
187 | break; | ||
188 | } | ||
189 | } | ||
190 | /* | ||
191 | * C1 and C2 are always valid. | ||
192 | * So, no need to check for 'next==NULL' outside this loop. | ||
193 | */ | ||
194 | } | ||
195 | |||
196 | return next; | ||
197 | } | ||
198 | |||
199 | /** | ||
144 | * omap3_enter_idle_bm - Checks for any bus activity | 200 | * omap3_enter_idle_bm - Checks for any bus activity |
145 | * @dev: cpuidle device | 201 | * @dev: cpuidle device |
146 | * @state: The target state to be programmed | 202 | * @state: The target state to be programmed |
@@ -152,7 +208,7 @@ return_sleep_time: | |||
152 | static int omap3_enter_idle_bm(struct cpuidle_device *dev, | 208 | static int omap3_enter_idle_bm(struct cpuidle_device *dev, |
153 | struct cpuidle_state *state) | 209 | struct cpuidle_state *state) |
154 | { | 210 | { |
155 | struct cpuidle_state *new_state = state; | 211 | struct cpuidle_state *new_state = next_valid_state(dev, state); |
156 | 212 | ||
157 | if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) { | 213 | if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) { |
158 | BUG_ON(!dev->safe_state); | 214 | BUG_ON(!dev->safe_state); |
@@ -165,6 +221,30 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, | |||
165 | 221 | ||
166 | DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); | 222 | DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); |
167 | 223 | ||
224 | /** | ||
225 | * omap3_cpuidle_update_states - Update the cpuidle states. | ||
226 | * | ||
227 | * Currently, this function toggles the validity of idle states based upon | ||
228 | * the flag 'enable_off_mode'. When the flag is set all states are valid. | ||
229 | * Else, states leading to OFF state set to be invalid. | ||
230 | */ | ||
231 | void omap3_cpuidle_update_states(void) | ||
232 | { | ||
233 | int i; | ||
234 | |||
235 | for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) { | ||
236 | struct omap3_processor_cx *cx = &omap3_power_states[i]; | ||
237 | |||
238 | if (enable_off_mode) { | ||
239 | cx->valid = 1; | ||
240 | } else { | ||
241 | if ((cx->mpu_state == PWRDM_POWER_OFF) || | ||
242 | (cx->core_state == PWRDM_POWER_OFF)) | ||
243 | cx->valid = 0; | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
168 | /* omap3_init_power_states - Initialises the OMAP3 specific C states. | 248 | /* omap3_init_power_states - Initialises the OMAP3 specific C states. |
169 | * | 249 | * |
170 | * Below is the desciption of each C state. | 250 | * Below is the desciption of each C state. |
@@ -302,6 +382,8 @@ int __init omap3_idle_init(void) | |||
302 | return -EINVAL; | 382 | return -EINVAL; |
303 | dev->state_count = count; | 383 | dev->state_count = count; |
304 | 384 | ||
385 | omap3_cpuidle_update_states(); | ||
386 | |||
305 | if (cpuidle_register_device(dev)) { | 387 | if (cpuidle_register_device(dev)) { |
306 | printk(KERN_ERR "%s: CPUidle register device failed\n", | 388 | printk(KERN_ERR "%s: CPUidle register device failed\n", |
307 | __func__); | 389 | __func__); |