1 // SPDX-License-Identifier: GPL-2.0-only
3 * intel_idle.c - native hardware idle loop for modern Intel processors
5 * Copyright (c) 2013, Intel Corporation.
6 * Len Brown <len.brown@intel.com>
10 * intel_idle is a cpuidle driver that loads on specific Intel processors
11 * in lieu of the legacy ACPI processor_idle driver. The intent is to
12 * make Linux more efficient on these processors, as intel_idle knows
13 * more than ACPI, as well as make Linux more immune to ACPI BIOS bugs.
19 * All CPUs have same idle states as boot CPU
21 * Chipset BM_STS (bus master status) bit is a NOP
22 * for preventing entry into deep C-stats
28 * The driver currently initializes for_each_online_cpu() upon modprobe.
29 * It it unaware of subsequent processors hot-added to the system.
30 * This means that if you boot with maxcpus=n and later online
31 * processors above n, those processors will use C1 only.
33 * ACPI has a .suspend hack to turn off deep c-statees during suspend
34 * to avoid complications with the lapic timer workaround.
35 * Have not seen issues with suspend, but may need same workaround here.
39 /* un-comment DEBUG to enable pr_debug() statements */
42 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
44 #include <linux/acpi.h>
45 #include <linux/kernel.h>
46 #include <linux/cpuidle.h>
47 #include <linux/tick.h>
48 #include <trace/events/power.h>
49 #include <linux/sched.h>
50 #include <linux/notifier.h>
51 #include <linux/cpu.h>
52 #include <linux/moduleparam.h>
53 #include <asm/cpu_device_id.h>
54 #include <asm/intel-family.h>
55 #include <asm/mwait.h>
58 #define INTEL_IDLE_VERSION "0.4.1"
60 static struct cpuidle_driver intel_idle_driver = {
64 /* intel_idle.max_cstate=0 disables driver */
65 static int max_cstate = CPUIDLE_STATE_MAX - 1;
67 static unsigned int mwait_substates;
69 #define LAPIC_TIMER_ALWAYS_RELIABLE 0xFFFFFFFF
70 /* Reliable LAPIC Timer States, bit 1 for C1 etc. */
71 static unsigned int lapic_timer_reliable_states = (1 << 1); /* Default to only C1 */
74 struct cpuidle_state *state_table;
77 * Hardware C-state auto-demotion may not always be optimal.
78 * Indicate which enable bits to clear here.
80 unsigned long auto_demotion_disable_flags;
81 bool byt_auto_demotion_disable_flag;
82 bool disable_promotion_to_c1e;
85 static const struct idle_cpu *icpu;
86 static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;
87 static int intel_idle(struct cpuidle_device *dev,
88 struct cpuidle_driver *drv, int index);
89 static void intel_idle_s2idle(struct cpuidle_device *dev,
90 struct cpuidle_driver *drv, int index);
91 static struct cpuidle_state *cpuidle_state_table;
94 * Set this flag for states where the HW flushes the TLB for us
95 * and so we don't need cross-calls to keep it consistent.
96 * If this flag is set, SW flushes the TLB, so even if the
97 * HW doesn't do the flushing, this flag is safe to use.
99 #define CPUIDLE_FLAG_TLB_FLUSHED 0x10000
102 * MWAIT takes an 8-bit "hint" in EAX "suggesting"
103 * the C-state (top nibble) and sub-state (bottom nibble)
104 * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.
106 * We store the hint at the top of our "flags" for each state.
108 #define flg2MWAIT(flags) (((flags) >> 24) & 0xFF)
109 #define MWAIT2flg(eax) ((eax & 0xFF) << 24)
112 * States are indexed by the cstate number,
113 * which is also the index into the MWAIT hint array.
114 * Thus C0 is a dummy.
116 static struct cpuidle_state nehalem_cstates[] = {
119 .desc = "MWAIT 0x00",
120 .flags = MWAIT2flg(0x00),
122 .target_residency = 6,
123 .enter = &intel_idle,
124 .enter_s2idle = intel_idle_s2idle, },
127 .desc = "MWAIT 0x01",
128 .flags = MWAIT2flg(0x01),
130 .target_residency = 20,
131 .enter = &intel_idle,
132 .enter_s2idle = intel_idle_s2idle, },
135 .desc = "MWAIT 0x10",
136 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
138 .target_residency = 80,
139 .enter = &intel_idle,
140 .enter_s2idle = intel_idle_s2idle, },
143 .desc = "MWAIT 0x20",
144 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
146 .target_residency = 800,
147 .enter = &intel_idle,
148 .enter_s2idle = intel_idle_s2idle, },
153 static struct cpuidle_state snb_cstates[] = {
156 .desc = "MWAIT 0x00",
157 .flags = MWAIT2flg(0x00),
159 .target_residency = 2,
160 .enter = &intel_idle,
161 .enter_s2idle = intel_idle_s2idle, },
164 .desc = "MWAIT 0x01",
165 .flags = MWAIT2flg(0x01),
167 .target_residency = 20,
168 .enter = &intel_idle,
169 .enter_s2idle = intel_idle_s2idle, },
172 .desc = "MWAIT 0x10",
173 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
175 .target_residency = 211,
176 .enter = &intel_idle,
177 .enter_s2idle = intel_idle_s2idle, },
180 .desc = "MWAIT 0x20",
181 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
183 .target_residency = 345,
184 .enter = &intel_idle,
185 .enter_s2idle = intel_idle_s2idle, },
188 .desc = "MWAIT 0x30",
189 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
191 .target_residency = 345,
192 .enter = &intel_idle,
193 .enter_s2idle = intel_idle_s2idle, },
198 static struct cpuidle_state byt_cstates[] = {
201 .desc = "MWAIT 0x00",
202 .flags = MWAIT2flg(0x00),
204 .target_residency = 1,
205 .enter = &intel_idle,
206 .enter_s2idle = intel_idle_s2idle, },
209 .desc = "MWAIT 0x58",
210 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
212 .target_residency = 275,
213 .enter = &intel_idle,
214 .enter_s2idle = intel_idle_s2idle, },
217 .desc = "MWAIT 0x52",
218 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
220 .target_residency = 560,
221 .enter = &intel_idle,
222 .enter_s2idle = intel_idle_s2idle, },
225 .desc = "MWAIT 0x60",
226 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
227 .exit_latency = 1200,
228 .target_residency = 4000,
229 .enter = &intel_idle,
230 .enter_s2idle = intel_idle_s2idle, },
233 .desc = "MWAIT 0x64",
234 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
235 .exit_latency = 10000,
236 .target_residency = 20000,
237 .enter = &intel_idle,
238 .enter_s2idle = intel_idle_s2idle, },
243 static struct cpuidle_state cht_cstates[] = {
246 .desc = "MWAIT 0x00",
247 .flags = MWAIT2flg(0x00),
249 .target_residency = 1,
250 .enter = &intel_idle,
251 .enter_s2idle = intel_idle_s2idle, },
254 .desc = "MWAIT 0x58",
255 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
257 .target_residency = 275,
258 .enter = &intel_idle,
259 .enter_s2idle = intel_idle_s2idle, },
262 .desc = "MWAIT 0x52",
263 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
265 .target_residency = 560,
266 .enter = &intel_idle,
267 .enter_s2idle = intel_idle_s2idle, },
270 .desc = "MWAIT 0x60",
271 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
272 .exit_latency = 1200,
273 .target_residency = 4000,
274 .enter = &intel_idle,
275 .enter_s2idle = intel_idle_s2idle, },
278 .desc = "MWAIT 0x64",
279 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
280 .exit_latency = 10000,
281 .target_residency = 20000,
282 .enter = &intel_idle,
283 .enter_s2idle = intel_idle_s2idle, },
288 static struct cpuidle_state ivb_cstates[] = {
291 .desc = "MWAIT 0x00",
292 .flags = MWAIT2flg(0x00),
294 .target_residency = 1,
295 .enter = &intel_idle,
296 .enter_s2idle = intel_idle_s2idle, },
299 .desc = "MWAIT 0x01",
300 .flags = MWAIT2flg(0x01),
302 .target_residency = 20,
303 .enter = &intel_idle,
304 .enter_s2idle = intel_idle_s2idle, },
307 .desc = "MWAIT 0x10",
308 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
310 .target_residency = 156,
311 .enter = &intel_idle,
312 .enter_s2idle = intel_idle_s2idle, },
315 .desc = "MWAIT 0x20",
316 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
318 .target_residency = 300,
319 .enter = &intel_idle,
320 .enter_s2idle = intel_idle_s2idle, },
323 .desc = "MWAIT 0x30",
324 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
326 .target_residency = 300,
327 .enter = &intel_idle,
328 .enter_s2idle = intel_idle_s2idle, },
333 static struct cpuidle_state ivt_cstates[] = {
336 .desc = "MWAIT 0x00",
337 .flags = MWAIT2flg(0x00),
339 .target_residency = 1,
340 .enter = &intel_idle,
341 .enter_s2idle = intel_idle_s2idle, },
344 .desc = "MWAIT 0x01",
345 .flags = MWAIT2flg(0x01),
347 .target_residency = 80,
348 .enter = &intel_idle,
349 .enter_s2idle = intel_idle_s2idle, },
352 .desc = "MWAIT 0x10",
353 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
355 .target_residency = 156,
356 .enter = &intel_idle,
357 .enter_s2idle = intel_idle_s2idle, },
360 .desc = "MWAIT 0x20",
361 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
363 .target_residency = 300,
364 .enter = &intel_idle,
365 .enter_s2idle = intel_idle_s2idle, },
370 static struct cpuidle_state ivt_cstates_4s[] = {
373 .desc = "MWAIT 0x00",
374 .flags = MWAIT2flg(0x00),
376 .target_residency = 1,
377 .enter = &intel_idle,
378 .enter_s2idle = intel_idle_s2idle, },
381 .desc = "MWAIT 0x01",
382 .flags = MWAIT2flg(0x01),
384 .target_residency = 250,
385 .enter = &intel_idle,
386 .enter_s2idle = intel_idle_s2idle, },
389 .desc = "MWAIT 0x10",
390 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
392 .target_residency = 300,
393 .enter = &intel_idle,
394 .enter_s2idle = intel_idle_s2idle, },
397 .desc = "MWAIT 0x20",
398 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
400 .target_residency = 400,
401 .enter = &intel_idle,
402 .enter_s2idle = intel_idle_s2idle, },
407 static struct cpuidle_state ivt_cstates_8s[] = {
410 .desc = "MWAIT 0x00",
411 .flags = MWAIT2flg(0x00),
413 .target_residency = 1,
414 .enter = &intel_idle,
415 .enter_s2idle = intel_idle_s2idle, },
418 .desc = "MWAIT 0x01",
419 .flags = MWAIT2flg(0x01),
421 .target_residency = 500,
422 .enter = &intel_idle,
423 .enter_s2idle = intel_idle_s2idle, },
426 .desc = "MWAIT 0x10",
427 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
429 .target_residency = 600,
430 .enter = &intel_idle,
431 .enter_s2idle = intel_idle_s2idle, },
434 .desc = "MWAIT 0x20",
435 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
437 .target_residency = 700,
438 .enter = &intel_idle,
439 .enter_s2idle = intel_idle_s2idle, },
444 static struct cpuidle_state hsw_cstates[] = {
447 .desc = "MWAIT 0x00",
448 .flags = MWAIT2flg(0x00),
450 .target_residency = 2,
451 .enter = &intel_idle,
452 .enter_s2idle = intel_idle_s2idle, },
455 .desc = "MWAIT 0x01",
456 .flags = MWAIT2flg(0x01),
458 .target_residency = 20,
459 .enter = &intel_idle,
460 .enter_s2idle = intel_idle_s2idle, },
463 .desc = "MWAIT 0x10",
464 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
466 .target_residency = 100,
467 .enter = &intel_idle,
468 .enter_s2idle = intel_idle_s2idle, },
471 .desc = "MWAIT 0x20",
472 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
474 .target_residency = 400,
475 .enter = &intel_idle,
476 .enter_s2idle = intel_idle_s2idle, },
479 .desc = "MWAIT 0x32",
480 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
482 .target_residency = 500,
483 .enter = &intel_idle,
484 .enter_s2idle = intel_idle_s2idle, },
487 .desc = "MWAIT 0x40",
488 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
490 .target_residency = 900,
491 .enter = &intel_idle,
492 .enter_s2idle = intel_idle_s2idle, },
495 .desc = "MWAIT 0x50",
496 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
498 .target_residency = 1800,
499 .enter = &intel_idle,
500 .enter_s2idle = intel_idle_s2idle, },
503 .desc = "MWAIT 0x60",
504 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
505 .exit_latency = 2600,
506 .target_residency = 7700,
507 .enter = &intel_idle,
508 .enter_s2idle = intel_idle_s2idle, },
512 static struct cpuidle_state bdw_cstates[] = {
515 .desc = "MWAIT 0x00",
516 .flags = MWAIT2flg(0x00),
518 .target_residency = 2,
519 .enter = &intel_idle,
520 .enter_s2idle = intel_idle_s2idle, },
523 .desc = "MWAIT 0x01",
524 .flags = MWAIT2flg(0x01),
526 .target_residency = 20,
527 .enter = &intel_idle,
528 .enter_s2idle = intel_idle_s2idle, },
531 .desc = "MWAIT 0x10",
532 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
534 .target_residency = 100,
535 .enter = &intel_idle,
536 .enter_s2idle = intel_idle_s2idle, },
539 .desc = "MWAIT 0x20",
540 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
542 .target_residency = 400,
543 .enter = &intel_idle,
544 .enter_s2idle = intel_idle_s2idle, },
547 .desc = "MWAIT 0x32",
548 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
550 .target_residency = 500,
551 .enter = &intel_idle,
552 .enter_s2idle = intel_idle_s2idle, },
555 .desc = "MWAIT 0x40",
556 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
558 .target_residency = 900,
559 .enter = &intel_idle,
560 .enter_s2idle = intel_idle_s2idle, },
563 .desc = "MWAIT 0x50",
564 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
566 .target_residency = 1800,
567 .enter = &intel_idle,
568 .enter_s2idle = intel_idle_s2idle, },
571 .desc = "MWAIT 0x60",
572 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
573 .exit_latency = 2600,
574 .target_residency = 7700,
575 .enter = &intel_idle,
576 .enter_s2idle = intel_idle_s2idle, },
581 static struct cpuidle_state skl_cstates[] = {
584 .desc = "MWAIT 0x00",
585 .flags = MWAIT2flg(0x00),
587 .target_residency = 2,
588 .enter = &intel_idle,
589 .enter_s2idle = intel_idle_s2idle, },
592 .desc = "MWAIT 0x01",
593 .flags = MWAIT2flg(0x01),
595 .target_residency = 20,
596 .enter = &intel_idle,
597 .enter_s2idle = intel_idle_s2idle, },
600 .desc = "MWAIT 0x10",
601 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
603 .target_residency = 100,
604 .enter = &intel_idle,
605 .enter_s2idle = intel_idle_s2idle, },
608 .desc = "MWAIT 0x20",
609 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
611 .target_residency = 200,
612 .enter = &intel_idle,
613 .enter_s2idle = intel_idle_s2idle, },
616 .desc = "MWAIT 0x33",
617 .flags = MWAIT2flg(0x33) | CPUIDLE_FLAG_TLB_FLUSHED,
619 .target_residency = 800,
620 .enter = &intel_idle,
621 .enter_s2idle = intel_idle_s2idle, },
624 .desc = "MWAIT 0x40",
625 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
627 .target_residency = 800,
628 .enter = &intel_idle,
629 .enter_s2idle = intel_idle_s2idle, },
632 .desc = "MWAIT 0x50",
633 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
635 .target_residency = 5000,
636 .enter = &intel_idle,
637 .enter_s2idle = intel_idle_s2idle, },
640 .desc = "MWAIT 0x60",
641 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
643 .target_residency = 5000,
644 .enter = &intel_idle,
645 .enter_s2idle = intel_idle_s2idle, },
650 static struct cpuidle_state skx_cstates[] = {
653 .desc = "MWAIT 0x00",
654 .flags = MWAIT2flg(0x00),
656 .target_residency = 2,
657 .enter = &intel_idle,
658 .enter_s2idle = intel_idle_s2idle, },
661 .desc = "MWAIT 0x01",
662 .flags = MWAIT2flg(0x01),
664 .target_residency = 20,
665 .enter = &intel_idle,
666 .enter_s2idle = intel_idle_s2idle, },
669 .desc = "MWAIT 0x20",
670 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
672 .target_residency = 600,
673 .enter = &intel_idle,
674 .enter_s2idle = intel_idle_s2idle, },
679 static struct cpuidle_state atom_cstates[] = {
682 .desc = "MWAIT 0x00",
683 .flags = MWAIT2flg(0x00),
685 .target_residency = 20,
686 .enter = &intel_idle,
687 .enter_s2idle = intel_idle_s2idle, },
690 .desc = "MWAIT 0x10",
691 .flags = MWAIT2flg(0x10),
693 .target_residency = 80,
694 .enter = &intel_idle,
695 .enter_s2idle = intel_idle_s2idle, },
698 .desc = "MWAIT 0x30",
699 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
701 .target_residency = 400,
702 .enter = &intel_idle,
703 .enter_s2idle = intel_idle_s2idle, },
706 .desc = "MWAIT 0x52",
707 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
709 .target_residency = 560,
710 .enter = &intel_idle,
711 .enter_s2idle = intel_idle_s2idle, },
715 static struct cpuidle_state tangier_cstates[] = {
718 .desc = "MWAIT 0x00",
719 .flags = MWAIT2flg(0x00),
721 .target_residency = 4,
722 .enter = &intel_idle,
723 .enter_s2idle = intel_idle_s2idle, },
726 .desc = "MWAIT 0x30",
727 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
729 .target_residency = 400,
730 .enter = &intel_idle,
731 .enter_s2idle = intel_idle_s2idle, },
734 .desc = "MWAIT 0x52",
735 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
737 .target_residency = 560,
738 .enter = &intel_idle,
739 .enter_s2idle = intel_idle_s2idle, },
742 .desc = "MWAIT 0x60",
743 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
744 .exit_latency = 1200,
745 .target_residency = 4000,
746 .enter = &intel_idle,
747 .enter_s2idle = intel_idle_s2idle, },
750 .desc = "MWAIT 0x64",
751 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
752 .exit_latency = 10000,
753 .target_residency = 20000,
754 .enter = &intel_idle,
755 .enter_s2idle = intel_idle_s2idle, },
759 static struct cpuidle_state avn_cstates[] = {
762 .desc = "MWAIT 0x00",
763 .flags = MWAIT2flg(0x00),
765 .target_residency = 2,
766 .enter = &intel_idle,
767 .enter_s2idle = intel_idle_s2idle, },
770 .desc = "MWAIT 0x51",
771 .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TLB_FLUSHED,
773 .target_residency = 45,
774 .enter = &intel_idle,
775 .enter_s2idle = intel_idle_s2idle, },
779 static struct cpuidle_state knl_cstates[] = {
782 .desc = "MWAIT 0x00",
783 .flags = MWAIT2flg(0x00),
785 .target_residency = 2,
786 .enter = &intel_idle,
787 .enter_s2idle = intel_idle_s2idle },
790 .desc = "MWAIT 0x10",
791 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
793 .target_residency = 500,
794 .enter = &intel_idle,
795 .enter_s2idle = intel_idle_s2idle },
800 static struct cpuidle_state bxt_cstates[] = {
803 .desc = "MWAIT 0x00",
804 .flags = MWAIT2flg(0x00),
806 .target_residency = 2,
807 .enter = &intel_idle,
808 .enter_s2idle = intel_idle_s2idle, },
811 .desc = "MWAIT 0x01",
812 .flags = MWAIT2flg(0x01),
814 .target_residency = 20,
815 .enter = &intel_idle,
816 .enter_s2idle = intel_idle_s2idle, },
819 .desc = "MWAIT 0x20",
820 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
822 .target_residency = 133,
823 .enter = &intel_idle,
824 .enter_s2idle = intel_idle_s2idle, },
827 .desc = "MWAIT 0x31",
828 .flags = MWAIT2flg(0x31) | CPUIDLE_FLAG_TLB_FLUSHED,
830 .target_residency = 155,
831 .enter = &intel_idle,
832 .enter_s2idle = intel_idle_s2idle, },
835 .desc = "MWAIT 0x40",
836 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
837 .exit_latency = 1000,
838 .target_residency = 1000,
839 .enter = &intel_idle,
840 .enter_s2idle = intel_idle_s2idle, },
843 .desc = "MWAIT 0x50",
844 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
845 .exit_latency = 2000,
846 .target_residency = 2000,
847 .enter = &intel_idle,
848 .enter_s2idle = intel_idle_s2idle, },
851 .desc = "MWAIT 0x60",
852 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
853 .exit_latency = 10000,
854 .target_residency = 10000,
855 .enter = &intel_idle,
856 .enter_s2idle = intel_idle_s2idle, },
861 static struct cpuidle_state dnv_cstates[] = {
864 .desc = "MWAIT 0x00",
865 .flags = MWAIT2flg(0x00),
867 .target_residency = 2,
868 .enter = &intel_idle,
869 .enter_s2idle = intel_idle_s2idle, },
872 .desc = "MWAIT 0x01",
873 .flags = MWAIT2flg(0x01),
875 .target_residency = 20,
876 .enter = &intel_idle,
877 .enter_s2idle = intel_idle_s2idle, },
880 .desc = "MWAIT 0x20",
881 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
883 .target_residency = 500,
884 .enter = &intel_idle,
885 .enter_s2idle = intel_idle_s2idle, },
892 * @dev: cpuidle_device
893 * @drv: cpuidle driver
894 * @index: index of cpuidle state
896 * Must be called under local_irq_disable().
898 static __cpuidle int intel_idle(struct cpuidle_device *dev,
899 struct cpuidle_driver *drv, int index)
901 unsigned long ecx = 1; /* break on interrupt flag */
902 struct cpuidle_state *state = &drv->states[index];
903 unsigned long eax = flg2MWAIT(state->flags);
905 bool uninitialized_var(tick);
906 int cpu = smp_processor_id();
909 * leave_mm() to avoid costly and often unnecessary wakeups
910 * for flushing the user TLB's associated with the active mm.
912 if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
915 if (!static_cpu_has(X86_FEATURE_ARAT)) {
916 cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) &
917 MWAIT_CSTATE_MASK) + 1;
919 if (!(lapic_timer_reliable_states & (1 << (cstate)))) {
921 tick_broadcast_enter();
925 mwait_idle_with_hints(eax, ecx);
927 if (!static_cpu_has(X86_FEATURE_ARAT) && tick)
928 tick_broadcast_exit();
934 * intel_idle_s2idle - simplified "enter" callback routine for suspend-to-idle
935 * @dev: cpuidle_device
936 * @drv: cpuidle driver
937 * @index: state index
939 static void intel_idle_s2idle(struct cpuidle_device *dev,
940 struct cpuidle_driver *drv, int index)
942 unsigned long ecx = 1; /* break on interrupt flag */
943 unsigned long eax = flg2MWAIT(drv->states[index].flags);
945 mwait_idle_with_hints(eax, ecx);
948 static bool intel_idle_verify_cstate(unsigned int mwait_hint)
950 unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
951 unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
954 /* Ignore the C-state if there are NO sub-states in CPUID for it. */
955 if (num_substates == 0)
958 if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
959 mark_tsc_unstable("TSC halts in idle states deeper than C2");
964 static void __setup_broadcast_timer(bool on)
967 tick_broadcast_enable();
969 tick_broadcast_disable();
972 static void auto_demotion_disable(void)
974 unsigned long long msr_bits;
976 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
977 msr_bits &= ~(icpu->auto_demotion_disable_flags);
978 wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
980 static void c1e_promotion_disable(void)
982 unsigned long long msr_bits;
984 rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
986 wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
989 static const struct idle_cpu idle_cpu_nehalem = {
990 .state_table = nehalem_cstates,
991 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
992 .disable_promotion_to_c1e = true,
995 static const struct idle_cpu idle_cpu_atom = {
996 .state_table = atom_cstates,
999 static const struct idle_cpu idle_cpu_tangier = {
1000 .state_table = tangier_cstates,
1003 static const struct idle_cpu idle_cpu_lincroft = {
1004 .state_table = atom_cstates,
1005 .auto_demotion_disable_flags = ATM_LNC_C6_AUTO_DEMOTE,
1008 static const struct idle_cpu idle_cpu_snb = {
1009 .state_table = snb_cstates,
1010 .disable_promotion_to_c1e = true,
1013 static const struct idle_cpu idle_cpu_byt = {
1014 .state_table = byt_cstates,
1015 .disable_promotion_to_c1e = true,
1016 .byt_auto_demotion_disable_flag = true,
1019 static const struct idle_cpu idle_cpu_cht = {
1020 .state_table = cht_cstates,
1021 .disable_promotion_to_c1e = true,
1022 .byt_auto_demotion_disable_flag = true,
1025 static const struct idle_cpu idle_cpu_ivb = {
1026 .state_table = ivb_cstates,
1027 .disable_promotion_to_c1e = true,
1030 static const struct idle_cpu idle_cpu_ivt = {
1031 .state_table = ivt_cstates,
1032 .disable_promotion_to_c1e = true,
1035 static const struct idle_cpu idle_cpu_hsw = {
1036 .state_table = hsw_cstates,
1037 .disable_promotion_to_c1e = true,
1040 static const struct idle_cpu idle_cpu_bdw = {
1041 .state_table = bdw_cstates,
1042 .disable_promotion_to_c1e = true,
1045 static const struct idle_cpu idle_cpu_skl = {
1046 .state_table = skl_cstates,
1047 .disable_promotion_to_c1e = true,
1050 static const struct idle_cpu idle_cpu_skx = {
1051 .state_table = skx_cstates,
1052 .disable_promotion_to_c1e = true,
1055 static const struct idle_cpu idle_cpu_avn = {
1056 .state_table = avn_cstates,
1057 .disable_promotion_to_c1e = true,
1060 static const struct idle_cpu idle_cpu_knl = {
1061 .state_table = knl_cstates,
1064 static const struct idle_cpu idle_cpu_bxt = {
1065 .state_table = bxt_cstates,
1066 .disable_promotion_to_c1e = true,
1069 static const struct idle_cpu idle_cpu_dnv = {
1070 .state_table = dnv_cstates,
1071 .disable_promotion_to_c1e = true,
1074 static const struct x86_cpu_id intel_idle_ids[] __initconst = {
1075 INTEL_CPU_FAM6(NEHALEM_EP, idle_cpu_nehalem),
1076 INTEL_CPU_FAM6(NEHALEM, idle_cpu_nehalem),
1077 INTEL_CPU_FAM6(NEHALEM_G, idle_cpu_nehalem),
1078 INTEL_CPU_FAM6(WESTMERE, idle_cpu_nehalem),
1079 INTEL_CPU_FAM6(WESTMERE_EP, idle_cpu_nehalem),
1080 INTEL_CPU_FAM6(NEHALEM_EX, idle_cpu_nehalem),
1081 INTEL_CPU_FAM6(ATOM_BONNELL, idle_cpu_atom),
1082 INTEL_CPU_FAM6(ATOM_BONNELL_MID, idle_cpu_lincroft),
1083 INTEL_CPU_FAM6(WESTMERE_EX, idle_cpu_nehalem),
1084 INTEL_CPU_FAM6(SANDYBRIDGE, idle_cpu_snb),
1085 INTEL_CPU_FAM6(SANDYBRIDGE_X, idle_cpu_snb),
1086 INTEL_CPU_FAM6(ATOM_SALTWELL, idle_cpu_atom),
1087 INTEL_CPU_FAM6(ATOM_SILVERMONT, idle_cpu_byt),
1088 INTEL_CPU_FAM6(ATOM_SILVERMONT_MID, idle_cpu_tangier),
1089 INTEL_CPU_FAM6(ATOM_AIRMONT, idle_cpu_cht),
1090 INTEL_CPU_FAM6(IVYBRIDGE, idle_cpu_ivb),
1091 INTEL_CPU_FAM6(IVYBRIDGE_X, idle_cpu_ivt),
1092 INTEL_CPU_FAM6(HASWELL, idle_cpu_hsw),
1093 INTEL_CPU_FAM6(HASWELL_X, idle_cpu_hsw),
1094 INTEL_CPU_FAM6(HASWELL_L, idle_cpu_hsw),
1095 INTEL_CPU_FAM6(HASWELL_G, idle_cpu_hsw),
1096 INTEL_CPU_FAM6(ATOM_SILVERMONT_D, idle_cpu_avn),
1097 INTEL_CPU_FAM6(BROADWELL, idle_cpu_bdw),
1098 INTEL_CPU_FAM6(BROADWELL_G, idle_cpu_bdw),
1099 INTEL_CPU_FAM6(BROADWELL_X, idle_cpu_bdw),
1100 INTEL_CPU_FAM6(BROADWELL_D, idle_cpu_bdw),
1101 INTEL_CPU_FAM6(SKYLAKE_L, idle_cpu_skl),
1102 INTEL_CPU_FAM6(SKYLAKE, idle_cpu_skl),
1103 INTEL_CPU_FAM6(KABYLAKE_L, idle_cpu_skl),
1104 INTEL_CPU_FAM6(KABYLAKE, idle_cpu_skl),
1105 INTEL_CPU_FAM6(SKYLAKE_X, idle_cpu_skx),
1106 INTEL_CPU_FAM6(XEON_PHI_KNL, idle_cpu_knl),
1107 INTEL_CPU_FAM6(XEON_PHI_KNM, idle_cpu_knl),
1108 INTEL_CPU_FAM6(ATOM_GOLDMONT, idle_cpu_bxt),
1109 INTEL_CPU_FAM6(ATOM_GOLDMONT_PLUS, idle_cpu_bxt),
1110 INTEL_CPU_FAM6(ATOM_GOLDMONT_D, idle_cpu_dnv),
1111 INTEL_CPU_FAM6(ATOM_TREMONT_D, idle_cpu_dnv),
1115 #define INTEL_CPU_FAM6_MWAIT \
1116 { X86_VENDOR_INTEL, 6, X86_MODEL_ANY, X86_FEATURE_MWAIT, 0 }
1118 static const struct x86_cpu_id intel_mwait_ids[] __initconst = {
1119 INTEL_CPU_FAM6_MWAIT,
1123 static bool intel_idle_max_cstate_reached(int cstate)
1125 if (cstate + 1 > max_cstate) {
1126 pr_info("max_cstate %d reached\n", max_cstate);
1132 #ifdef CONFIG_ACPI_PROCESSOR_CSTATE
1133 #include <acpi/processor.h>
1135 static struct acpi_processor_power acpi_state_table;
1138 * intel_idle_cst_usable - Check if the _CST information can be used.
1140 * Check if all of the C-states listed by _CST in the max_cstate range are
1141 * ACPI_CSTATE_FFH, which means that they should be entered via MWAIT.
1143 static bool intel_idle_cst_usable(void)
1147 limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1),
1148 acpi_state_table.count);
1150 for (cstate = 1; cstate < limit; cstate++) {
1151 struct acpi_processor_cx *cx = &acpi_state_table.states[cstate];
1153 if (cx->entry_method != ACPI_CSTATE_FFH)
1160 static bool intel_idle_acpi_cst_extract(void)
1164 for_each_possible_cpu(cpu) {
1165 struct acpi_processor *pr = per_cpu(processors, cpu);
1170 if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table))
1173 acpi_state_table.count++;
1175 if (!intel_idle_cst_usable())
1178 if (!acpi_processor_claim_cst_control()) {
1179 acpi_state_table.count = 0;
1186 pr_debug("ACPI _CST not found or not usable\n");
1190 static void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
1192 int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
1195 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
1196 * the interesting states are ACPI_CSTATE_FFH.
1198 for (cstate = 1; cstate < limit; cstate++) {
1199 struct acpi_processor_cx *cx;
1200 struct cpuidle_state *state;
1202 if (intel_idle_max_cstate_reached(cstate))
1205 cx = &acpi_state_table.states[cstate];
1207 state = &drv->states[drv->state_count++];
1209 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d_ACPI", cstate);
1210 strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1211 state->exit_latency = cx->latency;
1213 * For C1-type C-states use the same number for both the exit
1214 * latency and target residency, because that is the case for
1215 * C1 in the majority of the static C-states tables above.
1216 * For the other types of C-states, however, set the target
1217 * residency to 3 times the exit latency which should lead to
1218 * a reasonable balance between energy-efficiency and
1219 * performance in the majority of interesting cases.
1221 state->target_residency = cx->latency;
1222 if (cx->type > ACPI_STATE_C1)
1223 state->target_residency *= 3;
1225 state->flags = MWAIT2flg(cx->address);
1226 if (cx->type > ACPI_STATE_C2)
1227 state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
1229 state->enter = intel_idle;
1230 state->enter_s2idle = intel_idle_s2idle;
1233 #else /* !CONFIG_ACPI_PROCESSOR_CSTATE */
1234 static inline bool intel_idle_acpi_cst_extract(void) { return false; }
1235 static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { }
1236 #endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
1239 * intel_idle_probe()
1241 static int __init intel_idle_probe(void)
1243 unsigned int eax, ebx, ecx;
1244 const struct x86_cpu_id *id;
1246 if (max_cstate == 0) {
1247 pr_debug("disabled\n");
1251 id = x86_match_cpu(intel_idle_ids);
1253 if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
1254 pr_debug("Please enable MWAIT in BIOS SETUP\n");
1258 id = x86_match_cpu(intel_mwait_ids);
1263 if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
1266 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
1268 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
1269 !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
1273 pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
1275 icpu = (const struct idle_cpu *)id->driver_data;
1277 cpuidle_state_table = icpu->state_table;
1278 else if (!intel_idle_acpi_cst_extract())
1281 pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
1282 boot_cpu_data.x86_model);
1288 * intel_idle_cpuidle_devices_uninit()
1289 * Unregisters the cpuidle devices.
1291 static void intel_idle_cpuidle_devices_uninit(void)
1294 struct cpuidle_device *dev;
1296 for_each_online_cpu(i) {
1297 dev = per_cpu_ptr(intel_idle_cpuidle_devices, i);
1298 cpuidle_unregister_device(dev);
1303 * ivt_idle_state_table_update(void)
1305 * Tune IVT multi-socket targets
1306 * Assumption: num_sockets == (max_package_num + 1)
1308 static void ivt_idle_state_table_update(void)
1310 /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
1311 int cpu, package_num, num_sockets = 1;
1313 for_each_online_cpu(cpu) {
1314 package_num = topology_physical_package_id(cpu);
1315 if (package_num + 1 > num_sockets) {
1316 num_sockets = package_num + 1;
1318 if (num_sockets > 4) {
1319 cpuidle_state_table = ivt_cstates_8s;
1325 if (num_sockets > 2)
1326 cpuidle_state_table = ivt_cstates_4s;
1328 /* else, 1 and 2 socket systems use default ivt_cstates */
1332 * Translate IRTL (Interrupt Response Time Limit) MSR to usec
1335 static unsigned int irtl_ns_units[] = {
1336 1, 32, 1024, 32768, 1048576, 33554432, 0, 0 };
1338 static unsigned long long irtl_2_usec(unsigned long long irtl)
1340 unsigned long long ns;
1345 ns = irtl_ns_units[(irtl >> 10) & 0x7];
1347 return div64_u64((irtl & 0x3FF) * ns, 1000);
1350 * bxt_idle_state_table_update(void)
1352 * On BXT, we trust the IRTL to show the definitive maximum latency
1353 * We use the same value for target_residency.
1355 static void bxt_idle_state_table_update(void)
1357 unsigned long long msr;
1360 rdmsrl(MSR_PKGC6_IRTL, msr);
1361 usec = irtl_2_usec(msr);
1363 bxt_cstates[2].exit_latency = usec;
1364 bxt_cstates[2].target_residency = usec;
1367 rdmsrl(MSR_PKGC7_IRTL, msr);
1368 usec = irtl_2_usec(msr);
1370 bxt_cstates[3].exit_latency = usec;
1371 bxt_cstates[3].target_residency = usec;
1374 rdmsrl(MSR_PKGC8_IRTL, msr);
1375 usec = irtl_2_usec(msr);
1377 bxt_cstates[4].exit_latency = usec;
1378 bxt_cstates[4].target_residency = usec;
1381 rdmsrl(MSR_PKGC9_IRTL, msr);
1382 usec = irtl_2_usec(msr);
1384 bxt_cstates[5].exit_latency = usec;
1385 bxt_cstates[5].target_residency = usec;
1388 rdmsrl(MSR_PKGC10_IRTL, msr);
1389 usec = irtl_2_usec(msr);
1391 bxt_cstates[6].exit_latency = usec;
1392 bxt_cstates[6].target_residency = usec;
1397 * sklh_idle_state_table_update(void)
1399 * On SKL-H (model 0x5e) disable C8 and C9 if:
1400 * C10 is enabled and SGX disabled
1402 static void sklh_idle_state_table_update(void)
1404 unsigned long long msr;
1405 unsigned int eax, ebx, ecx, edx;
1408 /* if PC10 disabled via cmdline intel_idle.max_cstate=7 or shallower */
1409 if (max_cstate <= 7)
1412 /* if PC10 not present in CPUID.MWAIT.EDX */
1413 if ((mwait_substates & (0xF << 28)) == 0)
1416 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr);
1418 /* PC10 is not enabled in PKG C-state limit */
1419 if ((msr & 0xF) != 8)
1423 cpuid(7, &eax, &ebx, &ecx, &edx);
1425 /* if SGX is present */
1426 if (ebx & (1 << 2)) {
1428 rdmsrl(MSR_IA32_FEATURE_CONTROL, msr);
1430 /* if SGX is enabled */
1431 if (msr & (1 << 18))
1435 skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
1436 skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
1439 * intel_idle_state_table_update()
1441 * Update the default state_table for this CPU-id
1444 static void intel_idle_state_table_update(void)
1446 switch (boot_cpu_data.x86_model) {
1448 case INTEL_FAM6_IVYBRIDGE_X:
1449 ivt_idle_state_table_update();
1451 case INTEL_FAM6_ATOM_GOLDMONT:
1452 case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
1453 bxt_idle_state_table_update();
1455 case INTEL_FAM6_SKYLAKE:
1456 sklh_idle_state_table_update();
1461 static void intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
1465 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
1466 unsigned int mwait_hint;
1468 if (intel_idle_max_cstate_reached(cstate))
1471 if (!cpuidle_state_table[cstate].enter &&
1472 !cpuidle_state_table[cstate].enter_s2idle)
1475 /* If marked as unusable, skip this state. */
1476 if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
1477 pr_debug("state %s is disabled\n",
1478 cpuidle_state_table[cstate].name);
1482 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
1483 if (!intel_idle_verify_cstate(mwait_hint))
1486 /* Structure copy. */
1487 drv->states[drv->state_count++] = cpuidle_state_table[cstate];
1490 if (icpu->byt_auto_demotion_disable_flag) {
1491 wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
1492 wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
1497 * intel_idle_cpuidle_driver_init()
1498 * allocate, initialize cpuidle_states
1500 static void __init intel_idle_cpuidle_driver_init(void)
1502 struct cpuidle_driver *drv = &intel_idle_driver;
1504 intel_idle_state_table_update();
1506 cpuidle_poll_state_init(drv);
1507 drv->state_count = 1;
1510 intel_idle_init_cstates_icpu(drv);
1512 intel_idle_init_cstates_acpi(drv);
1516 * intel_idle_cpu_init()
1517 * allocate, initialize, register cpuidle_devices
1518 * @cpu: cpu/core to initialize
1520 static int intel_idle_cpu_init(unsigned int cpu)
1522 struct cpuidle_device *dev;
1524 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
1527 if (cpuidle_register_device(dev)) {
1528 pr_debug("cpuidle_register_device %d failed!\n", cpu);
1535 if (icpu->auto_demotion_disable_flags)
1536 auto_demotion_disable();
1538 if (icpu->disable_promotion_to_c1e)
1539 c1e_promotion_disable();
1544 static int intel_idle_cpu_online(unsigned int cpu)
1546 struct cpuidle_device *dev;
1548 if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
1549 __setup_broadcast_timer(true);
1552 * Some systems can hotplug a cpu at runtime after
1553 * the kernel has booted, we have to initialize the
1554 * driver in this case
1556 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
1557 if (!dev->registered)
1558 return intel_idle_cpu_init(cpu);
1563 static int __init intel_idle_init(void)
1567 /* Do not load intel_idle at all for now if idle= is passed */
1568 if (boot_option_idle_override != IDLE_NO_OVERRIDE)
1571 retval = intel_idle_probe();
1575 intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
1576 if (intel_idle_cpuidle_devices == NULL)
1579 intel_idle_cpuidle_driver_init();
1580 retval = cpuidle_register_driver(&intel_idle_driver);
1582 struct cpuidle_driver *drv = cpuidle_get_driver();
1583 printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"),
1584 drv ? drv->name : "none");
1585 goto init_driver_fail;
1588 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
1589 lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE;
1591 retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online",
1592 intel_idle_cpu_online, NULL);
1596 pr_debug("lapic_timer_reliable_states 0x%x\n",
1597 lapic_timer_reliable_states);
1602 intel_idle_cpuidle_devices_uninit();
1603 cpuidle_unregister_driver(&intel_idle_driver);
1605 free_percpu(intel_idle_cpuidle_devices);
1609 device_initcall(intel_idle_init);
1612 * We are not really modular, but we used to support that. Meaning we also
1613 * support "intel_idle.max_cstate=..." at boot and also a read-only export of
1614 * it at /sys/module/intel_idle/parameters/max_cstate -- so using module_param
1615 * is the easiest way (currently) to continue doing that.
1617 module_param(max_cstate, int, 0444);