diff options
Diffstat (limited to 'drivers/cpuidle/cpuidle.c')
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index dbefe15bd582..a50710843378 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -74,6 +74,17 @@ static void cpuidle_idle_call(void) | |||
74 | */ | 74 | */ |
75 | hrtimer_peek_ahead_timers(); | 75 | hrtimer_peek_ahead_timers(); |
76 | #endif | 76 | #endif |
77 | |||
78 | /* | ||
79 | * Call the device's prepare function before calling the | ||
80 | * governor's select function. ->prepare gives the device's | ||
81 | * cpuidle driver a chance to update any dynamic information | ||
82 | * of its cpuidle states for the current idle period, e.g. | ||
83 | * state availability, latencies, residencies, etc. | ||
84 | */ | ||
85 | if (dev->prepare) | ||
86 | dev->prepare(dev); | ||
87 | |||
77 | /* ask the governor for the next state */ | 88 | /* ask the governor for the next state */ |
78 | next_state = cpuidle_curr_governor->select(dev); | 89 | next_state = cpuidle_curr_governor->select(dev); |
79 | if (need_resched()) { | 90 | if (need_resched()) { |
@@ -282,6 +293,26 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
282 | 293 | ||
283 | poll_idle_init(dev); | 294 | poll_idle_init(dev); |
284 | 295 | ||
296 | /* | ||
297 | * cpuidle driver should set the dev->power_specified bit | ||
298 | * before registering the device if the driver provides | ||
299 | * power_usage numbers. | ||
300 | * | ||
301 | * For those devices whose ->power_specified is not set, | ||
302 | * we fill in power_usage with decreasing values as the | ||
303 | * cpuidle code has an implicit assumption that state Cn | ||
304 | * uses less power than C(n-1). | ||
305 | * | ||
306 | * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned | ||
307 | * an power value of -1. So we use -2, -3, etc, for other | ||
308 | * c-states. | ||
309 | */ | ||
310 | if (!dev->power_specified) { | ||
311 | int i; | ||
312 | for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) | ||
313 | dev->states[i].power_usage = -1 - i; | ||
314 | } | ||
315 | |||
285 | per_cpu(cpuidle_devices, dev->cpu) = dev; | 316 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
286 | list_add(&dev->device_list, &cpuidle_detected_devices); | 317 | list_add(&dev->device_list, &cpuidle_detected_devices); |
287 | if ((ret = cpuidle_add_sysfs(sys_dev))) { | 318 | if ((ret = cpuidle_add_sysfs(sys_dev))) { |