Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 1 | /* |
| 2 | * cpuidle.c - core cpuidle infrastructure |
| 3 | * |
| 4 | * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> |
| 5 | * Shaohua Li <shaohua.li@intel.com> |
| 6 | * Adam Belay <abelay@novell.com> |
| 7 | * |
| 8 | * This code is licenced under the GPL. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/mutex.h> |
| 13 | #include <linux/sched.h> |
| 14 | #include <linux/notifier.h> |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 15 | #include <linux/pm_qos_params.h> |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 16 | #include <linux/cpu.h> |
| 17 | #include <linux/cpuidle.h> |
venkatesh.pallipadi@intel.com | 9a0b841 | 2008-01-31 17:35:06 -0800 | [diff] [blame] | 18 | #include <linux/ktime.h> |
Arjan van de Ven | 2e94d1f | 2008-09-10 16:06:00 -0700 | [diff] [blame] | 19 | #include <linux/hrtimer.h> |
Arjan van de Ven | 288f023 | 2009-09-19 13:35:33 +0200 | [diff] [blame] | 20 | #include <trace/events/power.h> |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 21 | |
| 22 | #include "cpuidle.h" |
| 23 | |
| 24 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 25 | |
| 26 | DEFINE_MUTEX(cpuidle_lock); |
| 27 | LIST_HEAD(cpuidle_detected_devices); |
| 28 | static void (*pm_idle_old)(void); |
| 29 | |
| 30 | static int enabled_devices; |
| 31 | |
Venki Pallipadi | a6869cc | 2008-02-08 17:05:44 -0800 | [diff] [blame] | 32 | #if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT) |
| 33 | static void cpuidle_kick_cpus(void) |
| 34 | { |
| 35 | cpu_idle_wait(); |
| 36 | } |
| 37 | #elif defined(CONFIG_SMP) |
| 38 | # error "Arch needs cpu_idle_wait() equivalent here" |
| 39 | #else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT && !CONFIG_SMP */ |
| 40 | static void cpuidle_kick_cpus(void) {} |
| 41 | #endif |
| 42 | |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 43 | static int __cpuidle_register_device(struct cpuidle_device *dev); |
| 44 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 45 | /** |
| 46 | * cpuidle_idle_call - the main idle loop |
| 47 | * |
| 48 | * NOTE: no locks or semaphores should be used here |
| 49 | */ |
| 50 | static void cpuidle_idle_call(void) |
| 51 | { |
| 52 | struct cpuidle_device *dev = __get_cpu_var(cpuidle_devices); |
| 53 | struct cpuidle_state *target_state; |
| 54 | int next_state; |
| 55 | |
| 56 | /* check if the device is ready */ |
| 57 | if (!dev || !dev->enabled) { |
| 58 | if (pm_idle_old) |
| 59 | pm_idle_old(); |
| 60 | else |
Venkatesh Pallipadi | 89cedfe | 2008-10-16 19:00:08 -0400 | [diff] [blame] | 61 | #if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE) |
| 62 | default_idle(); |
| 63 | #else |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 64 | local_irq_enable(); |
Venkatesh Pallipadi | 89cedfe | 2008-10-16 19:00:08 -0400 | [diff] [blame] | 65 | #endif |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 66 | return; |
| 67 | } |
| 68 | |
Arjan van de Ven | 9a65583 | 2008-11-09 12:45:10 -0800 | [diff] [blame] | 69 | #if 0 |
| 70 | /* shows regressions, re-enable for 2.6.29 */ |
Arjan van de Ven | 2e94d1f | 2008-09-10 16:06:00 -0700 | [diff] [blame] | 71 | /* |
| 72 | * run any timers that can be run now, at this point |
| 73 | * before calculating the idle duration etc. |
| 74 | */ |
| 75 | hrtimer_peek_ahead_timers(); |
Arjan van de Ven | 9a65583 | 2008-11-09 12:45:10 -0800 | [diff] [blame] | 76 | #endif |
Ai Li | 71abbbf | 2010-08-09 17:20:13 -0700 | [diff] [blame] | 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 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 88 | /* ask the governor for the next state */ |
| 89 | next_state = cpuidle_curr_governor->select(dev); |
Kevin Hilman | 246eb7f | 2009-10-26 16:50:18 -0700 | [diff] [blame] | 90 | if (need_resched()) { |
| 91 | local_irq_enable(); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 92 | return; |
Kevin Hilman | 246eb7f | 2009-10-26 16:50:18 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 95 | target_state = &dev->states[next_state]; |
| 96 | |
| 97 | /* enter the state and update stats */ |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 98 | dev->last_state = target_state; |
Venkatesh Pallipadi | 887e301 | 2008-09-29 15:24:27 -0700 | [diff] [blame] | 99 | dev->last_residency = target_state->enter(dev, target_state); |
| 100 | if (dev->last_state) |
| 101 | target_state = dev->last_state; |
| 102 | |
Yi Yang | 8b78cf6 | 2008-02-25 08:46:12 +0800 | [diff] [blame] | 103 | target_state->time += (unsigned long long)dev->last_residency; |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 104 | target_state->usage++; |
| 105 | |
| 106 | /* give the governor an opportunity to reflect on the outcome */ |
| 107 | if (cpuidle_curr_governor->reflect) |
| 108 | cpuidle_curr_governor->reflect(dev); |
Thomas Renninger | 6f4f272 | 2010-04-20 13:17:36 +0200 | [diff] [blame] | 109 | trace_power_end(smp_processor_id()); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | /** |
| 113 | * cpuidle_install_idle_handler - installs the cpuidle idle loop handler |
| 114 | */ |
| 115 | void cpuidle_install_idle_handler(void) |
| 116 | { |
| 117 | if (enabled_devices && (pm_idle != cpuidle_idle_call)) { |
| 118 | /* Make sure all changes finished before we switch to new idle */ |
| 119 | smp_wmb(); |
| 120 | pm_idle = cpuidle_idle_call; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * cpuidle_uninstall_idle_handler - uninstalls the cpuidle idle loop handler |
| 126 | */ |
| 127 | void cpuidle_uninstall_idle_handler(void) |
| 128 | { |
Thomas Gleixner | b032bf70d | 2008-07-27 23:47:12 +0200 | [diff] [blame] | 129 | if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 130 | pm_idle = pm_idle_old; |
Venki Pallipadi | a6869cc | 2008-02-08 17:05:44 -0800 | [diff] [blame] | 131 | cpuidle_kick_cpus(); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * cpuidle_pause_and_lock - temporarily disables CPUIDLE |
| 137 | */ |
| 138 | void cpuidle_pause_and_lock(void) |
| 139 | { |
| 140 | mutex_lock(&cpuidle_lock); |
| 141 | cpuidle_uninstall_idle_handler(); |
| 142 | } |
| 143 | |
| 144 | EXPORT_SYMBOL_GPL(cpuidle_pause_and_lock); |
| 145 | |
| 146 | /** |
| 147 | * cpuidle_resume_and_unlock - resumes CPUIDLE operation |
| 148 | */ |
| 149 | void cpuidle_resume_and_unlock(void) |
| 150 | { |
| 151 | cpuidle_install_idle_handler(); |
| 152 | mutex_unlock(&cpuidle_lock); |
| 153 | } |
| 154 | |
| 155 | EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); |
| 156 | |
| 157 | /** |
| 158 | * cpuidle_enable_device - enables idle PM for a CPU |
| 159 | * @dev: the CPU |
| 160 | * |
| 161 | * This function must be called between cpuidle_pause_and_lock and |
| 162 | * cpuidle_resume_and_unlock when used externally. |
| 163 | */ |
| 164 | int cpuidle_enable_device(struct cpuidle_device *dev) |
| 165 | { |
| 166 | int ret, i; |
| 167 | |
| 168 | if (dev->enabled) |
| 169 | return 0; |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 170 | if (!cpuidle_get_driver() || !cpuidle_curr_governor) |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 171 | return -EIO; |
| 172 | if (!dev->state_count) |
| 173 | return -EINVAL; |
| 174 | |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 175 | if (dev->registered == 0) { |
| 176 | ret = __cpuidle_register_device(dev); |
| 177 | if (ret) |
| 178 | return ret; |
| 179 | } |
| 180 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 181 | if ((ret = cpuidle_add_state_sysfs(dev))) |
| 182 | return ret; |
| 183 | |
| 184 | if (cpuidle_curr_governor->enable && |
| 185 | (ret = cpuidle_curr_governor->enable(dev))) |
| 186 | goto fail_sysfs; |
| 187 | |
| 188 | for (i = 0; i < dev->state_count; i++) { |
| 189 | dev->states[i].usage = 0; |
| 190 | dev->states[i].time = 0; |
| 191 | } |
| 192 | dev->last_residency = 0; |
| 193 | dev->last_state = NULL; |
| 194 | |
| 195 | smp_wmb(); |
| 196 | |
| 197 | dev->enabled = 1; |
| 198 | |
| 199 | enabled_devices++; |
| 200 | return 0; |
| 201 | |
| 202 | fail_sysfs: |
| 203 | cpuidle_remove_state_sysfs(dev); |
| 204 | |
| 205 | return ret; |
| 206 | } |
| 207 | |
| 208 | EXPORT_SYMBOL_GPL(cpuidle_enable_device); |
| 209 | |
| 210 | /** |
| 211 | * cpuidle_disable_device - disables idle PM for a CPU |
| 212 | * @dev: the CPU |
| 213 | * |
| 214 | * This function must be called between cpuidle_pause_and_lock and |
| 215 | * cpuidle_resume_and_unlock when used externally. |
| 216 | */ |
| 217 | void cpuidle_disable_device(struct cpuidle_device *dev) |
| 218 | { |
| 219 | if (!dev->enabled) |
| 220 | return; |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 221 | if (!cpuidle_get_driver() || !cpuidle_curr_governor) |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 222 | return; |
| 223 | |
| 224 | dev->enabled = 0; |
| 225 | |
| 226 | if (cpuidle_curr_governor->disable) |
| 227 | cpuidle_curr_governor->disable(dev); |
| 228 | |
| 229 | cpuidle_remove_state_sysfs(dev); |
| 230 | enabled_devices--; |
| 231 | } |
| 232 | |
| 233 | EXPORT_SYMBOL_GPL(cpuidle_disable_device); |
| 234 | |
venkatesh.pallipadi@intel.com | 9a0b841 | 2008-01-31 17:35:06 -0800 | [diff] [blame] | 235 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX |
| 236 | static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st) |
| 237 | { |
| 238 | ktime_t t1, t2; |
| 239 | s64 diff; |
| 240 | int ret; |
| 241 | |
| 242 | t1 = ktime_get(); |
| 243 | local_irq_enable(); |
| 244 | while (!need_resched()) |
| 245 | cpu_relax(); |
| 246 | |
| 247 | t2 = ktime_get(); |
| 248 | diff = ktime_to_us(ktime_sub(t2, t1)); |
| 249 | if (diff > INT_MAX) |
| 250 | diff = INT_MAX; |
| 251 | |
| 252 | ret = (int) diff; |
| 253 | return ret; |
| 254 | } |
| 255 | |
| 256 | static void poll_idle_init(struct cpuidle_device *dev) |
| 257 | { |
| 258 | struct cpuidle_state *state = &dev->states[0]; |
| 259 | |
| 260 | cpuidle_set_statedata(state, NULL); |
| 261 | |
Venkatesh Pallipadi | 4fcb2fc | 2008-02-11 17:46:31 -0800 | [diff] [blame] | 262 | snprintf(state->name, CPUIDLE_NAME_LEN, "C0"); |
| 263 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); |
venkatesh.pallipadi@intel.com | 9a0b841 | 2008-01-31 17:35:06 -0800 | [diff] [blame] | 264 | state->exit_latency = 0; |
| 265 | state->target_residency = 0; |
| 266 | state->power_usage = -1; |
Venki Pallipadi | 8e92b66 | 2008-02-29 10:24:32 -0800 | [diff] [blame] | 267 | state->flags = CPUIDLE_FLAG_POLL; |
venkatesh.pallipadi@intel.com | 9a0b841 | 2008-01-31 17:35:06 -0800 | [diff] [blame] | 268 | state->enter = poll_idle; |
| 269 | } |
| 270 | #else |
| 271 | static void poll_idle_init(struct cpuidle_device *dev) {} |
| 272 | #endif /* CONFIG_ARCH_HAS_CPU_RELAX */ |
| 273 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 274 | /** |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 275 | * __cpuidle_register_device - internal register function called before register |
| 276 | * and enable routines |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 277 | * @dev: the cpu |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 278 | * |
| 279 | * cpuidle_lock mutex must be held before this is called |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 280 | */ |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 281 | static int __cpuidle_register_device(struct cpuidle_device *dev) |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 282 | { |
| 283 | int ret; |
| 284 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 285 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 286 | |
| 287 | if (!sys_dev) |
| 288 | return -EINVAL; |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 289 | if (!try_module_get(cpuidle_driver->owner)) |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 290 | return -EINVAL; |
| 291 | |
| 292 | init_completion(&dev->kobj_unregister); |
| 293 | |
venkatesh.pallipadi@intel.com | 9a0b841 | 2008-01-31 17:35:06 -0800 | [diff] [blame] | 294 | poll_idle_init(dev); |
| 295 | |
Ai Li | 71abbbf | 2010-08-09 17:20:13 -0700 | [diff] [blame] | 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 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 316 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
| 317 | list_add(&dev->device_list, &cpuidle_detected_devices); |
| 318 | if ((ret = cpuidle_add_sysfs(sys_dev))) { |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 319 | module_put(cpuidle_driver->owner); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 320 | return ret; |
| 321 | } |
| 322 | |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 323 | dev->registered = 1; |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * cpuidle_register_device - registers a CPU's idle PM feature |
| 329 | * @dev: the cpu |
| 330 | */ |
| 331 | int cpuidle_register_device(struct cpuidle_device *dev) |
| 332 | { |
| 333 | int ret; |
| 334 | |
| 335 | mutex_lock(&cpuidle_lock); |
| 336 | |
| 337 | if ((ret = __cpuidle_register_device(dev))) { |
| 338 | mutex_unlock(&cpuidle_lock); |
| 339 | return ret; |
| 340 | } |
| 341 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 342 | cpuidle_enable_device(dev); |
| 343 | cpuidle_install_idle_handler(); |
| 344 | |
| 345 | mutex_unlock(&cpuidle_lock); |
| 346 | |
| 347 | return 0; |
| 348 | |
| 349 | } |
| 350 | |
| 351 | EXPORT_SYMBOL_GPL(cpuidle_register_device); |
| 352 | |
| 353 | /** |
| 354 | * cpuidle_unregister_device - unregisters a CPU's idle PM feature |
| 355 | * @dev: the cpu |
| 356 | */ |
| 357 | void cpuidle_unregister_device(struct cpuidle_device *dev) |
| 358 | { |
| 359 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 360 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 361 | |
Venkatesh Pallipadi | dcb84f3 | 2008-05-19 19:09:27 -0400 | [diff] [blame] | 362 | if (dev->registered == 0) |
| 363 | return; |
| 364 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 365 | cpuidle_pause_and_lock(); |
| 366 | |
| 367 | cpuidle_disable_device(dev); |
| 368 | |
| 369 | cpuidle_remove_sysfs(sys_dev); |
| 370 | list_del(&dev->device_list); |
| 371 | wait_for_completion(&dev->kobj_unregister); |
| 372 | per_cpu(cpuidle_devices, dev->cpu) = NULL; |
| 373 | |
| 374 | cpuidle_resume_and_unlock(); |
| 375 | |
Len Brown | 752138d | 2010-05-22 16:57:26 -0400 | [diff] [blame] | 376 | module_put(cpuidle_driver->owner); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | EXPORT_SYMBOL_GPL(cpuidle_unregister_device); |
| 380 | |
| 381 | #ifdef CONFIG_SMP |
| 382 | |
| 383 | static void smp_callback(void *v) |
| 384 | { |
| 385 | /* we already woke the CPU up, nothing more to do */ |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | * This function gets called when a part of the kernel has a new latency |
| 390 | * requirement. This means we need to get all processors out of their C-state, |
| 391 | * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that |
| 392 | * wakes them all right up. |
| 393 | */ |
| 394 | static int cpuidle_latency_notify(struct notifier_block *b, |
| 395 | unsigned long l, void *v) |
| 396 | { |
Jens Axboe | 8691e5a | 2008-06-06 11:18:06 +0200 | [diff] [blame] | 397 | smp_call_function(smp_callback, NULL, 1); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 398 | return NOTIFY_OK; |
| 399 | } |
| 400 | |
| 401 | static struct notifier_block cpuidle_latency_notifier = { |
| 402 | .notifier_call = cpuidle_latency_notify, |
| 403 | }; |
| 404 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 405 | static inline void latency_notifier_init(struct notifier_block *n) |
| 406 | { |
| 407 | pm_qos_add_notifier(PM_QOS_CPU_DMA_LATENCY, n); |
| 408 | } |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 409 | |
| 410 | #else /* CONFIG_SMP */ |
| 411 | |
| 412 | #define latency_notifier_init(x) do { } while (0) |
| 413 | |
| 414 | #endif /* CONFIG_SMP */ |
| 415 | |
| 416 | /** |
| 417 | * cpuidle_init - core initializer |
| 418 | */ |
| 419 | static int __init cpuidle_init(void) |
| 420 | { |
| 421 | int ret; |
| 422 | |
| 423 | pm_idle_old = pm_idle; |
| 424 | |
| 425 | ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); |
| 426 | if (ret) |
| 427 | return ret; |
| 428 | |
| 429 | latency_notifier_init(&cpuidle_latency_notifier); |
| 430 | |
| 431 | return 0; |
| 432 | } |
| 433 | |
| 434 | core_initcall(cpuidle_init); |