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/clockchips.h> 12 #include <linux/kernel.h> 13 #include <linux/mutex.h> 14 #include <linux/sched.h> 15 #include <linux/sched/clock.h> 16 #include <linux/notifier.h> 17 #include <linux/pm_qos.h> 18 #include <linux/cpu.h> 19 #include <linux/cpuidle.h> 20 #include <linux/ktime.h> 21 #include <linux/hrtimer.h> 22 #include <linux/module.h> 23 #include <linux/suspend.h> 24 #include <linux/tick.h> 25 #include <linux/mmu_context.h> 26 #include <linux/context_tracking.h> 27 #include <trace/events/power.h> 28 29 #include "cpuidle.h" 30 31 DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); 32 DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev); 33 34 DEFINE_MUTEX(cpuidle_lock); 35 LIST_HEAD(cpuidle_detected_devices); 36 37 static int enabled_devices; 38 static int off __read_mostly; 39 static int initialized __read_mostly; 40 41 int cpuidle_disabled(void) 42 { 43 return off; 44 } 45 void disable_cpuidle(void) 46 { 47 off = 1; 48 } 49 50 bool cpuidle_not_available(struct cpuidle_driver *drv, 51 struct cpuidle_device *dev) 52 { 53 return off || !initialized || !drv || !dev || !dev->enabled; 54 } 55 56 /** 57 * cpuidle_play_dead - cpu off-lining 58 * 59 * Returns in case of an error or no driver 60 */ 61 int cpuidle_play_dead(void) 62 { 63 struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); 64 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 65 int i; 66 67 if (!drv) 68 return -ENODEV; 69 70 /* Find lowest-power state that supports long-term idle */ 71 for (i = drv->state_count - 1; i >= 0; i--) 72 if (drv->states[i].enter_dead) 73 return drv->states[i].enter_dead(dev, i); 74 75 return -ENODEV; 76 } 77 78 static int find_deepest_state(struct cpuidle_driver *drv, 79 struct cpuidle_device *dev, 80 u64 max_latency_ns, 81 unsigned int forbidden_flags, 82 bool s2idle) 83 { 84 u64 latency_req = 0; 85 int i, ret = 0; 86 87 for (i = 1; i < drv->state_count; i++) { 88 struct cpuidle_state *s = &drv->states[i]; 89 90 if (dev->states_usage[i].disable || 91 s->exit_latency_ns <= latency_req || 92 s->exit_latency_ns > max_latency_ns || 93 (s->flags & forbidden_flags) || 94 (s2idle && !s->enter_s2idle)) 95 continue; 96 97 latency_req = s->exit_latency_ns; 98 ret = i; 99 } 100 return ret; 101 } 102 103 /** 104 * cpuidle_use_deepest_state - Set/unset governor override mode. 105 * @latency_limit_ns: Idle state exit latency limit (or no override if 0). 106 * 107 * If @latency_limit_ns is nonzero, set the current CPU to use the deepest idle 108 * state with exit latency within @latency_limit_ns (override governors going 109 * forward), or do not override governors if it is zero. 110 */ 111 void cpuidle_use_deepest_state(u64 latency_limit_ns) 112 { 113 struct cpuidle_device *dev; 114 115 preempt_disable(); 116 dev = cpuidle_get_device(); 117 if (dev) 118 dev->forced_idle_latency_limit_ns = latency_limit_ns; 119 preempt_enable(); 120 } 121 122 /** 123 * cpuidle_find_deepest_state - Find the deepest available idle state. 124 * @drv: cpuidle driver for the given CPU. 125 * @dev: cpuidle device for the given CPU. 126 * @latency_limit_ns: Idle state exit latency limit 127 * 128 * Return: the index of the deepest available idle state. 129 */ 130 int cpuidle_find_deepest_state(struct cpuidle_driver *drv, 131 struct cpuidle_device *dev, 132 u64 latency_limit_ns) 133 { 134 return find_deepest_state(drv, dev, latency_limit_ns, 0, false); 135 } 136 137 #ifdef CONFIG_SUSPEND 138 static void enter_s2idle_proper(struct cpuidle_driver *drv, 139 struct cpuidle_device *dev, int index) 140 { 141 ktime_t time_start, time_end; 142 struct cpuidle_state *target_state = &drv->states[index]; 143 144 time_start = ns_to_ktime(local_clock()); 145 146 tick_freeze(); 147 /* 148 * The state used here cannot be a "coupled" one, because the "coupled" 149 * cpuidle mechanism enables interrupts and doing that with timekeeping 150 * suspended is generally unsafe. 151 */ 152 stop_critical_timings(); 153 if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 154 ct_idle_enter(); 155 target_state->enter_s2idle(dev, drv, index); 156 if (WARN_ON_ONCE(!irqs_disabled())) 157 local_irq_disable(); 158 if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 159 ct_idle_exit(); 160 tick_unfreeze(); 161 start_critical_timings(); 162 163 time_end = ns_to_ktime(local_clock()); 164 165 dev->states_usage[index].s2idle_time += ktime_us_delta(time_end, time_start); 166 dev->states_usage[index].s2idle_usage++; 167 } 168 169 /** 170 * cpuidle_enter_s2idle - Enter an idle state suitable for suspend-to-idle. 171 * @drv: cpuidle driver for the given CPU. 172 * @dev: cpuidle device for the given CPU. 173 * 174 * If there are states with the ->enter_s2idle callback, find the deepest of 175 * them and enter it with frozen tick. 176 */ 177 int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev) 178 { 179 int index; 180 181 /* 182 * Find the deepest state with ->enter_s2idle present, which guarantees 183 * that interrupts won't be enabled when it exits and allows the tick to 184 * be frozen safely. 185 */ 186 index = find_deepest_state(drv, dev, U64_MAX, 0, true); 187 if (index > 0) { 188 enter_s2idle_proper(drv, dev, index); 189 local_irq_enable(); 190 } 191 return index; 192 } 193 #endif /* CONFIG_SUSPEND */ 194 195 /** 196 * cpuidle_enter_state - enter the state and update stats 197 * @dev: cpuidle device for this cpu 198 * @drv: cpuidle driver for this cpu 199 * @index: index into the states table in @drv of the state to enter 200 */ 201 int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, 202 int index) 203 { 204 int entered_state; 205 206 struct cpuidle_state *target_state = &drv->states[index]; 207 bool broadcast = !!(target_state->flags & CPUIDLE_FLAG_TIMER_STOP); 208 ktime_t time_start, time_end; 209 210 /* 211 * Tell the time framework to switch to a broadcast timer because our 212 * local timer will be shut down. If a local timer is used from another 213 * CPU as a broadcast timer, this call may fail if it is not available. 214 */ 215 if (broadcast && tick_broadcast_enter()) { 216 index = find_deepest_state(drv, dev, target_state->exit_latency_ns, 217 CPUIDLE_FLAG_TIMER_STOP, false); 218 if (index < 0) { 219 default_idle_call(); 220 return -EBUSY; 221 } 222 target_state = &drv->states[index]; 223 broadcast = false; 224 } 225 226 if (target_state->flags & CPUIDLE_FLAG_TLB_FLUSHED) 227 leave_mm(dev->cpu); 228 229 /* Take note of the planned idle state. */ 230 sched_idle_set_state(target_state); 231 232 trace_cpu_idle(index, dev->cpu); 233 time_start = ns_to_ktime(local_clock()); 234 235 stop_critical_timings(); 236 if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 237 ct_idle_enter(); 238 entered_state = target_state->enter(dev, drv, index); 239 if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 240 ct_idle_exit(); 241 start_critical_timings(); 242 243 sched_clock_idle_wakeup_event(); 244 time_end = ns_to_ktime(local_clock()); 245 trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); 246 247 /* The cpu is no longer idle or about to enter idle. */ 248 sched_idle_set_state(NULL); 249 250 if (broadcast) { 251 if (WARN_ON_ONCE(!irqs_disabled())) 252 local_irq_disable(); 253 254 tick_broadcast_exit(); 255 } 256 257 if (!cpuidle_state_is_coupled(drv, index)) 258 local_irq_enable(); 259 260 if (entered_state >= 0) { 261 s64 diff, delay = drv->states[entered_state].exit_latency_ns; 262 int i; 263 264 /* 265 * Update cpuidle counters 266 * This can be moved to within driver enter routine, 267 * but that results in multiple copies of same code. 268 */ 269 diff = ktime_sub(time_end, time_start); 270 271 dev->last_residency_ns = diff; 272 dev->states_usage[entered_state].time_ns += diff; 273 dev->states_usage[entered_state].usage++; 274 275 if (diff < drv->states[entered_state].target_residency_ns) { 276 for (i = entered_state - 1; i >= 0; i--) { 277 if (dev->states_usage[i].disable) 278 continue; 279 280 /* Shallower states are enabled, so update. */ 281 dev->states_usage[entered_state].above++; 282 break; 283 } 284 } else if (diff > delay) { 285 for (i = entered_state + 1; i < drv->state_count; i++) { 286 if (dev->states_usage[i].disable) 287 continue; 288 289 /* 290 * Update if a deeper state would have been a 291 * better match for the observed idle duration. 292 */ 293 if (diff - delay >= drv->states[i].target_residency_ns) 294 dev->states_usage[entered_state].below++; 295 296 break; 297 } 298 } 299 } else { 300 dev->last_residency_ns = 0; 301 dev->states_usage[index].rejected++; 302 } 303 304 return entered_state; 305 } 306 307 /** 308 * cpuidle_select - ask the cpuidle framework to choose an idle state 309 * 310 * @drv: the cpuidle driver 311 * @dev: the cpuidle device 312 * @stop_tick: indication on whether or not to stop the tick 313 * 314 * Returns the index of the idle state. The return value must not be negative. 315 * 316 * The memory location pointed to by @stop_tick is expected to be written the 317 * 'false' boolean value if the scheduler tick should not be stopped before 318 * entering the returned state. 319 */ 320 int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, 321 bool *stop_tick) 322 { 323 return cpuidle_curr_governor->select(drv, dev, stop_tick); 324 } 325 326 /** 327 * cpuidle_enter - enter into the specified idle state 328 * 329 * @drv: the cpuidle driver tied with the cpu 330 * @dev: the cpuidle device 331 * @index: the index in the idle state table 332 * 333 * Returns the index in the idle state, < 0 in case of error. 334 * The error code depends on the backend driver 335 */ 336 int cpuidle_enter(struct cpuidle_driver *drv, struct cpuidle_device *dev, 337 int index) 338 { 339 int ret = 0; 340 341 /* 342 * Store the next hrtimer, which becomes either next tick or the next 343 * timer event, whatever expires first. Additionally, to make this data 344 * useful for consumers outside cpuidle, we rely on that the governor's 345 * ->select() callback have decided, whether to stop the tick or not. 346 */ 347 WRITE_ONCE(dev->next_hrtimer, tick_nohz_get_next_hrtimer()); 348 349 if (cpuidle_state_is_coupled(drv, index)) 350 ret = cpuidle_enter_state_coupled(dev, drv, index); 351 else 352 ret = cpuidle_enter_state(dev, drv, index); 353 354 WRITE_ONCE(dev->next_hrtimer, 0); 355 return ret; 356 } 357 358 /** 359 * cpuidle_reflect - tell the underlying governor what was the state 360 * we were in 361 * 362 * @dev : the cpuidle device 363 * @index: the index in the idle state table 364 * 365 */ 366 void cpuidle_reflect(struct cpuidle_device *dev, int index) 367 { 368 if (cpuidle_curr_governor->reflect && index >= 0) 369 cpuidle_curr_governor->reflect(dev, index); 370 } 371 372 /* 373 * Min polling interval of 10usec is a guess. It is assuming that 374 * for most users, the time for a single ping-pong workload like 375 * perf bench pipe would generally complete within 10usec but 376 * this is hardware dependant. Actual time can be estimated with 377 * 378 * perf bench sched pipe -l 10000 379 * 380 * Run multiple times to avoid cpufreq effects. 381 */ 382 #define CPUIDLE_POLL_MIN 10000 383 #define CPUIDLE_POLL_MAX (TICK_NSEC / 16) 384 385 /** 386 * cpuidle_poll_time - return amount of time to poll for, 387 * governors can override dev->poll_limit_ns if necessary 388 * 389 * @drv: the cpuidle driver tied with the cpu 390 * @dev: the cpuidle device 391 * 392 */ 393 u64 cpuidle_poll_time(struct cpuidle_driver *drv, 394 struct cpuidle_device *dev) 395 { 396 int i; 397 u64 limit_ns; 398 399 BUILD_BUG_ON(CPUIDLE_POLL_MIN > CPUIDLE_POLL_MAX); 400 401 if (dev->poll_limit_ns) 402 return dev->poll_limit_ns; 403 404 limit_ns = CPUIDLE_POLL_MAX; 405 for (i = 1; i < drv->state_count; i++) { 406 u64 state_limit; 407 408 if (dev->states_usage[i].disable) 409 continue; 410 411 state_limit = drv->states[i].target_residency_ns; 412 if (state_limit < CPUIDLE_POLL_MIN) 413 continue; 414 415 limit_ns = min_t(u64, state_limit, CPUIDLE_POLL_MAX); 416 break; 417 } 418 419 dev->poll_limit_ns = limit_ns; 420 421 return dev->poll_limit_ns; 422 } 423 424 /** 425 * cpuidle_install_idle_handler - installs the cpuidle idle loop handler 426 */ 427 void cpuidle_install_idle_handler(void) 428 { 429 if (enabled_devices) { 430 /* Make sure all changes finished before we switch to new idle */ 431 smp_wmb(); 432 initialized = 1; 433 } 434 } 435 436 /** 437 * cpuidle_uninstall_idle_handler - uninstalls the cpuidle idle loop handler 438 */ 439 void cpuidle_uninstall_idle_handler(void) 440 { 441 if (enabled_devices) { 442 initialized = 0; 443 wake_up_all_idle_cpus(); 444 } 445 446 /* 447 * Make sure external observers (such as the scheduler) 448 * are done looking at pointed idle states. 449 */ 450 synchronize_rcu(); 451 } 452 453 /** 454 * cpuidle_pause_and_lock - temporarily disables CPUIDLE 455 */ 456 void cpuidle_pause_and_lock(void) 457 { 458 mutex_lock(&cpuidle_lock); 459 cpuidle_uninstall_idle_handler(); 460 } 461 462 EXPORT_SYMBOL_GPL(cpuidle_pause_and_lock); 463 464 /** 465 * cpuidle_resume_and_unlock - resumes CPUIDLE operation 466 */ 467 void cpuidle_resume_and_unlock(void) 468 { 469 cpuidle_install_idle_handler(); 470 mutex_unlock(&cpuidle_lock); 471 } 472 473 EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); 474 475 /* Currently used in suspend/resume path to suspend cpuidle */ 476 void cpuidle_pause(void) 477 { 478 mutex_lock(&cpuidle_lock); 479 cpuidle_uninstall_idle_handler(); 480 mutex_unlock(&cpuidle_lock); 481 } 482 483 /* Currently used in suspend/resume path to resume cpuidle */ 484 void cpuidle_resume(void) 485 { 486 mutex_lock(&cpuidle_lock); 487 cpuidle_install_idle_handler(); 488 mutex_unlock(&cpuidle_lock); 489 } 490 491 /** 492 * cpuidle_enable_device - enables idle PM for a CPU 493 * @dev: the CPU 494 * 495 * This function must be called between cpuidle_pause_and_lock and 496 * cpuidle_resume_and_unlock when used externally. 497 */ 498 int cpuidle_enable_device(struct cpuidle_device *dev) 499 { 500 int ret; 501 struct cpuidle_driver *drv; 502 503 if (!dev) 504 return -EINVAL; 505 506 if (dev->enabled) 507 return 0; 508 509 if (!cpuidle_curr_governor) 510 return -EIO; 511 512 drv = cpuidle_get_cpu_driver(dev); 513 514 if (!drv) 515 return -EIO; 516 517 if (!dev->registered) 518 return -EINVAL; 519 520 ret = cpuidle_add_device_sysfs(dev); 521 if (ret) 522 return ret; 523 524 if (cpuidle_curr_governor->enable) { 525 ret = cpuidle_curr_governor->enable(drv, dev); 526 if (ret) 527 goto fail_sysfs; 528 } 529 530 smp_wmb(); 531 532 dev->enabled = 1; 533 534 enabled_devices++; 535 return 0; 536 537 fail_sysfs: 538 cpuidle_remove_device_sysfs(dev); 539 540 return ret; 541 } 542 543 EXPORT_SYMBOL_GPL(cpuidle_enable_device); 544 545 /** 546 * cpuidle_disable_device - disables idle PM for a CPU 547 * @dev: the CPU 548 * 549 * This function must be called between cpuidle_pause_and_lock and 550 * cpuidle_resume_and_unlock when used externally. 551 */ 552 void cpuidle_disable_device(struct cpuidle_device *dev) 553 { 554 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 555 556 if (!dev || !dev->enabled) 557 return; 558 559 if (!drv || !cpuidle_curr_governor) 560 return; 561 562 dev->enabled = 0; 563 564 if (cpuidle_curr_governor->disable) 565 cpuidle_curr_governor->disable(drv, dev); 566 567 cpuidle_remove_device_sysfs(dev); 568 enabled_devices--; 569 } 570 571 EXPORT_SYMBOL_GPL(cpuidle_disable_device); 572 573 static void __cpuidle_unregister_device(struct cpuidle_device *dev) 574 { 575 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 576 577 list_del(&dev->device_list); 578 per_cpu(cpuidle_devices, dev->cpu) = NULL; 579 module_put(drv->owner); 580 581 dev->registered = 0; 582 } 583 584 static void __cpuidle_device_init(struct cpuidle_device *dev) 585 { 586 memset(dev->states_usage, 0, sizeof(dev->states_usage)); 587 dev->last_residency_ns = 0; 588 dev->next_hrtimer = 0; 589 } 590 591 /** 592 * __cpuidle_register_device - internal register function called before register 593 * and enable routines 594 * @dev: the cpu 595 * 596 * cpuidle_lock mutex must be held before this is called 597 */ 598 static int __cpuidle_register_device(struct cpuidle_device *dev) 599 { 600 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 601 int i, ret; 602 603 if (!try_module_get(drv->owner)) 604 return -EINVAL; 605 606 for (i = 0; i < drv->state_count; i++) { 607 if (drv->states[i].flags & CPUIDLE_FLAG_UNUSABLE) 608 dev->states_usage[i].disable |= CPUIDLE_STATE_DISABLED_BY_DRIVER; 609 610 if (drv->states[i].flags & CPUIDLE_FLAG_OFF) 611 dev->states_usage[i].disable |= CPUIDLE_STATE_DISABLED_BY_USER; 612 } 613 614 per_cpu(cpuidle_devices, dev->cpu) = dev; 615 list_add(&dev->device_list, &cpuidle_detected_devices); 616 617 ret = cpuidle_coupled_register_device(dev); 618 if (ret) 619 __cpuidle_unregister_device(dev); 620 else 621 dev->registered = 1; 622 623 return ret; 624 } 625 626 /** 627 * cpuidle_register_device - registers a CPU's idle PM feature 628 * @dev: the cpu 629 */ 630 int cpuidle_register_device(struct cpuidle_device *dev) 631 { 632 int ret = -EBUSY; 633 634 if (!dev) 635 return -EINVAL; 636 637 mutex_lock(&cpuidle_lock); 638 639 if (dev->registered) 640 goto out_unlock; 641 642 __cpuidle_device_init(dev); 643 644 ret = __cpuidle_register_device(dev); 645 if (ret) 646 goto out_unlock; 647 648 ret = cpuidle_add_sysfs(dev); 649 if (ret) 650 goto out_unregister; 651 652 ret = cpuidle_enable_device(dev); 653 if (ret) 654 goto out_sysfs; 655 656 cpuidle_install_idle_handler(); 657 658 out_unlock: 659 mutex_unlock(&cpuidle_lock); 660 661 return ret; 662 663 out_sysfs: 664 cpuidle_remove_sysfs(dev); 665 out_unregister: 666 __cpuidle_unregister_device(dev); 667 goto out_unlock; 668 } 669 670 EXPORT_SYMBOL_GPL(cpuidle_register_device); 671 672 /** 673 * cpuidle_unregister_device - unregisters a CPU's idle PM feature 674 * @dev: the cpu 675 */ 676 void cpuidle_unregister_device(struct cpuidle_device *dev) 677 { 678 if (!dev || dev->registered == 0) 679 return; 680 681 cpuidle_pause_and_lock(); 682 683 cpuidle_disable_device(dev); 684 685 cpuidle_remove_sysfs(dev); 686 687 __cpuidle_unregister_device(dev); 688 689 cpuidle_coupled_unregister_device(dev); 690 691 cpuidle_resume_and_unlock(); 692 } 693 694 EXPORT_SYMBOL_GPL(cpuidle_unregister_device); 695 696 /** 697 * cpuidle_unregister: unregister a driver and the devices. This function 698 * can be used only if the driver has been previously registered through 699 * the cpuidle_register function. 700 * 701 * @drv: a valid pointer to a struct cpuidle_driver 702 */ 703 void cpuidle_unregister(struct cpuidle_driver *drv) 704 { 705 int cpu; 706 struct cpuidle_device *device; 707 708 for_each_cpu(cpu, drv->cpumask) { 709 device = &per_cpu(cpuidle_dev, cpu); 710 cpuidle_unregister_device(device); 711 } 712 713 cpuidle_unregister_driver(drv); 714 } 715 EXPORT_SYMBOL_GPL(cpuidle_unregister); 716 717 /** 718 * cpuidle_register: registers the driver and the cpu devices with the 719 * coupled_cpus passed as parameter. This function is used for all common 720 * initialization pattern there are in the arch specific drivers. The 721 * devices is globally defined in this file. 722 * 723 * @drv : a valid pointer to a struct cpuidle_driver 724 * @coupled_cpus: a cpumask for the coupled states 725 * 726 * Returns 0 on success, < 0 otherwise 727 */ 728 int cpuidle_register(struct cpuidle_driver *drv, 729 const struct cpumask *const coupled_cpus) 730 { 731 int ret, cpu; 732 struct cpuidle_device *device; 733 734 ret = cpuidle_register_driver(drv); 735 if (ret) { 736 pr_err("failed to register cpuidle driver\n"); 737 return ret; 738 } 739 740 for_each_cpu(cpu, drv->cpumask) { 741 device = &per_cpu(cpuidle_dev, cpu); 742 device->cpu = cpu; 743 744 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED 745 /* 746 * On multiplatform for ARM, the coupled idle states could be 747 * enabled in the kernel even if the cpuidle driver does not 748 * use it. Note, coupled_cpus is a struct copy. 749 */ 750 if (coupled_cpus) 751 device->coupled_cpus = *coupled_cpus; 752 #endif 753 ret = cpuidle_register_device(device); 754 if (!ret) 755 continue; 756 757 pr_err("Failed to register cpuidle device for cpu%d\n", cpu); 758 759 cpuidle_unregister(drv); 760 break; 761 } 762 763 return ret; 764 } 765 EXPORT_SYMBOL_GPL(cpuidle_register); 766 767 /** 768 * cpuidle_init - core initializer 769 */ 770 static int __init cpuidle_init(void) 771 { 772 if (cpuidle_disabled()) 773 return -ENODEV; 774 775 return cpuidle_add_interface(cpu_subsys.dev_root); 776 } 777 778 module_param(off, int, 0444); 779 module_param_string(governor, param_governor, CPUIDLE_NAME_LEN, 0444); 780 core_initcall(cpuidle_init); 781