blob: fa23a7ea01ac9d366d270fe8c8a17ac15e89eb6c [file] [log] [blame]
Thomas Gleixnera61127c2019-05-29 16:57:49 -07001// SPDX-License-Identifier: GPL-2.0-only
Len Brown26717172010-03-08 14:07:30 -05002/*
3 * intel_idle.c - native hardware idle loop for modern Intel processors
4 *
Rafael J. Wysocki317e5ec2020-02-06 18:45:49 +01005 * Copyright (c) 2013 - 2020, Intel Corporation.
Len Brown26717172010-03-08 14:07:30 -05006 * Len Brown <len.brown@intel.com>
Rafael J. Wysocki317e5ec2020-02-06 18:45:49 +01007 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Len Brown26717172010-03-08 14:07:30 -05008 */
9
10/*
11 * intel_idle is a cpuidle driver that loads on specific Intel processors
12 * in lieu of the legacy ACPI processor_idle driver. The intent is to
13 * make Linux more efficient on these processors, as intel_idle knows
14 * more than ACPI, as well as make Linux more immune to ACPI BIOS bugs.
15 */
16
17/*
18 * Design Assumptions
19 *
20 * All CPUs have same idle states as boot CPU
21 *
22 * Chipset BM_STS (bus master status) bit is a NOP
23 * for preventing entry into deep C-stats
24 */
25
26/*
27 * Known limitations
28 *
Len Brown26717172010-03-08 14:07:30 -050029 * ACPI has a .suspend hack to turn off deep c-statees during suspend
30 * to avoid complications with the lapic timer workaround.
31 * Have not seen issues with suspend, but may need same workaround here.
32 *
Len Brown26717172010-03-08 14:07:30 -050033 */
34
35/* un-comment DEBUG to enable pr_debug() statements */
36#define DEBUG
37
Joe Perches654d08a2017-06-09 12:29:20 -070038#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
39
Rafael J. Wysocki18734952019-12-13 09:56:01 +010040#include <linux/acpi.h>
Len Brown26717172010-03-08 14:07:30 -050041#include <linux/kernel.h>
42#include <linux/cpuidle.h>
Thomas Gleixner76962ca2015-04-03 02:02:34 +020043#include <linux/tick.h>
Len Brown26717172010-03-08 14:07:30 -050044#include <trace/events/power.h>
45#include <linux/sched.h>
Shaohua Li2a2d31c2011-01-10 09:38:12 +080046#include <linux/notifier.h>
47#include <linux/cpu.h>
Paul Gortmaker02c4fae2016-06-17 01:28:33 -040048#include <linux/moduleparam.h>
Andi Kleenb66b8b92012-01-26 00:09:07 +010049#include <asm/cpu_device_id.h>
Dave Hansendb73c5a2016-06-02 17:19:32 -070050#include <asm/intel-family.h>
H. Peter Anvinbc83ccc2010-09-17 15:36:40 -070051#include <asm/mwait.h>
Len Brown14796fc2011-01-18 20:48:27 -050052#include <asm/msr.h>
Len Brown26717172010-03-08 14:07:30 -050053
Rafael J. Wysocki317e5ec2020-02-06 18:45:49 +010054#define INTEL_IDLE_VERSION "0.5.1"
Len Brown26717172010-03-08 14:07:30 -050055
Len Brown26717172010-03-08 14:07:30 -050056static struct cpuidle_driver intel_idle_driver = {
57 .name = "intel_idle",
58 .owner = THIS_MODULE,
59};
60/* intel_idle.max_cstate=0 disables driver */
Len Brown137ecc72013-02-01 21:35:35 -050061static int max_cstate = CPUIDLE_STATE_MAX - 1;
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +010062static unsigned int disabled_states_mask;
Len Brown26717172010-03-08 14:07:30 -050063
Rafael J. Wysocki6eb04432020-02-06 18:45:18 +010064static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +010065
66static unsigned long auto_demotion_disable_flags;
67static bool disable_promotion_to_c1e;
68
Andi Kleenb66b8b92012-01-26 00:09:07 +010069struct idle_cpu {
70 struct cpuidle_state *state_table;
71
72 /*
73 * Hardware C-state auto-demotion may not always be optimal.
74 * Indicate which enable bits to clear here.
75 */
76 unsigned long auto_demotion_disable_flags;
Len Brown8c058d532014-07-31 15:21:24 -040077 bool byt_auto_demotion_disable_flag;
Len Brown32e95182013-02-02 01:31:56 -050078 bool disable_promotion_to_c1e;
Rafael J. Wysockibff8e602019-12-13 09:56:21 +010079 bool use_acpi;
Andi Kleenb66b8b92012-01-26 00:09:07 +010080};
81
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +010082static const struct idle_cpu *icpu __initdata;
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +010083static struct cpuidle_state *cpuidle_state_table __initdata;
Len Brown26717172010-03-08 14:07:30 -050084
Rafael J. Wysocki6eb04432020-02-06 18:45:18 +010085static unsigned int mwait_substates __initdata;
86
Len Brown26717172010-03-08 14:07:30 -050087/*
Rafael J. Wysockibff8e602019-12-13 09:56:21 +010088 * Enable this state by default even if the ACPI _CST does not list it.
89 */
90#define CPUIDLE_FLAG_ALWAYS_ENABLE BIT(15)
91
92/*
Len Brown956d0332011-01-12 02:51:20 -050093 * Set this flag for states where the HW flushes the TLB for us
94 * and so we don't need cross-calls to keep it consistent.
95 * If this flag is set, SW flushes the TLB, so even if the
96 * HW doesn't do the flushing, this flag is safe to use.
97 */
Rafael J. Wysockia472e4b2020-02-06 18:45:39 +010098#define CPUIDLE_FLAG_TLB_FLUSHED BIT(16)
Len Brown956d0332011-01-12 02:51:20 -050099
100/*
Len Brownb1beab42013-01-31 19:55:37 -0500101 * MWAIT takes an 8-bit "hint" in EAX "suggesting"
102 * the C-state (top nibble) and sub-state (bottom nibble)
103 * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.
104 *
105 * We store the hint at the top of our "flags" for each state.
106 */
107#define flg2MWAIT(flags) (((flags) >> 24) & 0xFF)
108#define MWAIT2flg(eax) ((eax & 0xFF) << 24)
109
Rafael J. Wysocki30a996f2020-02-06 18:41:15 +0100110/**
111 * intel_idle - Ask the processor to enter the given idle state.
112 * @dev: cpuidle device of the target CPU.
113 * @drv: cpuidle driver (assumed to point to intel_idle_driver).
114 * @index: Target idle state index.
115 *
116 * Use the MWAIT instruction to notify the processor that the CPU represented by
117 * @dev is idle and it can try to enter the idle state corresponding to @index.
118 *
119 * If the local APIC timer is not known to be reliable in the target idle state,
120 * enable one-shot tick broadcasting for the target CPU before executing MWAIT.
121 *
122 * Optionally call leave_mm() for the target CPU upfront to avoid wakeups due to
123 * flushing user TLBs.
124 *
125 * Must be called under local_irq_disable().
126 */
127static __cpuidle int intel_idle(struct cpuidle_device *dev,
128 struct cpuidle_driver *drv, int index)
129{
130 struct cpuidle_state *state = &drv->states[index];
131 unsigned long eax = flg2MWAIT(state->flags);
132 unsigned long ecx = 1; /* break on interrupt flag */
133 bool uninitialized_var(tick);
134 int cpu = smp_processor_id();
135
136 /*
137 * leave_mm() to avoid costly and often unnecessary wakeups
138 * for flushing the user TLB's associated with the active mm.
139 */
140 if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
141 leave_mm(cpu);
142
Rafael J. Wysockidab20172020-06-29 13:58:28 +0200143 if (!static_cpu_has(X86_FEATURE_ARAT)) {
Rafael J. Wysocki30a996f2020-02-06 18:41:15 +0100144 /*
145 * Switch over to one-shot tick broadcast if the target C-state
146 * is deeper than C1.
147 */
148 if ((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) {
149 tick = true;
150 tick_broadcast_enter();
151 } else {
152 tick = false;
153 }
154 }
155
156 mwait_idle_with_hints(eax, ecx);
157
158 if (!static_cpu_has(X86_FEATURE_ARAT) && tick)
159 tick_broadcast_exit();
160
161 return index;
162}
163
164/**
165 * intel_idle_s2idle - Ask the processor to enter the given idle state.
166 * @dev: cpuidle device of the target CPU.
167 * @drv: cpuidle driver (assumed to point to intel_idle_driver).
168 * @index: Target idle state index.
169 *
170 * Use the MWAIT instruction to notify the processor that the CPU represented by
171 * @dev is idle and it can try to enter the idle state corresponding to @index.
172 *
173 * Invoked as a suspend-to-idle callback routine with frozen user space, frozen
174 * scheduler tick and suspended scheduler clock on the target CPU.
175 */
176static __cpuidle void intel_idle_s2idle(struct cpuidle_device *dev,
177 struct cpuidle_driver *drv, int index)
178{
179 unsigned long eax = flg2MWAIT(drv->states[index].flags);
180 unsigned long ecx = 1; /* break on interrupt flag */
181
182 mwait_idle_with_hints(eax, ecx);
183}
184
Len Brownb1beab42013-01-31 19:55:37 -0500185/*
Len Brown26717172010-03-08 14:07:30 -0500186 * States are indexed by the cstate number,
187 * which is also the index into the MWAIT hint array.
188 * Thus C0 is a dummy.
189 */
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100190static struct cpuidle_state nehalem_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500191 {
Len Brownde09cdd2017-02-28 16:32:44 -0500192 .name = "C1",
Len Brown26717172010-03-08 14:07:30 -0500193 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100194 .flags = MWAIT2flg(0x00),
Len Brown26717172010-03-08 14:07:30 -0500195 .exit_latency = 3,
Len Brown26717172010-03-08 14:07:30 -0500196 .target_residency = 6,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100197 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200198 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500199 {
Len Brownde09cdd2017-02-28 16:32:44 -0500200 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500201 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100202 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500203 .exit_latency = 10,
204 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100205 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200206 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500207 {
Len Brownde09cdd2017-02-28 16:32:44 -0500208 .name = "C3",
Len Brown26717172010-03-08 14:07:30 -0500209 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100210 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500211 .exit_latency = 20,
Len Brown26717172010-03-08 14:07:30 -0500212 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100213 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200214 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500215 {
Len Brownde09cdd2017-02-28 16:32:44 -0500216 .name = "C6",
Len Brown26717172010-03-08 14:07:30 -0500217 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100218 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500219 .exit_latency = 200,
Len Brown26717172010-03-08 14:07:30 -0500220 .target_residency = 800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100221 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200222 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500223 {
224 .enter = NULL }
Len Brown26717172010-03-08 14:07:30 -0500225};
226
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100227static struct cpuidle_state snb_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500228 {
Len Brownde09cdd2017-02-28 16:32:44 -0500229 .name = "C1",
Len Brownd13780d2010-07-07 00:12:03 -0400230 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100231 .flags = MWAIT2flg(0x00),
Len Brown32e95182013-02-02 01:31:56 -0500232 .exit_latency = 2,
233 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100234 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200235 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500236 {
Len Brownde09cdd2017-02-28 16:32:44 -0500237 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500238 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100239 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500240 .exit_latency = 10,
241 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100242 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200243 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500244 {
Len Brownde09cdd2017-02-28 16:32:44 -0500245 .name = "C3",
Len Brownd13780d2010-07-07 00:12:03 -0400246 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100247 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400248 .exit_latency = 80,
Len Brownddbd5502010-12-13 18:28:22 -0500249 .target_residency = 211,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100250 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200251 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500252 {
Len Brownde09cdd2017-02-28 16:32:44 -0500253 .name = "C6",
Len Brownd13780d2010-07-07 00:12:03 -0400254 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100255 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400256 .exit_latency = 104,
Len Brownddbd5502010-12-13 18:28:22 -0500257 .target_residency = 345,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100258 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200259 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500260 {
Len Brownde09cdd2017-02-28 16:32:44 -0500261 .name = "C7",
Len Brownd13780d2010-07-07 00:12:03 -0400262 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100263 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400264 .exit_latency = 109,
Len Brownddbd5502010-12-13 18:28:22 -0500265 .target_residency = 345,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100266 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200267 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500268 {
269 .enter = NULL }
Len Brownd13780d2010-07-07 00:12:03 -0400270};
271
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100272static struct cpuidle_state byt_cstates[] __initdata = {
Len Brown718987d2014-02-14 02:30:00 -0500273 {
Len Brownde09cdd2017-02-28 16:32:44 -0500274 .name = "C1",
Len Brown718987d2014-02-14 02:30:00 -0500275 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100276 .flags = MWAIT2flg(0x00),
Len Brown718987d2014-02-14 02:30:00 -0500277 .exit_latency = 1,
278 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100279 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200280 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500281 {
Len Brownde09cdd2017-02-28 16:32:44 -0500282 .name = "C6N",
Len Brown718987d2014-02-14 02:30:00 -0500283 .desc = "MWAIT 0x58",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100284 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd7ef7672015-03-24 23:23:20 -0400285 .exit_latency = 300,
Len Brown718987d2014-02-14 02:30:00 -0500286 .target_residency = 275,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100287 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200288 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500289 {
Len Brownde09cdd2017-02-28 16:32:44 -0500290 .name = "C6S",
Len Brown718987d2014-02-14 02:30:00 -0500291 .desc = "MWAIT 0x52",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100292 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd7ef7672015-03-24 23:23:20 -0400293 .exit_latency = 500,
Len Brown718987d2014-02-14 02:30:00 -0500294 .target_residency = 560,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100295 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200296 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500297 {
Len Brownde09cdd2017-02-28 16:32:44 -0500298 .name = "C7",
Len Brown718987d2014-02-14 02:30:00 -0500299 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100300 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown718987d2014-02-14 02:30:00 -0500301 .exit_latency = 1200,
Len Brownd7ef7672015-03-24 23:23:20 -0400302 .target_residency = 4000,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100303 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200304 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500305 {
Len Brownde09cdd2017-02-28 16:32:44 -0500306 .name = "C7S",
Len Brown718987d2014-02-14 02:30:00 -0500307 .desc = "MWAIT 0x64",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100308 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown718987d2014-02-14 02:30:00 -0500309 .exit_latency = 10000,
310 .target_residency = 20000,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100311 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200312 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500313 {
314 .enter = NULL }
315};
316
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100317static struct cpuidle_state cht_cstates[] __initdata = {
Len Browncab07a52015-03-27 20:54:01 -0400318 {
Len Brownde09cdd2017-02-28 16:32:44 -0500319 .name = "C1",
Len Browncab07a52015-03-27 20:54:01 -0400320 .desc = "MWAIT 0x00",
321 .flags = MWAIT2flg(0x00),
322 .exit_latency = 1,
323 .target_residency = 1,
324 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200325 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400326 {
Len Brownde09cdd2017-02-28 16:32:44 -0500327 .name = "C6N",
Len Browncab07a52015-03-27 20:54:01 -0400328 .desc = "MWAIT 0x58",
329 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
330 .exit_latency = 80,
331 .target_residency = 275,
332 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200333 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400334 {
Len Brownde09cdd2017-02-28 16:32:44 -0500335 .name = "C6S",
Len Browncab07a52015-03-27 20:54:01 -0400336 .desc = "MWAIT 0x52",
337 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
338 .exit_latency = 200,
339 .target_residency = 560,
340 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200341 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400342 {
Len Brownde09cdd2017-02-28 16:32:44 -0500343 .name = "C7",
Len Browncab07a52015-03-27 20:54:01 -0400344 .desc = "MWAIT 0x60",
345 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
346 .exit_latency = 1200,
347 .target_residency = 4000,
348 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200349 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400350 {
Len Brownde09cdd2017-02-28 16:32:44 -0500351 .name = "C7S",
Len Browncab07a52015-03-27 20:54:01 -0400352 .desc = "MWAIT 0x64",
353 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
354 .exit_latency = 10000,
355 .target_residency = 20000,
356 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200357 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400358 {
359 .enter = NULL }
360};
361
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100362static struct cpuidle_state ivb_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500363 {
Len Brownde09cdd2017-02-28 16:32:44 -0500364 .name = "C1",
Len Brown6edab082012-06-01 19:45:32 -0400365 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100366 .flags = MWAIT2flg(0x00),
Len Brown6edab082012-06-01 19:45:32 -0400367 .exit_latency = 1,
368 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100369 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200370 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500371 {
Len Brownde09cdd2017-02-28 16:32:44 -0500372 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500373 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100374 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500375 .exit_latency = 10,
376 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100377 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200378 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500379 {
Len Brownde09cdd2017-02-28 16:32:44 -0500380 .name = "C3",
Len Brown6edab082012-06-01 19:45:32 -0400381 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100382 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400383 .exit_latency = 59,
384 .target_residency = 156,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100385 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200386 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500387 {
Len Brownde09cdd2017-02-28 16:32:44 -0500388 .name = "C6",
Len Brown6edab082012-06-01 19:45:32 -0400389 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100390 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400391 .exit_latency = 80,
392 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100393 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200394 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500395 {
Len Brownde09cdd2017-02-28 16:32:44 -0500396 .name = "C7",
Len Brown6edab082012-06-01 19:45:32 -0400397 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100398 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400399 .exit_latency = 87,
400 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100401 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200402 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500403 {
404 .enter = NULL }
Len Brown6edab082012-06-01 19:45:32 -0400405};
406
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100407static struct cpuidle_state ivt_cstates[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400408 {
Len Brownde09cdd2017-02-28 16:32:44 -0500409 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400410 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100411 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400412 .exit_latency = 1,
413 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100414 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200415 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400416 {
Len Brownde09cdd2017-02-28 16:32:44 -0500417 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400418 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100419 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400420 .exit_latency = 10,
421 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100422 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200423 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400424 {
Len Brownde09cdd2017-02-28 16:32:44 -0500425 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400426 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100427 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400428 .exit_latency = 59,
429 .target_residency = 156,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100430 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200431 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400432 {
Len Brownde09cdd2017-02-28 16:32:44 -0500433 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400434 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100435 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400436 .exit_latency = 82,
437 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100438 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200439 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400440 {
441 .enter = NULL }
442};
443
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100444static struct cpuidle_state ivt_cstates_4s[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400445 {
Len Brownde09cdd2017-02-28 16:32:44 -0500446 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400447 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100448 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400449 .exit_latency = 1,
450 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100451 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200452 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400453 {
Len Brownde09cdd2017-02-28 16:32:44 -0500454 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400455 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100456 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400457 .exit_latency = 10,
458 .target_residency = 250,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100459 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200460 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400461 {
Len Brownde09cdd2017-02-28 16:32:44 -0500462 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400463 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100464 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400465 .exit_latency = 59,
466 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100467 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200468 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400469 {
Len Brownde09cdd2017-02-28 16:32:44 -0500470 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400471 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100472 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400473 .exit_latency = 84,
474 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100475 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200476 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400477 {
478 .enter = NULL }
479};
480
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100481static struct cpuidle_state ivt_cstates_8s[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400482 {
Len Brownde09cdd2017-02-28 16:32:44 -0500483 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400484 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100485 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400486 .exit_latency = 1,
487 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100488 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200489 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400490 {
Len Brownde09cdd2017-02-28 16:32:44 -0500491 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400492 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100493 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400494 .exit_latency = 10,
495 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100496 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200497 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400498 {
Len Brownde09cdd2017-02-28 16:32:44 -0500499 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400500 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100501 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400502 .exit_latency = 59,
503 .target_residency = 600,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100504 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200505 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400506 {
Len Brownde09cdd2017-02-28 16:32:44 -0500507 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400508 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100509 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400510 .exit_latency = 88,
511 .target_residency = 700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100512 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200513 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400514 {
515 .enter = NULL }
516};
517
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100518static struct cpuidle_state hsw_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500519 {
Len Brownde09cdd2017-02-28 16:32:44 -0500520 .name = "C1",
Len Brown85a4d2d2013-01-31 14:40:49 -0500521 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100522 .flags = MWAIT2flg(0x00),
Len Brown85a4d2d2013-01-31 14:40:49 -0500523 .exit_latency = 2,
524 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100525 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200526 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500527 {
Len Brownde09cdd2017-02-28 16:32:44 -0500528 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500529 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100530 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500531 .exit_latency = 10,
532 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100533 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200534 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500535 {
Len Brownde09cdd2017-02-28 16:32:44 -0500536 .name = "C3",
Len Brown85a4d2d2013-01-31 14:40:49 -0500537 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100538 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500539 .exit_latency = 33,
540 .target_residency = 100,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100541 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200542 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500543 {
Len Brownde09cdd2017-02-28 16:32:44 -0500544 .name = "C6",
Len Brown85a4d2d2013-01-31 14:40:49 -0500545 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100546 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500547 .exit_latency = 133,
548 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100549 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200550 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500551 {
Len Brownde09cdd2017-02-28 16:32:44 -0500552 .name = "C7s",
Len Brown85a4d2d2013-01-31 14:40:49 -0500553 .desc = "MWAIT 0x32",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100554 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500555 .exit_latency = 166,
556 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100557 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200558 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500559 {
Len Brownde09cdd2017-02-28 16:32:44 -0500560 .name = "C8",
Len Brown86239ce2013-02-27 13:18:50 -0500561 .desc = "MWAIT 0x40",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100562 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500563 .exit_latency = 300,
564 .target_residency = 900,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100565 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200566 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500567 {
Len Brownde09cdd2017-02-28 16:32:44 -0500568 .name = "C9",
Len Brown86239ce2013-02-27 13:18:50 -0500569 .desc = "MWAIT 0x50",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100570 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500571 .exit_latency = 600,
572 .target_residency = 1800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100573 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200574 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500575 {
Len Brownde09cdd2017-02-28 16:32:44 -0500576 .name = "C10",
Len Brown86239ce2013-02-27 13:18:50 -0500577 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100578 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500579 .exit_latency = 2600,
580 .target_residency = 7700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100581 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200582 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500583 {
Len Browne022e7e2013-02-01 23:37:30 -0500584 .enter = NULL }
Len Brown85a4d2d2013-01-31 14:40:49 -0500585};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100586static struct cpuidle_state bdw_cstates[] __initdata = {
Len Browna138b562014-02-04 23:56:40 -0500587 {
Len Brownde09cdd2017-02-28 16:32:44 -0500588 .name = "C1",
Len Browna138b562014-02-04 23:56:40 -0500589 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100590 .flags = MWAIT2flg(0x00),
Len Browna138b562014-02-04 23:56:40 -0500591 .exit_latency = 2,
592 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100593 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200594 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500595 {
Len Brownde09cdd2017-02-28 16:32:44 -0500596 .name = "C1E",
Len Browna138b562014-02-04 23:56:40 -0500597 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100598 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Browna138b562014-02-04 23:56:40 -0500599 .exit_latency = 10,
600 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100601 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200602 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500603 {
Len Brownde09cdd2017-02-28 16:32:44 -0500604 .name = "C3",
Len Browna138b562014-02-04 23:56:40 -0500605 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100606 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500607 .exit_latency = 40,
608 .target_residency = 100,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100609 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200610 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500611 {
Len Brownde09cdd2017-02-28 16:32:44 -0500612 .name = "C6",
Len Browna138b562014-02-04 23:56:40 -0500613 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100614 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500615 .exit_latency = 133,
616 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100617 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200618 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500619 {
Len Brownde09cdd2017-02-28 16:32:44 -0500620 .name = "C7s",
Len Browna138b562014-02-04 23:56:40 -0500621 .desc = "MWAIT 0x32",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100622 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500623 .exit_latency = 166,
624 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100625 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200626 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500627 {
Len Brownde09cdd2017-02-28 16:32:44 -0500628 .name = "C8",
Len Browna138b562014-02-04 23:56:40 -0500629 .desc = "MWAIT 0x40",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100630 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500631 .exit_latency = 300,
632 .target_residency = 900,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100633 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200634 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500635 {
Len Brownde09cdd2017-02-28 16:32:44 -0500636 .name = "C9",
Len Browna138b562014-02-04 23:56:40 -0500637 .desc = "MWAIT 0x50",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100638 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500639 .exit_latency = 600,
640 .target_residency = 1800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100641 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200642 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500643 {
Len Brownde09cdd2017-02-28 16:32:44 -0500644 .name = "C10",
Len Browna138b562014-02-04 23:56:40 -0500645 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100646 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500647 .exit_latency = 2600,
648 .target_residency = 7700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100649 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200650 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500651 {
652 .enter = NULL }
653};
Len Brown85a4d2d2013-01-31 14:40:49 -0500654
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100655static struct cpuidle_state skl_cstates[] __initdata = {
Len Brown493f1332015-03-25 23:20:37 -0400656 {
Len Brownde09cdd2017-02-28 16:32:44 -0500657 .name = "C1",
Len Brown493f1332015-03-25 23:20:37 -0400658 .desc = "MWAIT 0x00",
659 .flags = MWAIT2flg(0x00),
660 .exit_latency = 2,
661 .target_residency = 2,
662 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200663 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400664 {
Len Brownde09cdd2017-02-28 16:32:44 -0500665 .name = "C1E",
Len Brown493f1332015-03-25 23:20:37 -0400666 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100667 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown493f1332015-03-25 23:20:37 -0400668 .exit_latency = 10,
669 .target_residency = 20,
670 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200671 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400672 {
Len Brownde09cdd2017-02-28 16:32:44 -0500673 .name = "C3",
Len Brown493f1332015-03-25 23:20:37 -0400674 .desc = "MWAIT 0x10",
675 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
676 .exit_latency = 70,
677 .target_residency = 100,
678 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200679 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400680 {
Len Brownde09cdd2017-02-28 16:32:44 -0500681 .name = "C6",
Len Brown493f1332015-03-25 23:20:37 -0400682 .desc = "MWAIT 0x20",
683 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown135919a2015-09-09 13:35:05 -0400684 .exit_latency = 85,
Len Brown493f1332015-03-25 23:20:37 -0400685 .target_residency = 200,
686 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200687 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400688 {
Len Brownde09cdd2017-02-28 16:32:44 -0500689 .name = "C7s",
Len Brown493f1332015-03-25 23:20:37 -0400690 .desc = "MWAIT 0x33",
691 .flags = MWAIT2flg(0x33) | CPUIDLE_FLAG_TLB_FLUSHED,
692 .exit_latency = 124,
693 .target_residency = 800,
694 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200695 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400696 {
Len Brownde09cdd2017-02-28 16:32:44 -0500697 .name = "C8",
Len Brown493f1332015-03-25 23:20:37 -0400698 .desc = "MWAIT 0x40",
699 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown135919a2015-09-09 13:35:05 -0400700 .exit_latency = 200,
Len Brown493f1332015-03-25 23:20:37 -0400701 .target_residency = 800,
702 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200703 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400704 {
Len Brownde09cdd2017-02-28 16:32:44 -0500705 .name = "C9",
Len Brown135919a2015-09-09 13:35:05 -0400706 .desc = "MWAIT 0x50",
707 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
708 .exit_latency = 480,
709 .target_residency = 5000,
710 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200711 .enter_s2idle = intel_idle_s2idle, },
Len Brown135919a2015-09-09 13:35:05 -0400712 {
Len Brownde09cdd2017-02-28 16:32:44 -0500713 .name = "C10",
Len Brown493f1332015-03-25 23:20:37 -0400714 .desc = "MWAIT 0x60",
715 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
716 .exit_latency = 890,
717 .target_residency = 5000,
718 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200719 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400720 {
721 .enter = NULL }
722};
723
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100724static struct cpuidle_state skx_cstates[] __initdata = {
Len Brownf9e71652016-04-06 17:00:58 -0400725 {
Len Brownde09cdd2017-02-28 16:32:44 -0500726 .name = "C1",
Len Brownf9e71652016-04-06 17:00:58 -0400727 .desc = "MWAIT 0x00",
728 .flags = MWAIT2flg(0x00),
729 .exit_latency = 2,
730 .target_residency = 2,
731 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200732 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400733 {
Len Brownde09cdd2017-02-28 16:32:44 -0500734 .name = "C1E",
Len Brownf9e71652016-04-06 17:00:58 -0400735 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100736 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brownf9e71652016-04-06 17:00:58 -0400737 .exit_latency = 10,
738 .target_residency = 20,
739 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200740 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400741 {
Len Brownde09cdd2017-02-28 16:32:44 -0500742 .name = "C6",
Len Brownf9e71652016-04-06 17:00:58 -0400743 .desc = "MWAIT 0x20",
744 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
745 .exit_latency = 133,
746 .target_residency = 600,
747 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200748 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400749 {
750 .enter = NULL }
751};
752
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100753static struct cpuidle_state atom_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500754 {
Len Brownde09cdd2017-02-28 16:32:44 -0500755 .name = "C1E",
Len Brown26717172010-03-08 14:07:30 -0500756 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100757 .flags = MWAIT2flg(0x00),
Len Brown32e95182013-02-02 01:31:56 -0500758 .exit_latency = 10,
759 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100760 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200761 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500762 {
Len Brownde09cdd2017-02-28 16:32:44 -0500763 .name = "C2",
Len Brown26717172010-03-08 14:07:30 -0500764 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100765 .flags = MWAIT2flg(0x10),
Len Brown26717172010-03-08 14:07:30 -0500766 .exit_latency = 20,
Len Brown26717172010-03-08 14:07:30 -0500767 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100768 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200769 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500770 {
Len Brownde09cdd2017-02-28 16:32:44 -0500771 .name = "C4",
Len Brown26717172010-03-08 14:07:30 -0500772 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100773 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500774 .exit_latency = 100,
Len Brown26717172010-03-08 14:07:30 -0500775 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100776 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200777 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500778 {
Len Brownde09cdd2017-02-28 16:32:44 -0500779 .name = "C6",
Len Brown7fcca7d2010-10-05 13:43:14 -0400780 .desc = "MWAIT 0x52",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100781 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown7fcca7d2010-10-05 13:43:14 -0400782 .exit_latency = 140,
Len Brown7fcca7d2010-10-05 13:43:14 -0400783 .target_residency = 560,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100784 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200785 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500786 {
787 .enter = NULL }
Len Brown26717172010-03-08 14:07:30 -0500788};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100789static struct cpuidle_state tangier_cstates[] __initdata = {
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300790 {
Len Brownde09cdd2017-02-28 16:32:44 -0500791 .name = "C1",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300792 .desc = "MWAIT 0x00",
793 .flags = MWAIT2flg(0x00),
794 .exit_latency = 1,
795 .target_residency = 4,
796 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200797 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300798 {
Len Brownde09cdd2017-02-28 16:32:44 -0500799 .name = "C4",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300800 .desc = "MWAIT 0x30",
801 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
802 .exit_latency = 100,
803 .target_residency = 400,
804 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200805 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300806 {
Len Brownde09cdd2017-02-28 16:32:44 -0500807 .name = "C6",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300808 .desc = "MWAIT 0x52",
809 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
810 .exit_latency = 140,
811 .target_residency = 560,
812 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200813 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300814 {
Len Brownde09cdd2017-02-28 16:32:44 -0500815 .name = "C7",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300816 .desc = "MWAIT 0x60",
817 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
818 .exit_latency = 1200,
819 .target_residency = 4000,
820 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200821 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300822 {
Len Brownde09cdd2017-02-28 16:32:44 -0500823 .name = "C9",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300824 .desc = "MWAIT 0x64",
825 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
826 .exit_latency = 10000,
827 .target_residency = 20000,
828 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200829 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300830 {
831 .enter = NULL }
832};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100833static struct cpuidle_state avn_cstates[] __initdata = {
Len Brownfab04b22013-11-09 00:30:17 -0500834 {
Len Brownde09cdd2017-02-28 16:32:44 -0500835 .name = "C1",
Len Brownfab04b22013-11-09 00:30:17 -0500836 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100837 .flags = MWAIT2flg(0x00),
Len Brownfab04b22013-11-09 00:30:17 -0500838 .exit_latency = 2,
839 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100840 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200841 .enter_s2idle = intel_idle_s2idle, },
Len Brownfab04b22013-11-09 00:30:17 -0500842 {
Len Brownde09cdd2017-02-28 16:32:44 -0500843 .name = "C6",
Len Brownfab04b22013-11-09 00:30:17 -0500844 .desc = "MWAIT 0x51",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100845 .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownfab04b22013-11-09 00:30:17 -0500846 .exit_latency = 15,
847 .target_residency = 45,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100848 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200849 .enter_s2idle = intel_idle_s2idle, },
Jiang Liu88390992014-01-09 15:30:27 +0800850 {
851 .enter = NULL }
Len Brownfab04b22013-11-09 00:30:17 -0500852};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100853static struct cpuidle_state knl_cstates[] __initdata = {
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700854 {
Len Brownde09cdd2017-02-28 16:32:44 -0500855 .name = "C1",
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700856 .desc = "MWAIT 0x00",
857 .flags = MWAIT2flg(0x00),
858 .exit_latency = 1,
859 .target_residency = 2,
860 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200861 .enter_s2idle = intel_idle_s2idle },
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700862 {
Len Brownde09cdd2017-02-28 16:32:44 -0500863 .name = "C6",
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700864 .desc = "MWAIT 0x10",
865 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
866 .exit_latency = 120,
867 .target_residency = 500,
868 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200869 .enter_s2idle = intel_idle_s2idle },
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700870 {
871 .enter = NULL }
872};
Len Brown26717172010-03-08 14:07:30 -0500873
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100874static struct cpuidle_state bxt_cstates[] __initdata = {
Len Brown5dcef692016-04-06 17:00:47 -0400875 {
Len Brownde09cdd2017-02-28 16:32:44 -0500876 .name = "C1",
Len Brown5dcef692016-04-06 17:00:47 -0400877 .desc = "MWAIT 0x00",
878 .flags = MWAIT2flg(0x00),
879 .exit_latency = 2,
880 .target_residency = 2,
881 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200882 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400883 {
Len Brownde09cdd2017-02-28 16:32:44 -0500884 .name = "C1E",
Len Brown5dcef692016-04-06 17:00:47 -0400885 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100886 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown5dcef692016-04-06 17:00:47 -0400887 .exit_latency = 10,
888 .target_residency = 20,
889 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200890 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400891 {
Len Brownde09cdd2017-02-28 16:32:44 -0500892 .name = "C6",
Len Brown5dcef692016-04-06 17:00:47 -0400893 .desc = "MWAIT 0x20",
894 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
895 .exit_latency = 133,
896 .target_residency = 133,
897 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200898 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400899 {
Len Brownde09cdd2017-02-28 16:32:44 -0500900 .name = "C7s",
Len Brown5dcef692016-04-06 17:00:47 -0400901 .desc = "MWAIT 0x31",
902 .flags = MWAIT2flg(0x31) | CPUIDLE_FLAG_TLB_FLUSHED,
903 .exit_latency = 155,
904 .target_residency = 155,
905 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200906 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400907 {
Len Brownde09cdd2017-02-28 16:32:44 -0500908 .name = "C8",
Len Brown5dcef692016-04-06 17:00:47 -0400909 .desc = "MWAIT 0x40",
910 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
911 .exit_latency = 1000,
912 .target_residency = 1000,
913 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200914 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400915 {
Len Brownde09cdd2017-02-28 16:32:44 -0500916 .name = "C9",
Len Brown5dcef692016-04-06 17:00:47 -0400917 .desc = "MWAIT 0x50",
918 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
919 .exit_latency = 2000,
920 .target_residency = 2000,
921 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200922 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400923 {
Len Brownde09cdd2017-02-28 16:32:44 -0500924 .name = "C10",
Len Brown5dcef692016-04-06 17:00:47 -0400925 .desc = "MWAIT 0x60",
926 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
927 .exit_latency = 10000,
928 .target_residency = 10000,
929 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200930 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400931 {
932 .enter = NULL }
933};
934
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100935static struct cpuidle_state dnv_cstates[] __initdata = {
Jacob Pan0080d652016-06-17 01:28:34 -0400936 {
Len Brownde09cdd2017-02-28 16:32:44 -0500937 .name = "C1",
Jacob Pan0080d652016-06-17 01:28:34 -0400938 .desc = "MWAIT 0x00",
939 .flags = MWAIT2flg(0x00),
940 .exit_latency = 2,
941 .target_residency = 2,
942 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200943 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400944 {
Len Brownde09cdd2017-02-28 16:32:44 -0500945 .name = "C1E",
Jacob Pan0080d652016-06-17 01:28:34 -0400946 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100947 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Jacob Pan0080d652016-06-17 01:28:34 -0400948 .exit_latency = 10,
949 .target_residency = 20,
950 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200951 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400952 {
Len Brownde09cdd2017-02-28 16:32:44 -0500953 .name = "C6",
Jacob Pan0080d652016-06-17 01:28:34 -0400954 .desc = "MWAIT 0x20",
955 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
956 .exit_latency = 50,
957 .target_residency = 500,
958 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200959 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400960 {
961 .enter = NULL }
962};
963
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100964static const struct idle_cpu idle_cpu_nehalem __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100965 .state_table = nehalem_cstates,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100966 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
Len Brown32e95182013-02-02 01:31:56 -0500967 .disable_promotion_to_c1e = true,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100968};
969
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100970static const struct idle_cpu idle_cpu_nhx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100971 .state_table = nehalem_cstates,
972 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
973 .disable_promotion_to_c1e = true,
974 .use_acpi = true,
975};
976
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100977static const struct idle_cpu idle_cpu_atom __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100978 .state_table = atom_cstates,
979};
980
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100981static const struct idle_cpu idle_cpu_tangier __initconst = {
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300982 .state_table = tangier_cstates,
983};
984
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100985static const struct idle_cpu idle_cpu_lincroft __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100986 .state_table = atom_cstates,
987 .auto_demotion_disable_flags = ATM_LNC_C6_AUTO_DEMOTE,
988};
989
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100990static const struct idle_cpu idle_cpu_snb __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100991 .state_table = snb_cstates,
Len Brown32e95182013-02-02 01:31:56 -0500992 .disable_promotion_to_c1e = true,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100993};
994
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100995static const struct idle_cpu idle_cpu_snx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100996 .state_table = snb_cstates,
997 .disable_promotion_to_c1e = true,
998 .use_acpi = true,
999};
1000
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001001static const struct idle_cpu idle_cpu_byt __initconst = {
Len Brown718987d2014-02-14 02:30:00 -05001002 .state_table = byt_cstates,
1003 .disable_promotion_to_c1e = true,
Len Brown8c058d532014-07-31 15:21:24 -04001004 .byt_auto_demotion_disable_flag = true,
Len Brown718987d2014-02-14 02:30:00 -05001005};
1006
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001007static const struct idle_cpu idle_cpu_cht __initconst = {
Len Browncab07a52015-03-27 20:54:01 -04001008 .state_table = cht_cstates,
1009 .disable_promotion_to_c1e = true,
1010 .byt_auto_demotion_disable_flag = true,
1011};
1012
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001013static const struct idle_cpu idle_cpu_ivb __initconst = {
Len Brown6edab082012-06-01 19:45:32 -04001014 .state_table = ivb_cstates,
Len Brown32e95182013-02-02 01:31:56 -05001015 .disable_promotion_to_c1e = true,
Len Brown6edab082012-06-01 19:45:32 -04001016};
1017
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001018static const struct idle_cpu idle_cpu_ivt __initconst = {
Len Brown0138d8f2014-04-04 01:21:07 -04001019 .state_table = ivt_cstates,
1020 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001021 .use_acpi = true,
Len Brown0138d8f2014-04-04 01:21:07 -04001022};
1023
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001024static const struct idle_cpu idle_cpu_hsw __initconst = {
Len Brown85a4d2d2013-01-31 14:40:49 -05001025 .state_table = hsw_cstates,
Len Brown32e95182013-02-02 01:31:56 -05001026 .disable_promotion_to_c1e = true,
Len Brown85a4d2d2013-01-31 14:40:49 -05001027};
1028
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001029static const struct idle_cpu idle_cpu_hsx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001030 .state_table = hsw_cstates,
1031 .disable_promotion_to_c1e = true,
1032 .use_acpi = true,
1033};
1034
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001035static const struct idle_cpu idle_cpu_bdw __initconst = {
Len Browna138b562014-02-04 23:56:40 -05001036 .state_table = bdw_cstates,
1037 .disable_promotion_to_c1e = true,
1038};
1039
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001040static const struct idle_cpu idle_cpu_bdx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001041 .state_table = bdw_cstates,
1042 .disable_promotion_to_c1e = true,
1043 .use_acpi = true,
1044};
1045
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001046static const struct idle_cpu idle_cpu_skl __initconst = {
Len Brown493f1332015-03-25 23:20:37 -04001047 .state_table = skl_cstates,
1048 .disable_promotion_to_c1e = true,
1049};
1050
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001051static const struct idle_cpu idle_cpu_skx __initconst = {
Len Brownf9e71652016-04-06 17:00:58 -04001052 .state_table = skx_cstates,
1053 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001054 .use_acpi = true,
Len Brownf9e71652016-04-06 17:00:58 -04001055};
Len Brown493f1332015-03-25 23:20:37 -04001056
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001057static const struct idle_cpu idle_cpu_avn __initconst = {
Len Brownfab04b22013-11-09 00:30:17 -05001058 .state_table = avn_cstates,
1059 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001060 .use_acpi = true,
Len Brownfab04b22013-11-09 00:30:17 -05001061};
1062
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001063static const struct idle_cpu idle_cpu_knl __initconst = {
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -07001064 .state_table = knl_cstates,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001065 .use_acpi = true,
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -07001066};
1067
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001068static const struct idle_cpu idle_cpu_bxt __initconst = {
Len Brown5dcef692016-04-06 17:00:47 -04001069 .state_table = bxt_cstates,
1070 .disable_promotion_to_c1e = true,
1071};
1072
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001073static const struct idle_cpu idle_cpu_dnv __initconst = {
Jacob Pan0080d652016-06-17 01:28:34 -04001074 .state_table = dnv_cstates,
1075 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001076 .use_acpi = true,
Jacob Pan0080d652016-06-17 01:28:34 -04001077};
1078
Mathias Kraused5cdc3c2015-03-25 22:15:14 +01001079static const struct x86_cpu_id intel_idle_ids[] __initconst = {
Thomas Gleixner4a9f45a2020-03-20 14:14:00 +01001080 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EP, &idle_cpu_nhx),
1081 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM, &idle_cpu_nehalem),
1082 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_G, &idle_cpu_nehalem),
1083 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE, &idle_cpu_nehalem),
1084 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EP, &idle_cpu_nhx),
1085 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EX, &idle_cpu_nhx),
1086 X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL, &idle_cpu_atom),
1087 X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL_MID, &idle_cpu_lincroft),
1088 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EX, &idle_cpu_nhx),
1089 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &idle_cpu_snb),
1090 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &idle_cpu_snx),
1091 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL, &idle_cpu_atom),
1092 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, &idle_cpu_byt),
1093 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &idle_cpu_tangier),
1094 X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, &idle_cpu_cht),
1095 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, &idle_cpu_ivb),
1096 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, &idle_cpu_ivt),
1097 X86_MATCH_INTEL_FAM6_MODEL(HASWELL, &idle_cpu_hsw),
1098 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, &idle_cpu_hsx),
1099 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_L, &idle_cpu_hsw),
1100 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_G, &idle_cpu_hsw),
1101 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D, &idle_cpu_avn),
1102 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL, &idle_cpu_bdw),
1103 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_G, &idle_cpu_bdw),
1104 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, &idle_cpu_bdx),
1105 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, &idle_cpu_bdx),
1106 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, &idle_cpu_skl),
1107 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, &idle_cpu_skl),
1108 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, &idle_cpu_skl),
1109 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, &idle_cpu_skl),
1110 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &idle_cpu_skx),
1111 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &idle_cpu_knl),
1112 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &idle_cpu_knl),
1113 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, &idle_cpu_bxt),
1114 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_PLUS, &idle_cpu_bxt),
1115 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, &idle_cpu_dnv),
1116 X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &idle_cpu_dnv),
Andi Kleenb66b8b92012-01-26 00:09:07 +01001117 {}
1118};
Andi Kleenb66b8b92012-01-26 00:09:07 +01001119
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001120static const struct x86_cpu_id intel_mwait_ids[] __initconst = {
Thomas Gleixner4a9f45a2020-03-20 14:14:00 +01001121 X86_MATCH_VENDOR_FAM_FEATURE(INTEL, 6, X86_FEATURE_MWAIT, NULL),
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001122 {}
1123};
1124
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001125static bool __init intel_idle_max_cstate_reached(int cstate)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001126{
1127 if (cstate + 1 > max_cstate) {
1128 pr_info("max_cstate %d reached\n", max_cstate);
1129 return true;
1130 }
1131 return false;
1132}
1133
1134#ifdef CONFIG_ACPI_PROCESSOR_CSTATE
1135#include <acpi/processor.h>
1136
Rafael J. Wysocki4ec32d92019-12-13 09:56:29 +01001137static bool no_acpi __read_mostly;
1138module_param(no_acpi, bool, 0444);
1139MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list");
1140
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001141static bool force_use_acpi __read_mostly; /* No effect if no_acpi is set. */
1142module_param_named(use_acpi, force_use_acpi, bool, 0444);
1143MODULE_PARM_DESC(use_acpi, "Use ACPI _CST for building the idle states list");
1144
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001145static struct acpi_processor_power acpi_state_table __initdata;
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001146
1147/**
1148 * intel_idle_cst_usable - Check if the _CST information can be used.
1149 *
1150 * Check if all of the C-states listed by _CST in the max_cstate range are
1151 * ACPI_CSTATE_FFH, which means that they should be entered via MWAIT.
1152 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001153static bool __init intel_idle_cst_usable(void)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001154{
1155 int cstate, limit;
1156
1157 limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1),
1158 acpi_state_table.count);
1159
1160 for (cstate = 1; cstate < limit; cstate++) {
1161 struct acpi_processor_cx *cx = &acpi_state_table.states[cstate];
1162
1163 if (cx->entry_method != ACPI_CSTATE_FFH)
1164 return false;
1165 }
1166
1167 return true;
1168}
1169
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001170static bool __init intel_idle_acpi_cst_extract(void)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001171{
1172 unsigned int cpu;
1173
Rafael J. Wysocki4ec32d92019-12-13 09:56:29 +01001174 if (no_acpi) {
1175 pr_debug("Not allowed to use ACPI _CST\n");
1176 return false;
1177 }
1178
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001179 for_each_possible_cpu(cpu) {
1180 struct acpi_processor *pr = per_cpu(processors, cpu);
1181
1182 if (!pr)
1183 continue;
1184
1185 if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table))
1186 continue;
1187
1188 acpi_state_table.count++;
1189
1190 if (!intel_idle_cst_usable())
1191 continue;
1192
1193 if (!acpi_processor_claim_cst_control()) {
1194 acpi_state_table.count = 0;
1195 return false;
1196 }
1197
1198 return true;
1199 }
1200
1201 pr_debug("ACPI _CST not found or not usable\n");
1202 return false;
1203}
1204
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001205static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001206{
1207 int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
1208
1209 /*
1210 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
1211 * the interesting states are ACPI_CSTATE_FFH.
1212 */
1213 for (cstate = 1; cstate < limit; cstate++) {
1214 struct acpi_processor_cx *cx;
1215 struct cpuidle_state *state;
1216
1217 if (intel_idle_max_cstate_reached(cstate))
1218 break;
1219
1220 cx = &acpi_state_table.states[cstate];
1221
1222 state = &drv->states[drv->state_count++];
1223
1224 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d_ACPI", cstate);
1225 strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1226 state->exit_latency = cx->latency;
1227 /*
1228 * For C1-type C-states use the same number for both the exit
1229 * latency and target residency, because that is the case for
1230 * C1 in the majority of the static C-states tables above.
1231 * For the other types of C-states, however, set the target
1232 * residency to 3 times the exit latency which should lead to
1233 * a reasonable balance between energy-efficiency and
1234 * performance in the majority of interesting cases.
1235 */
1236 state->target_residency = cx->latency;
1237 if (cx->type > ACPI_STATE_C1)
1238 state->target_residency *= 3;
1239
1240 state->flags = MWAIT2flg(cx->address);
1241 if (cx->type > ACPI_STATE_C2)
1242 state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
1243
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001244 if (disabled_states_mask & BIT(cstate))
1245 state->flags |= CPUIDLE_FLAG_OFF;
1246
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001247 state->enter = intel_idle;
1248 state->enter_s2idle = intel_idle_s2idle;
1249 }
1250}
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001251
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001252static bool __init intel_idle_off_by_default(u32 mwait_hint)
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001253{
1254 int cstate, limit;
1255
1256 /*
1257 * If there are no _CST C-states, do not disable any C-states by
1258 * default.
1259 */
1260 if (!acpi_state_table.count)
1261 return false;
1262
1263 limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
1264 /*
1265 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
1266 * the interesting states are ACPI_CSTATE_FFH.
1267 */
1268 for (cstate = 1; cstate < limit; cstate++) {
1269 if (acpi_state_table.states[cstate].address == mwait_hint)
1270 return false;
1271 }
1272 return true;
1273}
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001274#else /* !CONFIG_ACPI_PROCESSOR_CSTATE */
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001275#define force_use_acpi (false)
1276
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001277static inline bool intel_idle_acpi_cst_extract(void) { return false; }
1278static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { }
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001279static inline bool intel_idle_off_by_default(u32 mwait_hint) { return false; }
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001280#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
1281
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001282/**
1283 * ivt_idle_state_table_update - Tune the idle states table for Ivy Town.
Len Brownd70e28f2016-03-13 00:33:48 -05001284 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001285 * Tune IVT multi-socket targets.
1286 * Assumption: num_sockets == (max_package_num + 1).
Len Brownd70e28f2016-03-13 00:33:48 -05001287 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001288static void __init ivt_idle_state_table_update(void)
Len Brownd70e28f2016-03-13 00:33:48 -05001289{
1290 /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
1291 int cpu, package_num, num_sockets = 1;
1292
1293 for_each_online_cpu(cpu) {
1294 package_num = topology_physical_package_id(cpu);
1295 if (package_num + 1 > num_sockets) {
1296 num_sockets = package_num + 1;
1297
1298 if (num_sockets > 4) {
1299 cpuidle_state_table = ivt_cstates_8s;
1300 return;
1301 }
1302 }
1303 }
1304
1305 if (num_sockets > 2)
1306 cpuidle_state_table = ivt_cstates_4s;
1307
1308 /* else, 1 and 2 socket systems use default ivt_cstates */
1309}
Len Brown5dcef692016-04-06 17:00:47 -04001310
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001311/**
1312 * irtl_2_usec - IRTL to microseconds conversion.
1313 * @irtl: IRTL MSR value.
1314 *
1315 * Translate the IRTL (Interrupt Response Time Limit) MSR value to microseconds.
Len Brown5dcef692016-04-06 17:00:47 -04001316 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001317static unsigned long long __init irtl_2_usec(unsigned long long irtl)
Len Brown5dcef692016-04-06 17:00:47 -04001318{
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001319 static const unsigned int irtl_ns_units[] __initconst = {
1320 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
1321 };
Len Brown5dcef692016-04-06 17:00:47 -04001322 unsigned long long ns;
1323
Jan Beulich3451ab32016-06-27 00:35:12 -06001324 if (!irtl)
1325 return 0;
1326
Jan Beulichbef45092016-06-27 00:35:48 -06001327 ns = irtl_ns_units[(irtl >> 10) & 0x7];
Len Brown5dcef692016-04-06 17:00:47 -04001328
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001329 return div_u64((irtl & 0x3FF) * ns, NSEC_PER_USEC);
Len Brown5dcef692016-04-06 17:00:47 -04001330}
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001331
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001332/**
1333 * bxt_idle_state_table_update - Fix up the Broxton idle states table.
Len Brown5dcef692016-04-06 17:00:47 -04001334 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001335 * On BXT, trust the IRTL (Interrupt Response Time Limit) MSR to show the
1336 * definitive maximum latency and use the same value for target_residency.
Len Brown5dcef692016-04-06 17:00:47 -04001337 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001338static void __init bxt_idle_state_table_update(void)
Len Brown5dcef692016-04-06 17:00:47 -04001339{
1340 unsigned long long msr;
Jan Beulich3451ab32016-06-27 00:35:12 -06001341 unsigned int usec;
Len Brown5dcef692016-04-06 17:00:47 -04001342
1343 rdmsrl(MSR_PKGC6_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001344 usec = irtl_2_usec(msr);
1345 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001346 bxt_cstates[2].exit_latency = usec;
1347 bxt_cstates[2].target_residency = usec;
1348 }
1349
1350 rdmsrl(MSR_PKGC7_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001351 usec = irtl_2_usec(msr);
1352 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001353 bxt_cstates[3].exit_latency = usec;
1354 bxt_cstates[3].target_residency = usec;
1355 }
1356
1357 rdmsrl(MSR_PKGC8_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001358 usec = irtl_2_usec(msr);
1359 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001360 bxt_cstates[4].exit_latency = usec;
1361 bxt_cstates[4].target_residency = usec;
1362 }
1363
1364 rdmsrl(MSR_PKGC9_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001365 usec = irtl_2_usec(msr);
1366 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001367 bxt_cstates[5].exit_latency = usec;
1368 bxt_cstates[5].target_residency = usec;
1369 }
1370
1371 rdmsrl(MSR_PKGC10_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001372 usec = irtl_2_usec(msr);
1373 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001374 bxt_cstates[6].exit_latency = usec;
1375 bxt_cstates[6].target_residency = usec;
1376 }
1377
1378}
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001379
1380/**
1381 * sklh_idle_state_table_update - Fix up the Sky Lake idle states table.
Len Brownd70e28f2016-03-13 00:33:48 -05001382 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001383 * On SKL-H (model 0x5e) skip C8 and C9 if C10 is enabled and SGX disabled.
Len Brownd70e28f2016-03-13 00:33:48 -05001384 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001385static void __init sklh_idle_state_table_update(void)
Len Brownd70e28f2016-03-13 00:33:48 -05001386{
1387 unsigned long long msr;
1388 unsigned int eax, ebx, ecx, edx;
1389
1390
1391 /* if PC10 disabled via cmdline intel_idle.max_cstate=7 or shallower */
1392 if (max_cstate <= 7)
1393 return;
1394
1395 /* if PC10 not present in CPUID.MWAIT.EDX */
1396 if ((mwait_substates & (0xF << 28)) == 0)
1397 return;
1398
Len Brown6cfb2372017-01-07 23:23:25 -05001399 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr);
Len Brownd70e28f2016-03-13 00:33:48 -05001400
1401 /* PC10 is not enabled in PKG C-state limit */
1402 if ((msr & 0xF) != 8)
1403 return;
1404
1405 ecx = 0;
1406 cpuid(7, &eax, &ebx, &ecx, &edx);
1407
1408 /* if SGX is present */
1409 if (ebx & (1 << 2)) {
1410
Sean Christopherson32ad73d2019-12-20 20:44:55 -08001411 rdmsrl(MSR_IA32_FEAT_CTL, msr);
Len Brownd70e28f2016-03-13 00:33:48 -05001412
1413 /* if SGX is enabled */
1414 if (msr & (1 << 18))
1415 return;
1416 }
1417
Rafael J. Wysockiba1e78a2019-11-21 19:41:51 +01001418 skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
1419 skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
Len Brownd70e28f2016-03-13 00:33:48 -05001420}
Len Brownd70e28f2016-03-13 00:33:48 -05001421
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001422static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
1423{
1424 unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
1425 unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
1426 MWAIT_SUBSTATE_MASK;
1427
1428 /* Ignore the C-state if there are NO sub-states in CPUID for it. */
1429 if (num_substates == 0)
1430 return false;
1431
1432 if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
1433 mark_tsc_unstable("TSC halts in idle states deeper than C2");
1434
1435 return true;
1436}
1437
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001438static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
Len Brown0138d8f2014-04-04 01:21:07 -04001439{
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001440 int cstate;
Len Brown0138d8f2014-04-04 01:21:07 -04001441
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001442 switch (boot_cpu_data.x86_model) {
Dave Hansendb73c5a2016-06-02 17:19:32 -07001443 case INTEL_FAM6_IVYBRIDGE_X:
Len Brownd70e28f2016-03-13 00:33:48 -05001444 ivt_idle_state_table_update();
1445 break;
Dave Hansendb73c5a2016-06-02 17:19:32 -07001446 case INTEL_FAM6_ATOM_GOLDMONT:
Peter Zijlstraf2c4db12018-08-07 10:17:27 -07001447 case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
Len Brown5dcef692016-04-06 17:00:47 -04001448 bxt_idle_state_table_update();
1449 break;
Peter Zijlstrac66f78a2019-08-27 21:48:21 +02001450 case INTEL_FAM6_SKYLAKE:
Len Brownd70e28f2016-03-13 00:33:48 -05001451 sklh_idle_state_table_update();
1452 break;
Len Brown0138d8f2014-04-04 01:21:07 -04001453 }
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301454
Len Browne022e7e2013-02-01 23:37:30 -05001455 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001456 unsigned int mwait_hint;
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301457
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001458 if (intel_idle_max_cstate_reached(cstate))
1459 break;
1460
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001461 if (!cpuidle_state_table[cstate].enter &&
1462 !cpuidle_state_table[cstate].enter_s2idle)
Len Browne022e7e2013-02-01 23:37:30 -05001463 break;
1464
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001465 /* If marked as unusable, skip this state. */
Rafael J. Wysockiba1e78a2019-11-21 19:41:51 +01001466 if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
Joe Perches654d08a2017-06-09 12:29:20 -07001467 pr_debug("state %s is disabled\n",
1468 cpuidle_state_table[cstate].name);
Len Brownd70e28f2016-03-13 00:33:48 -05001469 continue;
1470 }
1471
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001472 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
1473 if (!intel_idle_verify_cstate(mwait_hint))
1474 continue;
Len Brownd70e28f2016-03-13 00:33:48 -05001475
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001476 /* Structure copy. */
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001477 drv->states[drv->state_count] = cpuidle_state_table[cstate];
1478
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001479 if ((disabled_states_mask & BIT(drv->state_count)) ||
1480 ((icpu->use_acpi || force_use_acpi) &&
1481 intel_idle_off_by_default(mwait_hint) &&
1482 !(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001483 drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF;
1484
1485 drv->state_count++;
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301486 }
1487
Len Brown8c058d532014-07-31 15:21:24 -04001488 if (icpu->byt_auto_demotion_disable_flag) {
1489 wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
1490 wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
1491 }
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301492}
1493
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001494/**
1495 * intel_idle_cpuidle_driver_init - Create the list of available idle states.
1496 * @drv: cpuidle driver structure to initialize.
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001497 */
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001498static void __init intel_idle_cpuidle_driver_init(struct cpuidle_driver *drv)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001499{
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001500 cpuidle_poll_state_init(drv);
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001501
1502 if (disabled_states_mask & BIT(0))
1503 drv->states[0].flags |= CPUIDLE_FLAG_OFF;
1504
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001505 drv->state_count = 1;
1506
1507 if (icpu)
1508 intel_idle_init_cstates_icpu(drv);
1509 else
1510 intel_idle_init_cstates_acpi(drv);
1511}
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301512
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001513static void auto_demotion_disable(void)
1514{
1515 unsigned long long msr_bits;
1516
1517 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001518 msr_bits &= ~auto_demotion_disable_flags;
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001519 wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
1520}
1521
1522static void c1e_promotion_disable(void)
1523{
1524 unsigned long long msr_bits;
1525
1526 rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
1527 msr_bits &= ~0x2;
1528 wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
1529}
1530
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001531/**
1532 * intel_idle_cpu_init - Register the target CPU with the cpuidle core.
1533 * @cpu: CPU to initialize.
1534 *
1535 * Register a cpuidle device object for @cpu and update its MSRs in accordance
1536 * with the processor model flags.
Len Brown26717172010-03-08 14:07:30 -05001537 */
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001538static int intel_idle_cpu_init(unsigned int cpu)
Len Brown26717172010-03-08 14:07:30 -05001539{
Len Brown26717172010-03-08 14:07:30 -05001540 struct cpuidle_device *dev;
1541
Thomas Renninger65b7f832012-01-17 22:40:08 +01001542 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
Thomas Renninger65b7f832012-01-17 22:40:08 +01001543 dev->cpu = cpu;
Len Brown26717172010-03-08 14:07:30 -05001544
Thomas Renninger65b7f832012-01-17 22:40:08 +01001545 if (cpuidle_register_device(dev)) {
Joe Perches654d08a2017-06-09 12:29:20 -07001546 pr_debug("cpuidle_register_device %d failed!\n", cpu);
Thomas Renninger65b7f832012-01-17 22:40:08 +01001547 return -EIO;
Len Brown26717172010-03-08 14:07:30 -05001548 }
1549
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001550 if (auto_demotion_disable_flags)
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001551 auto_demotion_disable();
Thomas Renninger65b7f832012-01-17 22:40:08 +01001552
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001553 if (disable_promotion_to_c1e)
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001554 c1e_promotion_disable();
1555
1556 return 0;
1557}
1558
1559static int intel_idle_cpu_online(unsigned int cpu)
1560{
1561 struct cpuidle_device *dev;
1562
Rafael J. Wysockidab20172020-06-29 13:58:28 +02001563 if (!boot_cpu_has(X86_FEATURE_ARAT))
Rafael J. Wysockicbd2c4c2020-01-10 11:43:23 +01001564 tick_broadcast_enable();
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001565
1566 /*
1567 * Some systems can hotplug a cpu at runtime after
1568 * the kernel has booted, we have to initialize the
1569 * driver in this case
1570 */
1571 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
1572 if (!dev->registered)
1573 return intel_idle_cpu_init(cpu);
Bartlomiej Zolnierkiewiczdbf87ab2013-12-20 19:47:28 +01001574
Len Brown26717172010-03-08 14:07:30 -05001575 return 0;
1576}
Len Brown26717172010-03-08 14:07:30 -05001577
Rafael J. Wysocki0755a9b2020-01-10 11:49:58 +01001578/**
1579 * intel_idle_cpuidle_devices_uninit - Unregister all cpuidle devices.
1580 */
1581static void __init intel_idle_cpuidle_devices_uninit(void)
1582{
1583 int i;
1584
1585 for_each_online_cpu(i)
1586 cpuidle_unregister_device(per_cpu_ptr(intel_idle_cpuidle_devices, i));
1587}
1588
Len Brown26717172010-03-08 14:07:30 -05001589static int __init intel_idle_init(void)
1590{
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001591 const struct x86_cpu_id *id;
1592 unsigned int eax, ebx, ecx;
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001593 int retval;
Len Brown26717172010-03-08 14:07:30 -05001594
Thomas Renningerd1896042010-11-03 17:06:14 +01001595 /* Do not load intel_idle at all for now if idle= is passed */
1596 if (boot_option_idle_override != IDLE_NO_OVERRIDE)
1597 return -ENODEV;
1598
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001599 if (max_cstate == 0) {
1600 pr_debug("disabled\n");
1601 return -EPERM;
1602 }
1603
1604 id = x86_match_cpu(intel_idle_ids);
1605 if (id) {
1606 if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
1607 pr_debug("Please enable MWAIT in BIOS SETUP\n");
1608 return -ENODEV;
1609 }
1610 } else {
1611 id = x86_match_cpu(intel_mwait_ids);
1612 if (!id)
1613 return -ENODEV;
1614 }
1615
1616 if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
1617 return -ENODEV;
1618
1619 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
1620
1621 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
1622 !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
1623 !mwait_substates)
1624 return -ENODEV;
1625
1626 pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
1627
1628 icpu = (const struct idle_cpu *)id->driver_data;
1629 if (icpu) {
1630 cpuidle_state_table = icpu->state_table;
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001631 auto_demotion_disable_flags = icpu->auto_demotion_disable_flags;
1632 disable_promotion_to_c1e = icpu->disable_promotion_to_c1e;
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001633 if (icpu->use_acpi || force_use_acpi)
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001634 intel_idle_acpi_cst_extract();
1635 } else if (!intel_idle_acpi_cst_extract()) {
1636 return -ENODEV;
1637 }
1638
1639 pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
1640 boot_cpu_data.x86_model);
Len Brown26717172010-03-08 14:07:30 -05001641
Richard Cochrane9df69c2016-04-06 17:00:52 -04001642 intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
Rafael J. Wysocki533da742020-01-10 11:45:49 +01001643 if (!intel_idle_cpuidle_devices)
Richard Cochrane9df69c2016-04-06 17:00:52 -04001644 return -ENOMEM;
1645
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001646 intel_idle_cpuidle_driver_init(&intel_idle_driver);
1647
Len Brown26717172010-03-08 14:07:30 -05001648 retval = cpuidle_register_driver(&intel_idle_driver);
1649 if (retval) {
Konrad Rzeszutek Wilk3735d522012-08-16 22:06:55 +02001650 struct cpuidle_driver *drv = cpuidle_get_driver();
Joe Perches654d08a2017-06-09 12:29:20 -07001651 printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"),
1652 drv ? drv->name : "none");
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001653 goto init_driver_fail;
Len Brown26717172010-03-08 14:07:30 -05001654 }
1655
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001656 retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online",
1657 intel_idle_cpu_online, NULL);
1658 if (retval < 0)
1659 goto hp_setup_fail;
Len Brown26717172010-03-08 14:07:30 -05001660
Rafael J. Wysocki40ab82e2020-02-06 18:40:54 +01001661 pr_debug("Local APIC timer is reliable in %s\n",
Rafael J. Wysockidab20172020-06-29 13:58:28 +02001662 boot_cpu_has(X86_FEATURE_ARAT) ? "all C-states" : "C1");
Richard Cochran2259a812016-04-06 17:00:54 -04001663
Len Brown26717172010-03-08 14:07:30 -05001664 return 0;
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001665
1666hp_setup_fail:
1667 intel_idle_cpuidle_devices_uninit();
1668 cpuidle_unregister_driver(&intel_idle_driver);
1669init_driver_fail:
1670 free_percpu(intel_idle_cpuidle_devices);
1671 return retval;
1672
Len Brown26717172010-03-08 14:07:30 -05001673}
Paul Gortmaker02c4fae2016-06-17 01:28:33 -04001674device_initcall(intel_idle_init);
Len Brown26717172010-03-08 14:07:30 -05001675
Paul Gortmaker02c4fae2016-06-17 01:28:33 -04001676/*
1677 * We are not really modular, but we used to support that. Meaning we also
1678 * support "intel_idle.max_cstate=..." at boot and also a read-only export of
1679 * it at /sys/module/intel_idle/parameters/max_cstate -- so using module_param
1680 * is the easiest way (currently) to continue doing that.
1681 */
Len Brown26717172010-03-08 14:07:30 -05001682module_param(max_cstate, int, 0444);
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001683/*
1684 * The positions of the bits that are set in this number are the indices of the
1685 * idle states to be disabled by default (as reflected by the names of the
1686 * corresponding idle state directories in sysfs, "state0", "state1" ...
1687 * "state<i>" ..., where <i> is the index of the given state).
1688 */
1689module_param_named(states_off, disabled_states_mask, uint, 0444);
1690MODULE_PARM_DESC(states_off, "Mask of disabled idle states");