blob: f4495841bf68052ead29c40ac0b83092655b1428 [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
Rafael J. Wysocki40ab82e2020-02-06 18:40:54 +010069static bool lapic_timer_always_reliable;
Len Brown26717172010-03-08 14:07:30 -050070
Andi Kleenb66b8b92012-01-26 00:09:07 +010071struct idle_cpu {
72 struct cpuidle_state *state_table;
73
74 /*
75 * Hardware C-state auto-demotion may not always be optimal.
76 * Indicate which enable bits to clear here.
77 */
78 unsigned long auto_demotion_disable_flags;
Len Brown8c058d532014-07-31 15:21:24 -040079 bool byt_auto_demotion_disable_flag;
Len Brown32e95182013-02-02 01:31:56 -050080 bool disable_promotion_to_c1e;
Rafael J. Wysockibff8e602019-12-13 09:56:21 +010081 bool use_acpi;
Andi Kleenb66b8b92012-01-26 00:09:07 +010082};
83
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +010084static const struct idle_cpu *icpu __initdata;
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +010085static struct cpuidle_state *cpuidle_state_table __initdata;
Len Brown26717172010-03-08 14:07:30 -050086
Rafael J. Wysocki6eb04432020-02-06 18:45:18 +010087static unsigned int mwait_substates __initdata;
88
Len Brown26717172010-03-08 14:07:30 -050089/*
Rafael J. Wysockibff8e602019-12-13 09:56:21 +010090 * Enable this state by default even if the ACPI _CST does not list it.
91 */
92#define CPUIDLE_FLAG_ALWAYS_ENABLE BIT(15)
93
94/*
Len Brown956d0332011-01-12 02:51:20 -050095 * Set this flag for states where the HW flushes the TLB for us
96 * and so we don't need cross-calls to keep it consistent.
97 * If this flag is set, SW flushes the TLB, so even if the
98 * HW doesn't do the flushing, this flag is safe to use.
99 */
Rafael J. Wysockia472e4b2020-02-06 18:45:39 +0100100#define CPUIDLE_FLAG_TLB_FLUSHED BIT(16)
Len Brown956d0332011-01-12 02:51:20 -0500101
102/*
Len Brownb1beab42013-01-31 19:55:37 -0500103 * MWAIT takes an 8-bit "hint" in EAX "suggesting"
104 * the C-state (top nibble) and sub-state (bottom nibble)
105 * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.
106 *
107 * We store the hint at the top of our "flags" for each state.
108 */
109#define flg2MWAIT(flags) (((flags) >> 24) & 0xFF)
110#define MWAIT2flg(eax) ((eax & 0xFF) << 24)
111
Rafael J. Wysocki30a996f2020-02-06 18:41:15 +0100112/**
113 * intel_idle - Ask the processor to enter the given idle state.
114 * @dev: cpuidle device of the target CPU.
115 * @drv: cpuidle driver (assumed to point to intel_idle_driver).
116 * @index: Target idle state index.
117 *
118 * Use the MWAIT instruction to notify the processor that the CPU represented by
119 * @dev is idle and it can try to enter the idle state corresponding to @index.
120 *
121 * If the local APIC timer is not known to be reliable in the target idle state,
122 * enable one-shot tick broadcasting for the target CPU before executing MWAIT.
123 *
124 * Optionally call leave_mm() for the target CPU upfront to avoid wakeups due to
125 * flushing user TLBs.
126 *
127 * Must be called under local_irq_disable().
128 */
129static __cpuidle int intel_idle(struct cpuidle_device *dev,
130 struct cpuidle_driver *drv, int index)
131{
132 struct cpuidle_state *state = &drv->states[index];
133 unsigned long eax = flg2MWAIT(state->flags);
134 unsigned long ecx = 1; /* break on interrupt flag */
135 bool uninitialized_var(tick);
136 int cpu = smp_processor_id();
137
138 /*
139 * leave_mm() to avoid costly and often unnecessary wakeups
140 * for flushing the user TLB's associated with the active mm.
141 */
142 if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
143 leave_mm(cpu);
144
145 if (!static_cpu_has(X86_FEATURE_ARAT) && !lapic_timer_always_reliable) {
146 /*
147 * Switch over to one-shot tick broadcast if the target C-state
148 * is deeper than C1.
149 */
150 if ((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) {
151 tick = true;
152 tick_broadcast_enter();
153 } else {
154 tick = false;
155 }
156 }
157
158 mwait_idle_with_hints(eax, ecx);
159
160 if (!static_cpu_has(X86_FEATURE_ARAT) && tick)
161 tick_broadcast_exit();
162
163 return index;
164}
165
166/**
167 * intel_idle_s2idle - Ask the processor to enter the given idle state.
168 * @dev: cpuidle device of the target CPU.
169 * @drv: cpuidle driver (assumed to point to intel_idle_driver).
170 * @index: Target idle state index.
171 *
172 * Use the MWAIT instruction to notify the processor that the CPU represented by
173 * @dev is idle and it can try to enter the idle state corresponding to @index.
174 *
175 * Invoked as a suspend-to-idle callback routine with frozen user space, frozen
176 * scheduler tick and suspended scheduler clock on the target CPU.
177 */
178static __cpuidle void intel_idle_s2idle(struct cpuidle_device *dev,
179 struct cpuidle_driver *drv, int index)
180{
181 unsigned long eax = flg2MWAIT(drv->states[index].flags);
182 unsigned long ecx = 1; /* break on interrupt flag */
183
184 mwait_idle_with_hints(eax, ecx);
185}
186
Len Brownb1beab42013-01-31 19:55:37 -0500187/*
Len Brown26717172010-03-08 14:07:30 -0500188 * States are indexed by the cstate number,
189 * which is also the index into the MWAIT hint array.
190 * Thus C0 is a dummy.
191 */
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100192static struct cpuidle_state nehalem_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500193 {
Len Brownde09cdd2017-02-28 16:32:44 -0500194 .name = "C1",
Len Brown26717172010-03-08 14:07:30 -0500195 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100196 .flags = MWAIT2flg(0x00),
Len Brown26717172010-03-08 14:07:30 -0500197 .exit_latency = 3,
Len Brown26717172010-03-08 14:07:30 -0500198 .target_residency = 6,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100199 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200200 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500201 {
Len Brownde09cdd2017-02-28 16:32:44 -0500202 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500203 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100204 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500205 .exit_latency = 10,
206 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100207 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200208 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500209 {
Len Brownde09cdd2017-02-28 16:32:44 -0500210 .name = "C3",
Len Brown26717172010-03-08 14:07:30 -0500211 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100212 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500213 .exit_latency = 20,
Len Brown26717172010-03-08 14:07:30 -0500214 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100215 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200216 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500217 {
Len Brownde09cdd2017-02-28 16:32:44 -0500218 .name = "C6",
Len Brown26717172010-03-08 14:07:30 -0500219 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100220 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500221 .exit_latency = 200,
Len Brown26717172010-03-08 14:07:30 -0500222 .target_residency = 800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100223 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200224 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500225 {
226 .enter = NULL }
Len Brown26717172010-03-08 14:07:30 -0500227};
228
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100229static struct cpuidle_state snb_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500230 {
Len Brownde09cdd2017-02-28 16:32:44 -0500231 .name = "C1",
Len Brownd13780d2010-07-07 00:12:03 -0400232 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100233 .flags = MWAIT2flg(0x00),
Len Brown32e95182013-02-02 01:31:56 -0500234 .exit_latency = 2,
235 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100236 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200237 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500238 {
Len Brownde09cdd2017-02-28 16:32:44 -0500239 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500240 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100241 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500242 .exit_latency = 10,
243 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100244 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200245 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500246 {
Len Brownde09cdd2017-02-28 16:32:44 -0500247 .name = "C3",
Len Brownd13780d2010-07-07 00:12:03 -0400248 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100249 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400250 .exit_latency = 80,
Len Brownddbd5502010-12-13 18:28:22 -0500251 .target_residency = 211,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100252 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200253 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500254 {
Len Brownde09cdd2017-02-28 16:32:44 -0500255 .name = "C6",
Len Brownd13780d2010-07-07 00:12:03 -0400256 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100257 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400258 .exit_latency = 104,
Len Brownddbd5502010-12-13 18:28:22 -0500259 .target_residency = 345,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100260 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200261 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500262 {
Len Brownde09cdd2017-02-28 16:32:44 -0500263 .name = "C7",
Len Brownd13780d2010-07-07 00:12:03 -0400264 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100265 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd13780d2010-07-07 00:12:03 -0400266 .exit_latency = 109,
Len Brownddbd5502010-12-13 18:28:22 -0500267 .target_residency = 345,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100268 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200269 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500270 {
271 .enter = NULL }
Len Brownd13780d2010-07-07 00:12:03 -0400272};
273
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100274static struct cpuidle_state byt_cstates[] __initdata = {
Len Brown718987d2014-02-14 02:30:00 -0500275 {
Len Brownde09cdd2017-02-28 16:32:44 -0500276 .name = "C1",
Len Brown718987d2014-02-14 02:30:00 -0500277 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100278 .flags = MWAIT2flg(0x00),
Len Brown718987d2014-02-14 02:30:00 -0500279 .exit_latency = 1,
280 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100281 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200282 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500283 {
Len Brownde09cdd2017-02-28 16:32:44 -0500284 .name = "C6N",
Len Brown718987d2014-02-14 02:30:00 -0500285 .desc = "MWAIT 0x58",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100286 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd7ef7672015-03-24 23:23:20 -0400287 .exit_latency = 300,
Len Brown718987d2014-02-14 02:30:00 -0500288 .target_residency = 275,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100289 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200290 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500291 {
Len Brownde09cdd2017-02-28 16:32:44 -0500292 .name = "C6S",
Len Brown718987d2014-02-14 02:30:00 -0500293 .desc = "MWAIT 0x52",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100294 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownd7ef7672015-03-24 23:23:20 -0400295 .exit_latency = 500,
Len Brown718987d2014-02-14 02:30:00 -0500296 .target_residency = 560,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100297 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200298 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500299 {
Len Brownde09cdd2017-02-28 16:32:44 -0500300 .name = "C7",
Len Brown718987d2014-02-14 02:30:00 -0500301 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100302 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown718987d2014-02-14 02:30:00 -0500303 .exit_latency = 1200,
Len Brownd7ef7672015-03-24 23:23:20 -0400304 .target_residency = 4000,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100305 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200306 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500307 {
Len Brownde09cdd2017-02-28 16:32:44 -0500308 .name = "C7S",
Len Brown718987d2014-02-14 02:30:00 -0500309 .desc = "MWAIT 0x64",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100310 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown718987d2014-02-14 02:30:00 -0500311 .exit_latency = 10000,
312 .target_residency = 20000,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100313 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200314 .enter_s2idle = intel_idle_s2idle, },
Len Brown718987d2014-02-14 02:30:00 -0500315 {
316 .enter = NULL }
317};
318
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100319static struct cpuidle_state cht_cstates[] __initdata = {
Len Browncab07a52015-03-27 20:54:01 -0400320 {
Len Brownde09cdd2017-02-28 16:32:44 -0500321 .name = "C1",
Len Browncab07a52015-03-27 20:54:01 -0400322 .desc = "MWAIT 0x00",
323 .flags = MWAIT2flg(0x00),
324 .exit_latency = 1,
325 .target_residency = 1,
326 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200327 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400328 {
Len Brownde09cdd2017-02-28 16:32:44 -0500329 .name = "C6N",
Len Browncab07a52015-03-27 20:54:01 -0400330 .desc = "MWAIT 0x58",
331 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
332 .exit_latency = 80,
333 .target_residency = 275,
334 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200335 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400336 {
Len Brownde09cdd2017-02-28 16:32:44 -0500337 .name = "C6S",
Len Browncab07a52015-03-27 20:54:01 -0400338 .desc = "MWAIT 0x52",
339 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
340 .exit_latency = 200,
341 .target_residency = 560,
342 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200343 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400344 {
Len Brownde09cdd2017-02-28 16:32:44 -0500345 .name = "C7",
Len Browncab07a52015-03-27 20:54:01 -0400346 .desc = "MWAIT 0x60",
347 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
348 .exit_latency = 1200,
349 .target_residency = 4000,
350 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200351 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400352 {
Len Brownde09cdd2017-02-28 16:32:44 -0500353 .name = "C7S",
Len Browncab07a52015-03-27 20:54:01 -0400354 .desc = "MWAIT 0x64",
355 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
356 .exit_latency = 10000,
357 .target_residency = 20000,
358 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200359 .enter_s2idle = intel_idle_s2idle, },
Len Browncab07a52015-03-27 20:54:01 -0400360 {
361 .enter = NULL }
362};
363
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100364static struct cpuidle_state ivb_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500365 {
Len Brownde09cdd2017-02-28 16:32:44 -0500366 .name = "C1",
Len Brown6edab082012-06-01 19:45:32 -0400367 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100368 .flags = MWAIT2flg(0x00),
Len Brown6edab082012-06-01 19:45:32 -0400369 .exit_latency = 1,
370 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100371 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200372 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500373 {
Len Brownde09cdd2017-02-28 16:32:44 -0500374 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500375 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100376 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500377 .exit_latency = 10,
378 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100379 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200380 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500381 {
Len Brownde09cdd2017-02-28 16:32:44 -0500382 .name = "C3",
Len Brown6edab082012-06-01 19:45:32 -0400383 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100384 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400385 .exit_latency = 59,
386 .target_residency = 156,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100387 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200388 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500389 {
Len Brownde09cdd2017-02-28 16:32:44 -0500390 .name = "C6",
Len Brown6edab082012-06-01 19:45:32 -0400391 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100392 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400393 .exit_latency = 80,
394 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100395 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200396 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500397 {
Len Brownde09cdd2017-02-28 16:32:44 -0500398 .name = "C7",
Len Brown6edab082012-06-01 19:45:32 -0400399 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100400 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown6edab082012-06-01 19:45:32 -0400401 .exit_latency = 87,
402 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100403 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200404 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500405 {
406 .enter = NULL }
Len Brown6edab082012-06-01 19:45:32 -0400407};
408
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100409static struct cpuidle_state ivt_cstates[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400410 {
Len Brownde09cdd2017-02-28 16:32:44 -0500411 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400412 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100413 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400414 .exit_latency = 1,
415 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100416 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200417 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400418 {
Len Brownde09cdd2017-02-28 16:32:44 -0500419 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400420 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100421 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400422 .exit_latency = 10,
423 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100424 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200425 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400426 {
Len Brownde09cdd2017-02-28 16:32:44 -0500427 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400428 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100429 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400430 .exit_latency = 59,
431 .target_residency = 156,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100432 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200433 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400434 {
Len Brownde09cdd2017-02-28 16:32:44 -0500435 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400436 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100437 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400438 .exit_latency = 82,
439 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100440 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200441 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400442 {
443 .enter = NULL }
444};
445
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100446static struct cpuidle_state ivt_cstates_4s[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400447 {
Len Brownde09cdd2017-02-28 16:32:44 -0500448 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400449 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100450 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400451 .exit_latency = 1,
452 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100453 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200454 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400455 {
Len Brownde09cdd2017-02-28 16:32:44 -0500456 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400457 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100458 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400459 .exit_latency = 10,
460 .target_residency = 250,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100461 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200462 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400463 {
Len Brownde09cdd2017-02-28 16:32:44 -0500464 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400465 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100466 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400467 .exit_latency = 59,
468 .target_residency = 300,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100469 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200470 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400471 {
Len Brownde09cdd2017-02-28 16:32:44 -0500472 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400473 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100474 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400475 .exit_latency = 84,
476 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100477 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200478 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400479 {
480 .enter = NULL }
481};
482
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100483static struct cpuidle_state ivt_cstates_8s[] __initdata = {
Len Brown0138d8f2014-04-04 01:21:07 -0400484 {
Len Brownde09cdd2017-02-28 16:32:44 -0500485 .name = "C1",
Len Brown0138d8f2014-04-04 01:21:07 -0400486 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100487 .flags = MWAIT2flg(0x00),
Len Brown0138d8f2014-04-04 01:21:07 -0400488 .exit_latency = 1,
489 .target_residency = 1,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100490 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200491 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400492 {
Len Brownde09cdd2017-02-28 16:32:44 -0500493 .name = "C1E",
Len Brown0138d8f2014-04-04 01:21:07 -0400494 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100495 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown0138d8f2014-04-04 01:21:07 -0400496 .exit_latency = 10,
497 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100498 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200499 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400500 {
Len Brownde09cdd2017-02-28 16:32:44 -0500501 .name = "C3",
Len Brown0138d8f2014-04-04 01:21:07 -0400502 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100503 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400504 .exit_latency = 59,
505 .target_residency = 600,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100506 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200507 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400508 {
Len Brownde09cdd2017-02-28 16:32:44 -0500509 .name = "C6",
Len Brown0138d8f2014-04-04 01:21:07 -0400510 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100511 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown0138d8f2014-04-04 01:21:07 -0400512 .exit_latency = 88,
513 .target_residency = 700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100514 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200515 .enter_s2idle = intel_idle_s2idle, },
Len Brown0138d8f2014-04-04 01:21:07 -0400516 {
517 .enter = NULL }
518};
519
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100520static struct cpuidle_state hsw_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500521 {
Len Brownde09cdd2017-02-28 16:32:44 -0500522 .name = "C1",
Len Brown85a4d2d2013-01-31 14:40:49 -0500523 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100524 .flags = MWAIT2flg(0x00),
Len Brown85a4d2d2013-01-31 14:40:49 -0500525 .exit_latency = 2,
526 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100527 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200528 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500529 {
Len Brownde09cdd2017-02-28 16:32:44 -0500530 .name = "C1E",
Len Brown32e95182013-02-02 01:31:56 -0500531 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100532 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown32e95182013-02-02 01:31:56 -0500533 .exit_latency = 10,
534 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100535 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200536 .enter_s2idle = intel_idle_s2idle, },
Len Brown32e95182013-02-02 01:31:56 -0500537 {
Len Brownde09cdd2017-02-28 16:32:44 -0500538 .name = "C3",
Len Brown85a4d2d2013-01-31 14:40:49 -0500539 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100540 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500541 .exit_latency = 33,
542 .target_residency = 100,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100543 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200544 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500545 {
Len Brownde09cdd2017-02-28 16:32:44 -0500546 .name = "C6",
Len Brown85a4d2d2013-01-31 14:40:49 -0500547 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100548 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500549 .exit_latency = 133,
550 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100551 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200552 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500553 {
Len Brownde09cdd2017-02-28 16:32:44 -0500554 .name = "C7s",
Len Brown85a4d2d2013-01-31 14:40:49 -0500555 .desc = "MWAIT 0x32",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100556 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown85a4d2d2013-01-31 14:40:49 -0500557 .exit_latency = 166,
558 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100559 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200560 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500561 {
Len Brownde09cdd2017-02-28 16:32:44 -0500562 .name = "C8",
Len Brown86239ce2013-02-27 13:18:50 -0500563 .desc = "MWAIT 0x40",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100564 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500565 .exit_latency = 300,
566 .target_residency = 900,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100567 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200568 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500569 {
Len Brownde09cdd2017-02-28 16:32:44 -0500570 .name = "C9",
Len Brown86239ce2013-02-27 13:18:50 -0500571 .desc = "MWAIT 0x50",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100572 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500573 .exit_latency = 600,
574 .target_residency = 1800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100575 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200576 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500577 {
Len Brownde09cdd2017-02-28 16:32:44 -0500578 .name = "C10",
Len Brown86239ce2013-02-27 13:18:50 -0500579 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100580 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown86239ce2013-02-27 13:18:50 -0500581 .exit_latency = 2600,
582 .target_residency = 7700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100583 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200584 .enter_s2idle = intel_idle_s2idle, },
Len Brown86239ce2013-02-27 13:18:50 -0500585 {
Len Browne022e7e2013-02-01 23:37:30 -0500586 .enter = NULL }
Len Brown85a4d2d2013-01-31 14:40:49 -0500587};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100588static struct cpuidle_state bdw_cstates[] __initdata = {
Len Browna138b562014-02-04 23:56:40 -0500589 {
Len Brownde09cdd2017-02-28 16:32:44 -0500590 .name = "C1",
Len Browna138b562014-02-04 23:56:40 -0500591 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100592 .flags = MWAIT2flg(0x00),
Len Browna138b562014-02-04 23:56:40 -0500593 .exit_latency = 2,
594 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100595 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200596 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500597 {
Len Brownde09cdd2017-02-28 16:32:44 -0500598 .name = "C1E",
Len Browna138b562014-02-04 23:56:40 -0500599 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100600 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Browna138b562014-02-04 23:56:40 -0500601 .exit_latency = 10,
602 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100603 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200604 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500605 {
Len Brownde09cdd2017-02-28 16:32:44 -0500606 .name = "C3",
Len Browna138b562014-02-04 23:56:40 -0500607 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100608 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500609 .exit_latency = 40,
610 .target_residency = 100,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100611 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200612 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500613 {
Len Brownde09cdd2017-02-28 16:32:44 -0500614 .name = "C6",
Len Browna138b562014-02-04 23:56:40 -0500615 .desc = "MWAIT 0x20",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100616 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500617 .exit_latency = 133,
618 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100619 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200620 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500621 {
Len Brownde09cdd2017-02-28 16:32:44 -0500622 .name = "C7s",
Len Browna138b562014-02-04 23:56:40 -0500623 .desc = "MWAIT 0x32",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100624 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500625 .exit_latency = 166,
626 .target_residency = 500,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100627 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200628 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500629 {
Len Brownde09cdd2017-02-28 16:32:44 -0500630 .name = "C8",
Len Browna138b562014-02-04 23:56:40 -0500631 .desc = "MWAIT 0x40",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100632 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500633 .exit_latency = 300,
634 .target_residency = 900,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100635 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200636 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500637 {
Len Brownde09cdd2017-02-28 16:32:44 -0500638 .name = "C9",
Len Browna138b562014-02-04 23:56:40 -0500639 .desc = "MWAIT 0x50",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100640 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500641 .exit_latency = 600,
642 .target_residency = 1800,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100643 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200644 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500645 {
Len Brownde09cdd2017-02-28 16:32:44 -0500646 .name = "C10",
Len Browna138b562014-02-04 23:56:40 -0500647 .desc = "MWAIT 0x60",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100648 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Browna138b562014-02-04 23:56:40 -0500649 .exit_latency = 2600,
650 .target_residency = 7700,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100651 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200652 .enter_s2idle = intel_idle_s2idle, },
Len Browna138b562014-02-04 23:56:40 -0500653 {
654 .enter = NULL }
655};
Len Brown85a4d2d2013-01-31 14:40:49 -0500656
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100657static struct cpuidle_state skl_cstates[] __initdata = {
Len Brown493f1332015-03-25 23:20:37 -0400658 {
Len Brownde09cdd2017-02-28 16:32:44 -0500659 .name = "C1",
Len Brown493f1332015-03-25 23:20:37 -0400660 .desc = "MWAIT 0x00",
661 .flags = MWAIT2flg(0x00),
662 .exit_latency = 2,
663 .target_residency = 2,
664 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200665 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400666 {
Len Brownde09cdd2017-02-28 16:32:44 -0500667 .name = "C1E",
Len Brown493f1332015-03-25 23:20:37 -0400668 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100669 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown493f1332015-03-25 23:20:37 -0400670 .exit_latency = 10,
671 .target_residency = 20,
672 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200673 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400674 {
Len Brownde09cdd2017-02-28 16:32:44 -0500675 .name = "C3",
Len Brown493f1332015-03-25 23:20:37 -0400676 .desc = "MWAIT 0x10",
677 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
678 .exit_latency = 70,
679 .target_residency = 100,
680 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200681 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400682 {
Len Brownde09cdd2017-02-28 16:32:44 -0500683 .name = "C6",
Len Brown493f1332015-03-25 23:20:37 -0400684 .desc = "MWAIT 0x20",
685 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown135919a2015-09-09 13:35:05 -0400686 .exit_latency = 85,
Len Brown493f1332015-03-25 23:20:37 -0400687 .target_residency = 200,
688 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200689 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400690 {
Len Brownde09cdd2017-02-28 16:32:44 -0500691 .name = "C7s",
Len Brown493f1332015-03-25 23:20:37 -0400692 .desc = "MWAIT 0x33",
693 .flags = MWAIT2flg(0x33) | CPUIDLE_FLAG_TLB_FLUSHED,
694 .exit_latency = 124,
695 .target_residency = 800,
696 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200697 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400698 {
Len Brownde09cdd2017-02-28 16:32:44 -0500699 .name = "C8",
Len Brown493f1332015-03-25 23:20:37 -0400700 .desc = "MWAIT 0x40",
701 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown135919a2015-09-09 13:35:05 -0400702 .exit_latency = 200,
Len Brown493f1332015-03-25 23:20:37 -0400703 .target_residency = 800,
704 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200705 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400706 {
Len Brownde09cdd2017-02-28 16:32:44 -0500707 .name = "C9",
Len Brown135919a2015-09-09 13:35:05 -0400708 .desc = "MWAIT 0x50",
709 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
710 .exit_latency = 480,
711 .target_residency = 5000,
712 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200713 .enter_s2idle = intel_idle_s2idle, },
Len Brown135919a2015-09-09 13:35:05 -0400714 {
Len Brownde09cdd2017-02-28 16:32:44 -0500715 .name = "C10",
Len Brown493f1332015-03-25 23:20:37 -0400716 .desc = "MWAIT 0x60",
717 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
718 .exit_latency = 890,
719 .target_residency = 5000,
720 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200721 .enter_s2idle = intel_idle_s2idle, },
Len Brown493f1332015-03-25 23:20:37 -0400722 {
723 .enter = NULL }
724};
725
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100726static struct cpuidle_state skx_cstates[] __initdata = {
Len Brownf9e71652016-04-06 17:00:58 -0400727 {
Len Brownde09cdd2017-02-28 16:32:44 -0500728 .name = "C1",
Len Brownf9e71652016-04-06 17:00:58 -0400729 .desc = "MWAIT 0x00",
730 .flags = MWAIT2flg(0x00),
731 .exit_latency = 2,
732 .target_residency = 2,
733 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200734 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400735 {
Len Brownde09cdd2017-02-28 16:32:44 -0500736 .name = "C1E",
Len Brownf9e71652016-04-06 17:00:58 -0400737 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100738 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brownf9e71652016-04-06 17:00:58 -0400739 .exit_latency = 10,
740 .target_residency = 20,
741 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200742 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400743 {
Len Brownde09cdd2017-02-28 16:32:44 -0500744 .name = "C6",
Len Brownf9e71652016-04-06 17:00:58 -0400745 .desc = "MWAIT 0x20",
746 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
747 .exit_latency = 133,
748 .target_residency = 600,
749 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200750 .enter_s2idle = intel_idle_s2idle, },
Len Brownf9e71652016-04-06 17:00:58 -0400751 {
752 .enter = NULL }
753};
754
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100755static struct cpuidle_state atom_cstates[] __initdata = {
Len Browne022e7e2013-02-01 23:37:30 -0500756 {
Len Brownde09cdd2017-02-28 16:32:44 -0500757 .name = "C1E",
Len Brown26717172010-03-08 14:07:30 -0500758 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100759 .flags = MWAIT2flg(0x00),
Len Brown32e95182013-02-02 01:31:56 -0500760 .exit_latency = 10,
761 .target_residency = 20,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100762 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200763 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500764 {
Len Brownde09cdd2017-02-28 16:32:44 -0500765 .name = "C2",
Len Brown26717172010-03-08 14:07:30 -0500766 .desc = "MWAIT 0x10",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100767 .flags = MWAIT2flg(0x10),
Len Brown26717172010-03-08 14:07:30 -0500768 .exit_latency = 20,
Len Brown26717172010-03-08 14:07:30 -0500769 .target_residency = 80,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100770 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200771 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500772 {
Len Brownde09cdd2017-02-28 16:32:44 -0500773 .name = "C4",
Len Brown26717172010-03-08 14:07:30 -0500774 .desc = "MWAIT 0x30",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100775 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown26717172010-03-08 14:07:30 -0500776 .exit_latency = 100,
Len Brown26717172010-03-08 14:07:30 -0500777 .target_residency = 400,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100778 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200779 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500780 {
Len Brownde09cdd2017-02-28 16:32:44 -0500781 .name = "C6",
Len Brown7fcca7d2010-10-05 13:43:14 -0400782 .desc = "MWAIT 0x52",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100783 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brown7fcca7d2010-10-05 13:43:14 -0400784 .exit_latency = 140,
Len Brown7fcca7d2010-10-05 13:43:14 -0400785 .target_residency = 560,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100786 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200787 .enter_s2idle = intel_idle_s2idle, },
Len Browne022e7e2013-02-01 23:37:30 -0500788 {
789 .enter = NULL }
Len Brown26717172010-03-08 14:07:30 -0500790};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100791static struct cpuidle_state tangier_cstates[] __initdata = {
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300792 {
Len Brownde09cdd2017-02-28 16:32:44 -0500793 .name = "C1",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300794 .desc = "MWAIT 0x00",
795 .flags = MWAIT2flg(0x00),
796 .exit_latency = 1,
797 .target_residency = 4,
798 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200799 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300800 {
Len Brownde09cdd2017-02-28 16:32:44 -0500801 .name = "C4",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300802 .desc = "MWAIT 0x30",
803 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
804 .exit_latency = 100,
805 .target_residency = 400,
806 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200807 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300808 {
Len Brownde09cdd2017-02-28 16:32:44 -0500809 .name = "C6",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300810 .desc = "MWAIT 0x52",
811 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
812 .exit_latency = 140,
813 .target_residency = 560,
814 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200815 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300816 {
Len Brownde09cdd2017-02-28 16:32:44 -0500817 .name = "C7",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300818 .desc = "MWAIT 0x60",
819 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
820 .exit_latency = 1200,
821 .target_residency = 4000,
822 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200823 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300824 {
Len Brownde09cdd2017-02-28 16:32:44 -0500825 .name = "C9",
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300826 .desc = "MWAIT 0x64",
827 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
828 .exit_latency = 10000,
829 .target_residency = 20000,
830 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200831 .enter_s2idle = intel_idle_s2idle, },
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300832 {
833 .enter = NULL }
834};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100835static struct cpuidle_state avn_cstates[] __initdata = {
Len Brownfab04b22013-11-09 00:30:17 -0500836 {
Len Brownde09cdd2017-02-28 16:32:44 -0500837 .name = "C1",
Len Brownfab04b22013-11-09 00:30:17 -0500838 .desc = "MWAIT 0x00",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100839 .flags = MWAIT2flg(0x00),
Len Brownfab04b22013-11-09 00:30:17 -0500840 .exit_latency = 2,
841 .target_residency = 2,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100842 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200843 .enter_s2idle = intel_idle_s2idle, },
Len Brownfab04b22013-11-09 00:30:17 -0500844 {
Len Brownde09cdd2017-02-28 16:32:44 -0500845 .name = "C6",
Len Brownfab04b22013-11-09 00:30:17 -0500846 .desc = "MWAIT 0x51",
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +0100847 .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TLB_FLUSHED,
Len Brownfab04b22013-11-09 00:30:17 -0500848 .exit_latency = 15,
849 .target_residency = 45,
Rafael J. Wysocki5fe2e522015-02-11 05:04:17 +0100850 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200851 .enter_s2idle = intel_idle_s2idle, },
Jiang Liu88390992014-01-09 15:30:27 +0800852 {
853 .enter = NULL }
Len Brownfab04b22013-11-09 00:30:17 -0500854};
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100855static struct cpuidle_state knl_cstates[] __initdata = {
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700856 {
Len Brownde09cdd2017-02-28 16:32:44 -0500857 .name = "C1",
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700858 .desc = "MWAIT 0x00",
859 .flags = MWAIT2flg(0x00),
860 .exit_latency = 1,
861 .target_residency = 2,
862 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200863 .enter_s2idle = intel_idle_s2idle },
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700864 {
Len Brownde09cdd2017-02-28 16:32:44 -0500865 .name = "C6",
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700866 .desc = "MWAIT 0x10",
867 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
868 .exit_latency = 120,
869 .target_residency = 500,
870 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200871 .enter_s2idle = intel_idle_s2idle },
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -0700872 {
873 .enter = NULL }
874};
Len Brown26717172010-03-08 14:07:30 -0500875
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100876static struct cpuidle_state bxt_cstates[] __initdata = {
Len Brown5dcef692016-04-06 17:00:47 -0400877 {
Len Brownde09cdd2017-02-28 16:32:44 -0500878 .name = "C1",
Len Brown5dcef692016-04-06 17:00:47 -0400879 .desc = "MWAIT 0x00",
880 .flags = MWAIT2flg(0x00),
881 .exit_latency = 2,
882 .target_residency = 2,
883 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200884 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400885 {
Len Brownde09cdd2017-02-28 16:32:44 -0500886 .name = "C1E",
Len Brown5dcef692016-04-06 17:00:47 -0400887 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100888 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Len Brown5dcef692016-04-06 17:00:47 -0400889 .exit_latency = 10,
890 .target_residency = 20,
891 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200892 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400893 {
Len Brownde09cdd2017-02-28 16:32:44 -0500894 .name = "C6",
Len Brown5dcef692016-04-06 17:00:47 -0400895 .desc = "MWAIT 0x20",
896 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
897 .exit_latency = 133,
898 .target_residency = 133,
899 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200900 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400901 {
Len Brownde09cdd2017-02-28 16:32:44 -0500902 .name = "C7s",
Len Brown5dcef692016-04-06 17:00:47 -0400903 .desc = "MWAIT 0x31",
904 .flags = MWAIT2flg(0x31) | CPUIDLE_FLAG_TLB_FLUSHED,
905 .exit_latency = 155,
906 .target_residency = 155,
907 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200908 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400909 {
Len Brownde09cdd2017-02-28 16:32:44 -0500910 .name = "C8",
Len Brown5dcef692016-04-06 17:00:47 -0400911 .desc = "MWAIT 0x40",
912 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
913 .exit_latency = 1000,
914 .target_residency = 1000,
915 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200916 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400917 {
Len Brownde09cdd2017-02-28 16:32:44 -0500918 .name = "C9",
Len Brown5dcef692016-04-06 17:00:47 -0400919 .desc = "MWAIT 0x50",
920 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
921 .exit_latency = 2000,
922 .target_residency = 2000,
923 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200924 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400925 {
Len Brownde09cdd2017-02-28 16:32:44 -0500926 .name = "C10",
Len Brown5dcef692016-04-06 17:00:47 -0400927 .desc = "MWAIT 0x60",
928 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
929 .exit_latency = 10000,
930 .target_residency = 10000,
931 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200932 .enter_s2idle = intel_idle_s2idle, },
Len Brown5dcef692016-04-06 17:00:47 -0400933 {
934 .enter = NULL }
935};
936
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100937static struct cpuidle_state dnv_cstates[] __initdata = {
Jacob Pan0080d652016-06-17 01:28:34 -0400938 {
Len Brownde09cdd2017-02-28 16:32:44 -0500939 .name = "C1",
Jacob Pan0080d652016-06-17 01:28:34 -0400940 .desc = "MWAIT 0x00",
941 .flags = MWAIT2flg(0x00),
942 .exit_latency = 2,
943 .target_residency = 2,
944 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200945 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400946 {
Len Brownde09cdd2017-02-28 16:32:44 -0500947 .name = "C1E",
Jacob Pan0080d652016-06-17 01:28:34 -0400948 .desc = "MWAIT 0x01",
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100949 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
Jacob Pan0080d652016-06-17 01:28:34 -0400950 .exit_latency = 10,
951 .target_residency = 20,
952 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200953 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400954 {
Len Brownde09cdd2017-02-28 16:32:44 -0500955 .name = "C6",
Jacob Pan0080d652016-06-17 01:28:34 -0400956 .desc = "MWAIT 0x20",
957 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
958 .exit_latency = 50,
959 .target_residency = 500,
960 .enter = &intel_idle,
Rafael J. Wysocki28ba0862017-08-10 00:14:45 +0200961 .enter_s2idle = intel_idle_s2idle, },
Jacob Pan0080d652016-06-17 01:28:34 -0400962 {
963 .enter = NULL }
964};
965
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100966static const struct idle_cpu idle_cpu_nehalem __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100967 .state_table = nehalem_cstates,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100968 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
Len Brown32e95182013-02-02 01:31:56 -0500969 .disable_promotion_to_c1e = true,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100970};
971
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100972static const struct idle_cpu idle_cpu_nhx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100973 .state_table = nehalem_cstates,
974 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
975 .disable_promotion_to_c1e = true,
976 .use_acpi = true,
977};
978
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100979static const struct idle_cpu idle_cpu_atom __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100980 .state_table = atom_cstates,
981};
982
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100983static const struct idle_cpu idle_cpu_tangier __initconst = {
Andy Shevchenko5e7ec262016-10-25 17:11:39 +0300984 .state_table = tangier_cstates,
985};
986
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100987static const struct idle_cpu idle_cpu_lincroft __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100988 .state_table = atom_cstates,
989 .auto_demotion_disable_flags = ATM_LNC_C6_AUTO_DEMOTE,
990};
991
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100992static const struct idle_cpu idle_cpu_snb __initconst = {
Andi Kleenb66b8b92012-01-26 00:09:07 +0100993 .state_table = snb_cstates,
Len Brown32e95182013-02-02 01:31:56 -0500994 .disable_promotion_to_c1e = true,
Andi Kleenb66b8b92012-01-26 00:09:07 +0100995};
996
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +0100997static const struct idle_cpu idle_cpu_snx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +0100998 .state_table = snb_cstates,
999 .disable_promotion_to_c1e = true,
1000 .use_acpi = true,
1001};
1002
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001003static const struct idle_cpu idle_cpu_byt __initconst = {
Len Brown718987d2014-02-14 02:30:00 -05001004 .state_table = byt_cstates,
1005 .disable_promotion_to_c1e = true,
Len Brown8c058d532014-07-31 15:21:24 -04001006 .byt_auto_demotion_disable_flag = true,
Len Brown718987d2014-02-14 02:30:00 -05001007};
1008
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001009static const struct idle_cpu idle_cpu_cht __initconst = {
Len Browncab07a52015-03-27 20:54:01 -04001010 .state_table = cht_cstates,
1011 .disable_promotion_to_c1e = true,
1012 .byt_auto_demotion_disable_flag = true,
1013};
1014
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001015static const struct idle_cpu idle_cpu_ivb __initconst = {
Len Brown6edab082012-06-01 19:45:32 -04001016 .state_table = ivb_cstates,
Len Brown32e95182013-02-02 01:31:56 -05001017 .disable_promotion_to_c1e = true,
Len Brown6edab082012-06-01 19:45:32 -04001018};
1019
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001020static const struct idle_cpu idle_cpu_ivt __initconst = {
Len Brown0138d8f2014-04-04 01:21:07 -04001021 .state_table = ivt_cstates,
1022 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001023 .use_acpi = true,
Len Brown0138d8f2014-04-04 01:21:07 -04001024};
1025
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001026static const struct idle_cpu idle_cpu_hsw __initconst = {
Len Brown85a4d2d2013-01-31 14:40:49 -05001027 .state_table = hsw_cstates,
Len Brown32e95182013-02-02 01:31:56 -05001028 .disable_promotion_to_c1e = true,
Len Brown85a4d2d2013-01-31 14:40:49 -05001029};
1030
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001031static const struct idle_cpu idle_cpu_hsx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001032 .state_table = hsw_cstates,
1033 .disable_promotion_to_c1e = true,
1034 .use_acpi = true,
1035};
1036
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001037static const struct idle_cpu idle_cpu_bdw __initconst = {
Len Browna138b562014-02-04 23:56:40 -05001038 .state_table = bdw_cstates,
1039 .disable_promotion_to_c1e = true,
1040};
1041
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001042static const struct idle_cpu idle_cpu_bdx __initconst = {
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001043 .state_table = bdw_cstates,
1044 .disable_promotion_to_c1e = true,
1045 .use_acpi = true,
1046};
1047
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001048static const struct idle_cpu idle_cpu_skl __initconst = {
Len Brown493f1332015-03-25 23:20:37 -04001049 .state_table = skl_cstates,
1050 .disable_promotion_to_c1e = true,
1051};
1052
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001053static const struct idle_cpu idle_cpu_skx __initconst = {
Len Brownf9e71652016-04-06 17:00:58 -04001054 .state_table = skx_cstates,
1055 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001056 .use_acpi = true,
Len Brownf9e71652016-04-06 17:00:58 -04001057};
Len Brown493f1332015-03-25 23:20:37 -04001058
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001059static const struct idle_cpu idle_cpu_avn __initconst = {
Len Brownfab04b22013-11-09 00:30:17 -05001060 .state_table = avn_cstates,
1061 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001062 .use_acpi = true,
Len Brownfab04b22013-11-09 00:30:17 -05001063};
1064
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001065static const struct idle_cpu idle_cpu_knl __initconst = {
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -07001066 .state_table = knl_cstates,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001067 .use_acpi = true,
Dasaratharaman Chandramouli281baf72014-09-04 17:22:54 -07001068};
1069
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001070static const struct idle_cpu idle_cpu_bxt __initconst = {
Len Brown5dcef692016-04-06 17:00:47 -04001071 .state_table = bxt_cstates,
1072 .disable_promotion_to_c1e = true,
1073};
1074
Rafael J. Wysockiab1a85222020-02-06 18:45:06 +01001075static const struct idle_cpu idle_cpu_dnv __initconst = {
Jacob Pan0080d652016-06-17 01:28:34 -04001076 .state_table = dnv_cstates,
1077 .disable_promotion_to_c1e = true,
Rafael J. Wysockie6d4f082019-12-13 09:56:38 +01001078 .use_acpi = true,
Jacob Pan0080d652016-06-17 01:28:34 -04001079};
1080
Mathias Kraused5cdc3c2015-03-25 22:15:14 +01001081static const struct x86_cpu_id intel_idle_ids[] __initconst = {
Thomas Gleixner4a9f45a2020-03-20 14:14:00 +01001082 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EP, &idle_cpu_nhx),
1083 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM, &idle_cpu_nehalem),
1084 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_G, &idle_cpu_nehalem),
1085 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE, &idle_cpu_nehalem),
1086 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EP, &idle_cpu_nhx),
1087 X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EX, &idle_cpu_nhx),
1088 X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL, &idle_cpu_atom),
1089 X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL_MID, &idle_cpu_lincroft),
1090 X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EX, &idle_cpu_nhx),
1091 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &idle_cpu_snb),
1092 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &idle_cpu_snx),
1093 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL, &idle_cpu_atom),
1094 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, &idle_cpu_byt),
1095 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &idle_cpu_tangier),
1096 X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, &idle_cpu_cht),
1097 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, &idle_cpu_ivb),
1098 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, &idle_cpu_ivt),
1099 X86_MATCH_INTEL_FAM6_MODEL(HASWELL, &idle_cpu_hsw),
1100 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, &idle_cpu_hsx),
1101 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_L, &idle_cpu_hsw),
1102 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_G, &idle_cpu_hsw),
1103 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D, &idle_cpu_avn),
1104 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL, &idle_cpu_bdw),
1105 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_G, &idle_cpu_bdw),
1106 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, &idle_cpu_bdx),
1107 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, &idle_cpu_bdx),
1108 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, &idle_cpu_skl),
1109 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, &idle_cpu_skl),
1110 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, &idle_cpu_skl),
1111 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, &idle_cpu_skl),
1112 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &idle_cpu_skx),
1113 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &idle_cpu_knl),
1114 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &idle_cpu_knl),
1115 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, &idle_cpu_bxt),
1116 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_PLUS, &idle_cpu_bxt),
1117 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, &idle_cpu_dnv),
1118 X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &idle_cpu_dnv),
Andi Kleenb66b8b92012-01-26 00:09:07 +01001119 {}
1120};
Andi Kleenb66b8b92012-01-26 00:09:07 +01001121
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001122static const struct x86_cpu_id intel_mwait_ids[] __initconst = {
Thomas Gleixner4a9f45a2020-03-20 14:14:00 +01001123 X86_MATCH_VENDOR_FAM_FEATURE(INTEL, 6, X86_FEATURE_MWAIT, NULL),
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001124 {}
1125};
1126
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001127static bool __init intel_idle_max_cstate_reached(int cstate)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001128{
1129 if (cstate + 1 > max_cstate) {
1130 pr_info("max_cstate %d reached\n", max_cstate);
1131 return true;
1132 }
1133 return false;
1134}
1135
1136#ifdef CONFIG_ACPI_PROCESSOR_CSTATE
1137#include <acpi/processor.h>
1138
Rafael J. Wysocki4ec32d92019-12-13 09:56:29 +01001139static bool no_acpi __read_mostly;
1140module_param(no_acpi, bool, 0444);
1141MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list");
1142
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001143static bool force_use_acpi __read_mostly; /* No effect if no_acpi is set. */
1144module_param_named(use_acpi, force_use_acpi, bool, 0444);
1145MODULE_PARM_DESC(use_acpi, "Use ACPI _CST for building the idle states list");
1146
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001147static struct acpi_processor_power acpi_state_table __initdata;
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001148
1149/**
1150 * intel_idle_cst_usable - Check if the _CST information can be used.
1151 *
1152 * Check if all of the C-states listed by _CST in the max_cstate range are
1153 * ACPI_CSTATE_FFH, which means that they should be entered via MWAIT.
1154 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001155static bool __init intel_idle_cst_usable(void)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001156{
1157 int cstate, limit;
1158
1159 limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1),
1160 acpi_state_table.count);
1161
1162 for (cstate = 1; cstate < limit; cstate++) {
1163 struct acpi_processor_cx *cx = &acpi_state_table.states[cstate];
1164
1165 if (cx->entry_method != ACPI_CSTATE_FFH)
1166 return false;
1167 }
1168
1169 return true;
1170}
1171
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001172static bool __init intel_idle_acpi_cst_extract(void)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001173{
1174 unsigned int cpu;
1175
Rafael J. Wysocki4ec32d92019-12-13 09:56:29 +01001176 if (no_acpi) {
1177 pr_debug("Not allowed to use ACPI _CST\n");
1178 return false;
1179 }
1180
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001181 for_each_possible_cpu(cpu) {
1182 struct acpi_processor *pr = per_cpu(processors, cpu);
1183
1184 if (!pr)
1185 continue;
1186
1187 if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table))
1188 continue;
1189
1190 acpi_state_table.count++;
1191
1192 if (!intel_idle_cst_usable())
1193 continue;
1194
1195 if (!acpi_processor_claim_cst_control()) {
1196 acpi_state_table.count = 0;
1197 return false;
1198 }
1199
1200 return true;
1201 }
1202
1203 pr_debug("ACPI _CST not found or not usable\n");
1204 return false;
1205}
1206
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001207static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001208{
1209 int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
1210
1211 /*
1212 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
1213 * the interesting states are ACPI_CSTATE_FFH.
1214 */
1215 for (cstate = 1; cstate < limit; cstate++) {
1216 struct acpi_processor_cx *cx;
1217 struct cpuidle_state *state;
1218
1219 if (intel_idle_max_cstate_reached(cstate))
1220 break;
1221
1222 cx = &acpi_state_table.states[cstate];
1223
1224 state = &drv->states[drv->state_count++];
1225
1226 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d_ACPI", cstate);
1227 strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1228 state->exit_latency = cx->latency;
1229 /*
1230 * For C1-type C-states use the same number for both the exit
1231 * latency and target residency, because that is the case for
1232 * C1 in the majority of the static C-states tables above.
1233 * For the other types of C-states, however, set the target
1234 * residency to 3 times the exit latency which should lead to
1235 * a reasonable balance between energy-efficiency and
1236 * performance in the majority of interesting cases.
1237 */
1238 state->target_residency = cx->latency;
1239 if (cx->type > ACPI_STATE_C1)
1240 state->target_residency *= 3;
1241
1242 state->flags = MWAIT2flg(cx->address);
1243 if (cx->type > ACPI_STATE_C2)
1244 state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
1245
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001246 if (disabled_states_mask & BIT(cstate))
1247 state->flags |= CPUIDLE_FLAG_OFF;
1248
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001249 state->enter = intel_idle;
1250 state->enter_s2idle = intel_idle_s2idle;
1251 }
1252}
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001253
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001254static bool __init intel_idle_off_by_default(u32 mwait_hint)
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001255{
1256 int cstate, limit;
1257
1258 /*
1259 * If there are no _CST C-states, do not disable any C-states by
1260 * default.
1261 */
1262 if (!acpi_state_table.count)
1263 return false;
1264
1265 limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
1266 /*
1267 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
1268 * the interesting states are ACPI_CSTATE_FFH.
1269 */
1270 for (cstate = 1; cstate < limit; cstate++) {
1271 if (acpi_state_table.states[cstate].address == mwait_hint)
1272 return false;
1273 }
1274 return true;
1275}
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001276#else /* !CONFIG_ACPI_PROCESSOR_CSTATE */
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001277#define force_use_acpi (false)
1278
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001279static inline bool intel_idle_acpi_cst_extract(void) { return false; }
1280static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { }
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001281static inline bool intel_idle_off_by_default(u32 mwait_hint) { return false; }
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001282#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
1283
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001284/**
1285 * ivt_idle_state_table_update - Tune the idle states table for Ivy Town.
Len Brownd70e28f2016-03-13 00:33:48 -05001286 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001287 * Tune IVT multi-socket targets.
1288 * Assumption: num_sockets == (max_package_num + 1).
Len Brownd70e28f2016-03-13 00:33:48 -05001289 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001290static void __init ivt_idle_state_table_update(void)
Len Brownd70e28f2016-03-13 00:33:48 -05001291{
1292 /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
1293 int cpu, package_num, num_sockets = 1;
1294
1295 for_each_online_cpu(cpu) {
1296 package_num = topology_physical_package_id(cpu);
1297 if (package_num + 1 > num_sockets) {
1298 num_sockets = package_num + 1;
1299
1300 if (num_sockets > 4) {
1301 cpuidle_state_table = ivt_cstates_8s;
1302 return;
1303 }
1304 }
1305 }
1306
1307 if (num_sockets > 2)
1308 cpuidle_state_table = ivt_cstates_4s;
1309
1310 /* else, 1 and 2 socket systems use default ivt_cstates */
1311}
Len Brown5dcef692016-04-06 17:00:47 -04001312
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001313/**
1314 * irtl_2_usec - IRTL to microseconds conversion.
1315 * @irtl: IRTL MSR value.
1316 *
1317 * Translate the IRTL (Interrupt Response Time Limit) MSR value to microseconds.
Len Brown5dcef692016-04-06 17:00:47 -04001318 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001319static unsigned long long __init irtl_2_usec(unsigned long long irtl)
Len Brown5dcef692016-04-06 17:00:47 -04001320{
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001321 static const unsigned int irtl_ns_units[] __initconst = {
1322 1, 32, 1024, 32768, 1048576, 33554432, 0, 0
1323 };
Len Brown5dcef692016-04-06 17:00:47 -04001324 unsigned long long ns;
1325
Jan Beulich3451ab32016-06-27 00:35:12 -06001326 if (!irtl)
1327 return 0;
1328
Jan Beulichbef45092016-06-27 00:35:48 -06001329 ns = irtl_ns_units[(irtl >> 10) & 0x7];
Len Brown5dcef692016-04-06 17:00:47 -04001330
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001331 return div_u64((irtl & 0x3FF) * ns, NSEC_PER_USEC);
Len Brown5dcef692016-04-06 17:00:47 -04001332}
Rafael J. Wysocki86e94662020-01-17 11:46:24 +01001333
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001334/**
1335 * bxt_idle_state_table_update - Fix up the Broxton idle states table.
Len Brown5dcef692016-04-06 17:00:47 -04001336 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001337 * On BXT, trust the IRTL (Interrupt Response Time Limit) MSR to show the
1338 * definitive maximum latency and use the same value for target_residency.
Len Brown5dcef692016-04-06 17:00:47 -04001339 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001340static void __init bxt_idle_state_table_update(void)
Len Brown5dcef692016-04-06 17:00:47 -04001341{
1342 unsigned long long msr;
Jan Beulich3451ab32016-06-27 00:35:12 -06001343 unsigned int usec;
Len Brown5dcef692016-04-06 17:00:47 -04001344
1345 rdmsrl(MSR_PKGC6_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001346 usec = irtl_2_usec(msr);
1347 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001348 bxt_cstates[2].exit_latency = usec;
1349 bxt_cstates[2].target_residency = usec;
1350 }
1351
1352 rdmsrl(MSR_PKGC7_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001353 usec = irtl_2_usec(msr);
1354 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001355 bxt_cstates[3].exit_latency = usec;
1356 bxt_cstates[3].target_residency = usec;
1357 }
1358
1359 rdmsrl(MSR_PKGC8_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001360 usec = irtl_2_usec(msr);
1361 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001362 bxt_cstates[4].exit_latency = usec;
1363 bxt_cstates[4].target_residency = usec;
1364 }
1365
1366 rdmsrl(MSR_PKGC9_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001367 usec = irtl_2_usec(msr);
1368 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001369 bxt_cstates[5].exit_latency = usec;
1370 bxt_cstates[5].target_residency = usec;
1371 }
1372
1373 rdmsrl(MSR_PKGC10_IRTL, msr);
Jan Beulich3451ab32016-06-27 00:35:12 -06001374 usec = irtl_2_usec(msr);
1375 if (usec) {
Len Brown5dcef692016-04-06 17:00:47 -04001376 bxt_cstates[6].exit_latency = usec;
1377 bxt_cstates[6].target_residency = usec;
1378 }
1379
1380}
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001381
1382/**
1383 * sklh_idle_state_table_update - Fix up the Sky Lake idle states table.
Len Brownd70e28f2016-03-13 00:33:48 -05001384 *
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001385 * On SKL-H (model 0x5e) skip C8 and C9 if C10 is enabled and SGX disabled.
Len Brownd70e28f2016-03-13 00:33:48 -05001386 */
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001387static void __init sklh_idle_state_table_update(void)
Len Brownd70e28f2016-03-13 00:33:48 -05001388{
1389 unsigned long long msr;
1390 unsigned int eax, ebx, ecx, edx;
1391
1392
1393 /* if PC10 disabled via cmdline intel_idle.max_cstate=7 or shallower */
1394 if (max_cstate <= 7)
1395 return;
1396
1397 /* if PC10 not present in CPUID.MWAIT.EDX */
1398 if ((mwait_substates & (0xF << 28)) == 0)
1399 return;
1400
Len Brown6cfb2372017-01-07 23:23:25 -05001401 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr);
Len Brownd70e28f2016-03-13 00:33:48 -05001402
1403 /* PC10 is not enabled in PKG C-state limit */
1404 if ((msr & 0xF) != 8)
1405 return;
1406
1407 ecx = 0;
1408 cpuid(7, &eax, &ebx, &ecx, &edx);
1409
1410 /* if SGX is present */
1411 if (ebx & (1 << 2)) {
1412
Sean Christopherson32ad73d2019-12-20 20:44:55 -08001413 rdmsrl(MSR_IA32_FEAT_CTL, msr);
Len Brownd70e28f2016-03-13 00:33:48 -05001414
1415 /* if SGX is enabled */
1416 if (msr & (1 << 18))
1417 return;
1418 }
1419
Rafael J. Wysockiba1e78a2019-11-21 19:41:51 +01001420 skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
1421 skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
Len Brownd70e28f2016-03-13 00:33:48 -05001422}
Len Brownd70e28f2016-03-13 00:33:48 -05001423
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001424static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
1425{
1426 unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
1427 unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
1428 MWAIT_SUBSTATE_MASK;
1429
1430 /* Ignore the C-state if there are NO sub-states in CPUID for it. */
1431 if (num_substates == 0)
1432 return false;
1433
1434 if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
1435 mark_tsc_unstable("TSC halts in idle states deeper than C2");
1436
1437 return true;
1438}
1439
Rafael J. Wysocki095928a2020-01-10 11:51:22 +01001440static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
Len Brown0138d8f2014-04-04 01:21:07 -04001441{
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001442 int cstate;
Len Brown0138d8f2014-04-04 01:21:07 -04001443
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001444 switch (boot_cpu_data.x86_model) {
Dave Hansendb73c5a2016-06-02 17:19:32 -07001445 case INTEL_FAM6_IVYBRIDGE_X:
Len Brownd70e28f2016-03-13 00:33:48 -05001446 ivt_idle_state_table_update();
1447 break;
Dave Hansendb73c5a2016-06-02 17:19:32 -07001448 case INTEL_FAM6_ATOM_GOLDMONT:
Peter Zijlstraf2c4db12018-08-07 10:17:27 -07001449 case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
Len Brown5dcef692016-04-06 17:00:47 -04001450 bxt_idle_state_table_update();
1451 break;
Peter Zijlstrac66f78a2019-08-27 21:48:21 +02001452 case INTEL_FAM6_SKYLAKE:
Len Brownd70e28f2016-03-13 00:33:48 -05001453 sklh_idle_state_table_update();
1454 break;
Len Brown0138d8f2014-04-04 01:21:07 -04001455 }
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301456
Len Browne022e7e2013-02-01 23:37:30 -05001457 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001458 unsigned int mwait_hint;
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301459
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001460 if (intel_idle_max_cstate_reached(cstate))
1461 break;
1462
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001463 if (!cpuidle_state_table[cstate].enter &&
1464 !cpuidle_state_table[cstate].enter_s2idle)
Len Browne022e7e2013-02-01 23:37:30 -05001465 break;
1466
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001467 /* If marked as unusable, skip this state. */
Rafael J. Wysockiba1e78a2019-11-21 19:41:51 +01001468 if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
Joe Perches654d08a2017-06-09 12:29:20 -07001469 pr_debug("state %s is disabled\n",
1470 cpuidle_state_table[cstate].name);
Len Brownd70e28f2016-03-13 00:33:48 -05001471 continue;
1472 }
1473
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001474 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
1475 if (!intel_idle_verify_cstate(mwait_hint))
1476 continue;
Len Brownd70e28f2016-03-13 00:33:48 -05001477
Rafael J. Wysocki9f3d6da2019-12-13 09:55:52 +01001478 /* Structure copy. */
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001479 drv->states[drv->state_count] = cpuidle_state_table[cstate];
1480
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001481 if ((disabled_states_mask & BIT(drv->state_count)) ||
1482 ((icpu->use_acpi || force_use_acpi) &&
1483 intel_idle_off_by_default(mwait_hint) &&
1484 !(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
Rafael J. Wysockibff8e602019-12-13 09:56:21 +01001485 drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF;
1486
1487 drv->state_count++;
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301488 }
1489
Len Brown8c058d532014-07-31 15:21:24 -04001490 if (icpu->byt_auto_demotion_disable_flag) {
1491 wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
1492 wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
1493 }
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301494}
1495
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001496/**
1497 * intel_idle_cpuidle_driver_init - Create the list of available idle states.
1498 * @drv: cpuidle driver structure to initialize.
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001499 */
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001500static void __init intel_idle_cpuidle_driver_init(struct cpuidle_driver *drv)
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001501{
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001502 cpuidle_poll_state_init(drv);
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001503
1504 if (disabled_states_mask & BIT(0))
1505 drv->states[0].flags |= CPUIDLE_FLAG_OFF;
1506
Rafael J. Wysocki18734952019-12-13 09:56:01 +01001507 drv->state_count = 1;
1508
1509 if (icpu)
1510 intel_idle_init_cstates_icpu(drv);
1511 else
1512 intel_idle_init_cstates_acpi(drv);
1513}
Deepthi Dharwar46bcfad2011-10-28 16:20:42 +05301514
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001515static void auto_demotion_disable(void)
1516{
1517 unsigned long long msr_bits;
1518
1519 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001520 msr_bits &= ~auto_demotion_disable_flags;
Rafael J. Wysocki1aefbd72020-01-10 11:52:32 +01001521 wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
1522}
1523
1524static void c1e_promotion_disable(void)
1525{
1526 unsigned long long msr_bits;
1527
1528 rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
1529 msr_bits &= ~0x2;
1530 wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
1531}
1532
Rafael J. Wysocki6eacb152020-02-06 18:45:29 +01001533/**
1534 * intel_idle_cpu_init - Register the target CPU with the cpuidle core.
1535 * @cpu: CPU to initialize.
1536 *
1537 * Register a cpuidle device object for @cpu and update its MSRs in accordance
1538 * with the processor model flags.
Len Brown26717172010-03-08 14:07:30 -05001539 */
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001540static int intel_idle_cpu_init(unsigned int cpu)
Len Brown26717172010-03-08 14:07:30 -05001541{
Len Brown26717172010-03-08 14:07:30 -05001542 struct cpuidle_device *dev;
1543
Thomas Renninger65b7f832012-01-17 22:40:08 +01001544 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
Thomas Renninger65b7f832012-01-17 22:40:08 +01001545 dev->cpu = cpu;
Len Brown26717172010-03-08 14:07:30 -05001546
Thomas Renninger65b7f832012-01-17 22:40:08 +01001547 if (cpuidle_register_device(dev)) {
Joe Perches654d08a2017-06-09 12:29:20 -07001548 pr_debug("cpuidle_register_device %d failed!\n", cpu);
Thomas Renninger65b7f832012-01-17 22:40:08 +01001549 return -EIO;
Len Brown26717172010-03-08 14:07:30 -05001550 }
1551
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001552 if (auto_demotion_disable_flags)
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001553 auto_demotion_disable();
Thomas Renninger65b7f832012-01-17 22:40:08 +01001554
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001555 if (disable_promotion_to_c1e)
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001556 c1e_promotion_disable();
1557
1558 return 0;
1559}
1560
1561static int intel_idle_cpu_online(unsigned int cpu)
1562{
1563 struct cpuidle_device *dev;
1564
Rafael J. Wysocki40ab82e2020-02-06 18:40:54 +01001565 if (!lapic_timer_always_reliable)
Rafael J. Wysockicbd2c4c2020-01-10 11:43:23 +01001566 tick_broadcast_enable();
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001567
1568 /*
1569 * Some systems can hotplug a cpu at runtime after
1570 * the kernel has booted, we have to initialize the
1571 * driver in this case
1572 */
1573 dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
1574 if (!dev->registered)
1575 return intel_idle_cpu_init(cpu);
Bartlomiej Zolnierkiewiczdbf87ab2013-12-20 19:47:28 +01001576
Len Brown26717172010-03-08 14:07:30 -05001577 return 0;
1578}
Len Brown26717172010-03-08 14:07:30 -05001579
Rafael J. Wysocki0755a9b2020-01-10 11:49:58 +01001580/**
1581 * intel_idle_cpuidle_devices_uninit - Unregister all cpuidle devices.
1582 */
1583static void __init intel_idle_cpuidle_devices_uninit(void)
1584{
1585 int i;
1586
1587 for_each_online_cpu(i)
1588 cpuidle_unregister_device(per_cpu_ptr(intel_idle_cpuidle_devices, i));
1589}
1590
Len Brown26717172010-03-08 14:07:30 -05001591static int __init intel_idle_init(void)
1592{
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001593 const struct x86_cpu_id *id;
1594 unsigned int eax, ebx, ecx;
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001595 int retval;
Len Brown26717172010-03-08 14:07:30 -05001596
Thomas Renningerd1896042010-11-03 17:06:14 +01001597 /* Do not load intel_idle at all for now if idle= is passed */
1598 if (boot_option_idle_override != IDLE_NO_OVERRIDE)
1599 return -ENODEV;
1600
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001601 if (max_cstate == 0) {
1602 pr_debug("disabled\n");
1603 return -EPERM;
1604 }
1605
1606 id = x86_match_cpu(intel_idle_ids);
1607 if (id) {
1608 if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
1609 pr_debug("Please enable MWAIT in BIOS SETUP\n");
1610 return -ENODEV;
1611 }
1612 } else {
1613 id = x86_match_cpu(intel_mwait_ids);
1614 if (!id)
1615 return -ENODEV;
1616 }
1617
1618 if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
1619 return -ENODEV;
1620
1621 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
1622
1623 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
1624 !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
1625 !mwait_substates)
1626 return -ENODEV;
1627
1628 pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
1629
1630 icpu = (const struct idle_cpu *)id->driver_data;
1631 if (icpu) {
1632 cpuidle_state_table = icpu->state_table;
Rafael J. Wysocki7f843dd2020-02-06 18:41:24 +01001633 auto_demotion_disable_flags = icpu->auto_demotion_disable_flags;
1634 disable_promotion_to_c1e = icpu->disable_promotion_to_c1e;
Rafael J. Wysocki3a5be9b2020-02-03 11:57:08 +01001635 if (icpu->use_acpi || force_use_acpi)
Rafael J. Wysockia6c86e32020-01-10 11:44:58 +01001636 intel_idle_acpi_cst_extract();
1637 } else if (!intel_idle_acpi_cst_extract()) {
1638 return -ENODEV;
1639 }
1640
1641 pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
1642 boot_cpu_data.x86_model);
Len Brown26717172010-03-08 14:07:30 -05001643
Richard Cochrane9df69c2016-04-06 17:00:52 -04001644 intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
Rafael J. Wysocki533da742020-01-10 11:45:49 +01001645 if (!intel_idle_cpuidle_devices)
Richard Cochrane9df69c2016-04-06 17:00:52 -04001646 return -ENOMEM;
1647
Rafael J. Wysocki3d3a1ae2020-01-10 11:48:25 +01001648 intel_idle_cpuidle_driver_init(&intel_idle_driver);
1649
Len Brown26717172010-03-08 14:07:30 -05001650 retval = cpuidle_register_driver(&intel_idle_driver);
1651 if (retval) {
Konrad Rzeszutek Wilk3735d522012-08-16 22:06:55 +02001652 struct cpuidle_driver *drv = cpuidle_get_driver();
Joe Perches654d08a2017-06-09 12:29:20 -07001653 printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"),
1654 drv ? drv->name : "none");
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001655 goto init_driver_fail;
Len Brown26717172010-03-08 14:07:30 -05001656 }
1657
Richard Cochran2259a812016-04-06 17:00:54 -04001658 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
Rafael J. Wysocki40ab82e2020-02-06 18:40:54 +01001659 lapic_timer_always_reliable = true;
Richard Cochran2259a812016-04-06 17:00:54 -04001660
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001661 retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online",
1662 intel_idle_cpu_online, NULL);
1663 if (retval < 0)
1664 goto hp_setup_fail;
Len Brown26717172010-03-08 14:07:30 -05001665
Rafael J. Wysocki40ab82e2020-02-06 18:40:54 +01001666 pr_debug("Local APIC timer is reliable in %s\n",
1667 lapic_timer_always_reliable ? "all C-states" : "C1");
Richard Cochran2259a812016-04-06 17:00:54 -04001668
Len Brown26717172010-03-08 14:07:30 -05001669 return 0;
Sebastian Andrzej Siewiorfb1013a2016-11-29 10:51:43 +01001670
1671hp_setup_fail:
1672 intel_idle_cpuidle_devices_uninit();
1673 cpuidle_unregister_driver(&intel_idle_driver);
1674init_driver_fail:
1675 free_percpu(intel_idle_cpuidle_devices);
1676 return retval;
1677
Len Brown26717172010-03-08 14:07:30 -05001678}
Paul Gortmaker02c4fae2016-06-17 01:28:33 -04001679device_initcall(intel_idle_init);
Len Brown26717172010-03-08 14:07:30 -05001680
Paul Gortmaker02c4fae2016-06-17 01:28:33 -04001681/*
1682 * We are not really modular, but we used to support that. Meaning we also
1683 * support "intel_idle.max_cstate=..." at boot and also a read-only export of
1684 * it at /sys/module/intel_idle/parameters/max_cstate -- so using module_param
1685 * is the easiest way (currently) to continue doing that.
1686 */
Len Brown26717172010-03-08 14:07:30 -05001687module_param(max_cstate, int, 0444);
Rafael J. Wysocki4dcb78e2020-02-03 11:57:18 +01001688/*
1689 * The positions of the bits that are set in this number are the indices of the
1690 * idle states to be disabled by default (as reflected by the names of the
1691 * corresponding idle state directories in sysfs, "state0", "state1" ...
1692 * "state<i>" ..., where <i> is the index of the given state).
1693 */
1694module_param_named(states_off, disabled_states_mask, uint, 0444);
1695MODULE_PARM_DESC(states_off, "Mask of disabled idle states");