X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=blobdiff_plain;f=drivers%2Fcpuidle%2Fcpuidle.c;h=a507108433785f8432b3d15504c3a036b461c1a0;hp=dbefe15bd582804497cbca76b6f3ce4fae6e28da;hb=71abbbf856a0e70ca478782505c800891260ba84;hpb=90c8327cad5d7c2d5d7d3e761d17af1925474107 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) */ hrtimer_peek_ahead_timers(); #endif + + /* + * Call the device's prepare function before calling the + * governor's select function. ->prepare gives the device's + * cpuidle driver a chance to update any dynamic information + * of its cpuidle states for the current idle period, e.g. + * state availability, latencies, residencies, etc. + */ + if (dev->prepare) + dev->prepare(dev); + /* ask the governor for the next state */ next_state = cpuidle_curr_governor->select(dev); if (need_resched()) { @@ -282,6 +293,26 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) poll_idle_init(dev); + /* + * cpuidle driver should set the dev->power_specified bit + * before registering the device if the driver provides + * power_usage numbers. + * + * For those devices whose ->power_specified is not set, + * we fill in power_usage with decreasing values as the + * cpuidle code has an implicit assumption that state Cn + * uses less power than C(n-1). + * + * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned + * an power value of -1. So we use -2, -3, etc, for other + * c-states. + */ + if (!dev->power_specified) { + int i; + for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) + dev->states[i].power_usage = -1 - i; + } + per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); if ((ret = cpuidle_add_sysfs(sys_dev))) {