Thomas Gleixner | a61127c | 2019-05-29 16:57:49 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 2 | /* |
| 3 | * intel_idle.c - native hardware idle loop for modern Intel processors |
| 4 | * |
Rafael J. Wysocki | 317e5ec | 2020-02-06 18:45:49 +0100 | [diff] [blame] | 5 | * Copyright (c) 2013 - 2020, Intel Corporation. |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 6 | * Len Brown <len.brown@intel.com> |
Rafael J. Wysocki | 317e5ec | 2020-02-06 18:45:49 +0100 | [diff] [blame] | 7 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* |
Alexander Monakov | 8bb2e2a | 2020-10-12 15:50:33 +0300 | [diff] [blame] | 11 | * intel_idle is a cpuidle driver that loads on all Intel CPUs with MWAIT |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 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 |
Alexander Monakov | 8bb2e2a | 2020-10-12 15:50:33 +0300 | [diff] [blame] | 23 | * for preventing entry into deep C-states |
| 24 | * |
| 25 | * CPU will flush caches as needed when entering a C-state via MWAIT |
| 26 | * (in contrast to entering ACPI C3, in which case the WBINVD |
| 27 | * instruction needs to be executed to flush the caches) |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * Known limitations |
| 32 | * |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 33 | * ACPI has a .suspend hack to turn off deep c-statees during suspend |
| 34 | * to avoid complications with the lapic timer workaround. |
| 35 | * Have not seen issues with suspend, but may need same workaround here. |
| 36 | * |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 37 | */ |
| 38 | |
| 39 | /* un-comment DEBUG to enable pr_debug() statements */ |
Tom Rix | 651bc58 | 2021-01-15 15:56:46 -0800 | [diff] [blame] | 40 | /* #define DEBUG */ |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 41 | |
Joe Perches | 654d08a | 2017-06-09 12:29:20 -0700 | [diff] [blame] | 42 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 43 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 44 | #include <linux/acpi.h> |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 45 | #include <linux/kernel.h> |
| 46 | #include <linux/cpuidle.h> |
Thomas Gleixner | 76962ca | 2015-04-03 02:02:34 +0200 | [diff] [blame] | 47 | #include <linux/tick.h> |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 48 | #include <trace/events/power.h> |
| 49 | #include <linux/sched.h> |
Shaohua Li | 2a2d31c | 2011-01-10 09:38:12 +0800 | [diff] [blame] | 50 | #include <linux/notifier.h> |
| 51 | #include <linux/cpu.h> |
Paul Gortmaker | 02c4fae | 2016-06-17 01:28:33 -0400 | [diff] [blame] | 52 | #include <linux/moduleparam.h> |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 53 | #include <asm/cpu_device_id.h> |
Dave Hansen | db73c5a | 2016-06-02 17:19:32 -0700 | [diff] [blame] | 54 | #include <asm/intel-family.h> |
H. Peter Anvin | bc83ccc | 2010-09-17 15:36:40 -0700 | [diff] [blame] | 55 | #include <asm/mwait.h> |
Len Brown | 14796fc | 2011-01-18 20:48:27 -0500 | [diff] [blame] | 56 | #include <asm/msr.h> |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 57 | |
Rafael J. Wysocki | 317e5ec | 2020-02-06 18:45:49 +0100 | [diff] [blame] | 58 | #define INTEL_IDLE_VERSION "0.5.1" |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 59 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 60 | static struct cpuidle_driver intel_idle_driver = { |
| 61 | .name = "intel_idle", |
| 62 | .owner = THIS_MODULE, |
| 63 | }; |
| 64 | /* intel_idle.max_cstate=0 disables driver */ |
Len Brown | 137ecc7 | 2013-02-01 21:35:35 -0500 | [diff] [blame] | 65 | static int max_cstate = CPUIDLE_STATE_MAX - 1; |
Rafael J. Wysocki | 4dcb78e | 2020-02-03 11:57:18 +0100 | [diff] [blame] | 66 | static unsigned int disabled_states_mask; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 67 | |
Rafael J. Wysocki | 6eb0443 | 2020-02-06 18:45:18 +0100 | [diff] [blame] | 68 | static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 69 | |
| 70 | static unsigned long auto_demotion_disable_flags; |
| 71 | static bool disable_promotion_to_c1e; |
| 72 | |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 73 | struct idle_cpu { |
| 74 | struct cpuidle_state *state_table; |
| 75 | |
| 76 | /* |
| 77 | * Hardware C-state auto-demotion may not always be optimal. |
| 78 | * Indicate which enable bits to clear here. |
| 79 | */ |
| 80 | unsigned long auto_demotion_disable_flags; |
Len Brown | 8c058d53 | 2014-07-31 15:21:24 -0400 | [diff] [blame] | 81 | bool byt_auto_demotion_disable_flag; |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 82 | bool disable_promotion_to_c1e; |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 83 | bool use_acpi; |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 86 | static const struct idle_cpu *icpu __initdata; |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 87 | static struct cpuidle_state *cpuidle_state_table __initdata; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 88 | |
Rafael J. Wysocki | 6eb0443 | 2020-02-06 18:45:18 +0100 | [diff] [blame] | 89 | static unsigned int mwait_substates __initdata; |
| 90 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 91 | /* |
Artem Bityutskiy | c227233 | 2021-09-17 10:20:22 +0300 | [diff] [blame] | 92 | * Enable interrupts before entering the C-state. On some platforms and for |
| 93 | * some C-states, this may measurably decrease interrupt latency. |
| 94 | */ |
| 95 | #define CPUIDLE_FLAG_IRQ_ENABLE BIT(14) |
| 96 | |
| 97 | /* |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 98 | * Enable this state by default even if the ACPI _CST does not list it. |
| 99 | */ |
| 100 | #define CPUIDLE_FLAG_ALWAYS_ENABLE BIT(15) |
| 101 | |
| 102 | /* |
Len Brown | b1beab4 | 2013-01-31 19:55:37 -0500 | [diff] [blame] | 103 | * 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. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 112 | /** |
| 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 | */ |
| 129 | static __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 */ |
Rafael J. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 135 | |
Artem Bityutskiy | c227233 | 2021-09-17 10:20:22 +0300 | [diff] [blame] | 136 | if (state->flags & CPUIDLE_FLAG_IRQ_ENABLE) |
| 137 | local_irq_enable(); |
| 138 | |
Rafael J. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 139 | mwait_idle_with_hints(eax, ecx); |
| 140 | |
Rafael J. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 141 | return index; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * intel_idle_s2idle - Ask the processor to enter the given idle state. |
| 146 | * @dev: cpuidle device of the target CPU. |
| 147 | * @drv: cpuidle driver (assumed to point to intel_idle_driver). |
| 148 | * @index: Target idle state index. |
| 149 | * |
| 150 | * Use the MWAIT instruction to notify the processor that the CPU represented by |
| 151 | * @dev is idle and it can try to enter the idle state corresponding to @index. |
| 152 | * |
| 153 | * Invoked as a suspend-to-idle callback routine with frozen user space, frozen |
| 154 | * scheduler tick and suspended scheduler clock on the target CPU. |
| 155 | */ |
Neal Liu | efe9711 | 2020-07-27 11:25:46 +0800 | [diff] [blame] | 156 | static __cpuidle int intel_idle_s2idle(struct cpuidle_device *dev, |
| 157 | struct cpuidle_driver *drv, int index) |
Rafael J. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 158 | { |
| 159 | unsigned long eax = flg2MWAIT(drv->states[index].flags); |
| 160 | unsigned long ecx = 1; /* break on interrupt flag */ |
| 161 | |
| 162 | mwait_idle_with_hints(eax, ecx); |
Neal Liu | efe9711 | 2020-07-27 11:25:46 +0800 | [diff] [blame] | 163 | |
| 164 | return 0; |
Rafael J. Wysocki | 30a996f | 2020-02-06 18:41:15 +0100 | [diff] [blame] | 165 | } |
| 166 | |
Len Brown | b1beab4 | 2013-01-31 19:55:37 -0500 | [diff] [blame] | 167 | /* |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 168 | * States are indexed by the cstate number, |
| 169 | * which is also the index into the MWAIT hint array. |
| 170 | * Thus C0 is a dummy. |
| 171 | */ |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 172 | static struct cpuidle_state nehalem_cstates[] __initdata = { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 173 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 174 | .name = "C1", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 175 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 176 | .flags = MWAIT2flg(0x00), |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 177 | .exit_latency = 3, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 178 | .target_residency = 6, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 179 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 180 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 181 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 182 | .name = "C1E", |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 183 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 184 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 185 | .exit_latency = 10, |
| 186 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 187 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 188 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 189 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 190 | .name = "C3", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 191 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 192 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 193 | .exit_latency = 20, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 194 | .target_residency = 80, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 195 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 196 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 197 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 198 | .name = "C6", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 199 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 200 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 201 | .exit_latency = 200, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 202 | .target_residency = 800, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 203 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 204 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 205 | { |
| 206 | .enter = NULL } |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 207 | }; |
| 208 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 209 | static struct cpuidle_state snb_cstates[] __initdata = { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 210 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 211 | .name = "C1", |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 212 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 213 | .flags = MWAIT2flg(0x00), |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 214 | .exit_latency = 2, |
| 215 | .target_residency = 2, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 216 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 217 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 218 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 219 | .name = "C1E", |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 220 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 221 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 222 | .exit_latency = 10, |
| 223 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 224 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 225 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 226 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 227 | .name = "C3", |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 228 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 229 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 230 | .exit_latency = 80, |
Len Brown | ddbd550 | 2010-12-13 18:28:22 -0500 | [diff] [blame] | 231 | .target_residency = 211, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 232 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 233 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 234 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 235 | .name = "C6", |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 236 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 237 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 238 | .exit_latency = 104, |
Len Brown | ddbd550 | 2010-12-13 18:28:22 -0500 | [diff] [blame] | 239 | .target_residency = 345, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 240 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 241 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 242 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 243 | .name = "C7", |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 244 | .desc = "MWAIT 0x30", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 245 | .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 246 | .exit_latency = 109, |
Len Brown | ddbd550 | 2010-12-13 18:28:22 -0500 | [diff] [blame] | 247 | .target_residency = 345, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 248 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 249 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 250 | { |
| 251 | .enter = NULL } |
Len Brown | d13780d | 2010-07-07 00:12:03 -0400 | [diff] [blame] | 252 | }; |
| 253 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 254 | static struct cpuidle_state byt_cstates[] __initdata = { |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 255 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 256 | .name = "C1", |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 257 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 258 | .flags = MWAIT2flg(0x00), |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 259 | .exit_latency = 1, |
| 260 | .target_residency = 1, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 261 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 262 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 263 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 264 | .name = "C6N", |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 265 | .desc = "MWAIT 0x58", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 266 | .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | d7ef767 | 2015-03-24 23:23:20 -0400 | [diff] [blame] | 267 | .exit_latency = 300, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 268 | .target_residency = 275, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 269 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 270 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 271 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 272 | .name = "C6S", |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 273 | .desc = "MWAIT 0x52", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 274 | .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | d7ef767 | 2015-03-24 23:23:20 -0400 | [diff] [blame] | 275 | .exit_latency = 500, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 276 | .target_residency = 560, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 277 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 278 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 279 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 280 | .name = "C7", |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 281 | .desc = "MWAIT 0x60", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 282 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 283 | .exit_latency = 1200, |
Len Brown | d7ef767 | 2015-03-24 23:23:20 -0400 | [diff] [blame] | 284 | .target_residency = 4000, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 285 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 286 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 287 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 288 | .name = "C7S", |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 289 | .desc = "MWAIT 0x64", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 290 | .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 291 | .exit_latency = 10000, |
| 292 | .target_residency = 20000, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 293 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 294 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 295 | { |
| 296 | .enter = NULL } |
| 297 | }; |
| 298 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 299 | static struct cpuidle_state cht_cstates[] __initdata = { |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 300 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 301 | .name = "C1", |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 302 | .desc = "MWAIT 0x00", |
| 303 | .flags = MWAIT2flg(0x00), |
| 304 | .exit_latency = 1, |
| 305 | .target_residency = 1, |
| 306 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 307 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 308 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 309 | .name = "C6N", |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 310 | .desc = "MWAIT 0x58", |
| 311 | .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 312 | .exit_latency = 80, |
| 313 | .target_residency = 275, |
| 314 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 315 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 316 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 317 | .name = "C6S", |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 318 | .desc = "MWAIT 0x52", |
| 319 | .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 320 | .exit_latency = 200, |
| 321 | .target_residency = 560, |
| 322 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 323 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 324 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 325 | .name = "C7", |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 326 | .desc = "MWAIT 0x60", |
| 327 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 328 | .exit_latency = 1200, |
| 329 | .target_residency = 4000, |
| 330 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 331 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 332 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 333 | .name = "C7S", |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 334 | .desc = "MWAIT 0x64", |
| 335 | .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 336 | .exit_latency = 10000, |
| 337 | .target_residency = 20000, |
| 338 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 339 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 340 | { |
| 341 | .enter = NULL } |
| 342 | }; |
| 343 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 344 | static struct cpuidle_state ivb_cstates[] __initdata = { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 345 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 346 | .name = "C1", |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 347 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 348 | .flags = MWAIT2flg(0x00), |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 349 | .exit_latency = 1, |
| 350 | .target_residency = 1, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 351 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 352 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 353 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 354 | .name = "C1E", |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 355 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 356 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 357 | .exit_latency = 10, |
| 358 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 359 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 360 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 361 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 362 | .name = "C3", |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 363 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 364 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 365 | .exit_latency = 59, |
| 366 | .target_residency = 156, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 367 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 368 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 369 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 370 | .name = "C6", |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 371 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 372 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 373 | .exit_latency = 80, |
| 374 | .target_residency = 300, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 375 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 376 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 377 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 378 | .name = "C7", |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 379 | .desc = "MWAIT 0x30", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 380 | .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 381 | .exit_latency = 87, |
| 382 | .target_residency = 300, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 383 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 384 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 385 | { |
| 386 | .enter = NULL } |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 387 | }; |
| 388 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 389 | static struct cpuidle_state ivt_cstates[] __initdata = { |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 390 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 391 | .name = "C1", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 392 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 393 | .flags = MWAIT2flg(0x00), |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 394 | .exit_latency = 1, |
| 395 | .target_residency = 1, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 396 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 397 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 398 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 399 | .name = "C1E", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 400 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 401 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 402 | .exit_latency = 10, |
| 403 | .target_residency = 80, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 404 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 405 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 406 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 407 | .name = "C3", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 408 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 409 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 410 | .exit_latency = 59, |
| 411 | .target_residency = 156, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 412 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 413 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 414 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 415 | .name = "C6", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 416 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 417 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 418 | .exit_latency = 82, |
| 419 | .target_residency = 300, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 420 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 421 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 422 | { |
| 423 | .enter = NULL } |
| 424 | }; |
| 425 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 426 | static struct cpuidle_state ivt_cstates_4s[] __initdata = { |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 427 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 428 | .name = "C1", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 429 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 430 | .flags = MWAIT2flg(0x00), |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 431 | .exit_latency = 1, |
| 432 | .target_residency = 1, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 433 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 434 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 435 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 436 | .name = "C1E", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 437 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 438 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 439 | .exit_latency = 10, |
| 440 | .target_residency = 250, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 441 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 442 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 443 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 444 | .name = "C3", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 445 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 446 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 447 | .exit_latency = 59, |
| 448 | .target_residency = 300, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 449 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 450 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 451 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 452 | .name = "C6", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 453 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 454 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 455 | .exit_latency = 84, |
| 456 | .target_residency = 400, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 457 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 458 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 459 | { |
| 460 | .enter = NULL } |
| 461 | }; |
| 462 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 463 | static struct cpuidle_state ivt_cstates_8s[] __initdata = { |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 464 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 465 | .name = "C1", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 466 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 467 | .flags = MWAIT2flg(0x00), |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 468 | .exit_latency = 1, |
| 469 | .target_residency = 1, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 470 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 471 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 472 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 473 | .name = "C1E", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 474 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 475 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 476 | .exit_latency = 10, |
| 477 | .target_residency = 500, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 478 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 479 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 480 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 481 | .name = "C3", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 482 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 483 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 484 | .exit_latency = 59, |
| 485 | .target_residency = 600, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 486 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 487 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 488 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 489 | .name = "C6", |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 490 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 491 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 492 | .exit_latency = 88, |
| 493 | .target_residency = 700, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 494 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 495 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 496 | { |
| 497 | .enter = NULL } |
| 498 | }; |
| 499 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 500 | static struct cpuidle_state hsw_cstates[] __initdata = { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 501 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 502 | .name = "C1", |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 503 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 504 | .flags = MWAIT2flg(0x00), |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 505 | .exit_latency = 2, |
| 506 | .target_residency = 2, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 507 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 508 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 509 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 510 | .name = "C1E", |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 511 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 512 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 513 | .exit_latency = 10, |
| 514 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 515 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 516 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 517 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 518 | .name = "C3", |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 519 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 520 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 521 | .exit_latency = 33, |
| 522 | .target_residency = 100, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 523 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 524 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 525 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 526 | .name = "C6", |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 527 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 528 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 529 | .exit_latency = 133, |
| 530 | .target_residency = 400, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 531 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 532 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 533 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 534 | .name = "C7s", |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 535 | .desc = "MWAIT 0x32", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 536 | .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 537 | .exit_latency = 166, |
| 538 | .target_residency = 500, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 539 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 540 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 541 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 542 | .name = "C8", |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 543 | .desc = "MWAIT 0x40", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 544 | .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 545 | .exit_latency = 300, |
| 546 | .target_residency = 900, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 547 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 548 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 549 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 550 | .name = "C9", |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 551 | .desc = "MWAIT 0x50", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 552 | .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 553 | .exit_latency = 600, |
| 554 | .target_residency = 1800, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 555 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 556 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 557 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 558 | .name = "C10", |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 559 | .desc = "MWAIT 0x60", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 560 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 561 | .exit_latency = 2600, |
| 562 | .target_residency = 7700, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 563 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 564 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 86239ce | 2013-02-27 13:18:50 -0500 | [diff] [blame] | 565 | { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 566 | .enter = NULL } |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 567 | }; |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 568 | static struct cpuidle_state bdw_cstates[] __initdata = { |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 569 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 570 | .name = "C1", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 571 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 572 | .flags = MWAIT2flg(0x00), |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 573 | .exit_latency = 2, |
| 574 | .target_residency = 2, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 575 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 576 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 577 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 578 | .name = "C1E", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 579 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 580 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 581 | .exit_latency = 10, |
| 582 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 583 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 584 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 585 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 586 | .name = "C3", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 587 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 588 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 589 | .exit_latency = 40, |
| 590 | .target_residency = 100, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 591 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 592 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 593 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 594 | .name = "C6", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 595 | .desc = "MWAIT 0x20", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 596 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 597 | .exit_latency = 133, |
| 598 | .target_residency = 400, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 599 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 600 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 601 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 602 | .name = "C7s", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 603 | .desc = "MWAIT 0x32", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 604 | .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 605 | .exit_latency = 166, |
| 606 | .target_residency = 500, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 607 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 608 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 609 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 610 | .name = "C8", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 611 | .desc = "MWAIT 0x40", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 612 | .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 613 | .exit_latency = 300, |
| 614 | .target_residency = 900, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 615 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 616 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 617 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 618 | .name = "C9", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 619 | .desc = "MWAIT 0x50", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 620 | .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 621 | .exit_latency = 600, |
| 622 | .target_residency = 1800, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 623 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 624 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 625 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 626 | .name = "C10", |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 627 | .desc = "MWAIT 0x60", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 628 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 629 | .exit_latency = 2600, |
| 630 | .target_residency = 7700, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 631 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 632 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 633 | { |
| 634 | .enter = NULL } |
| 635 | }; |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 636 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 637 | static struct cpuidle_state skl_cstates[] __initdata = { |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 638 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 639 | .name = "C1", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 640 | .desc = "MWAIT 0x00", |
| 641 | .flags = MWAIT2flg(0x00), |
| 642 | .exit_latency = 2, |
| 643 | .target_residency = 2, |
| 644 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 645 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 646 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 647 | .name = "C1E", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 648 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 649 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 650 | .exit_latency = 10, |
| 651 | .target_residency = 20, |
| 652 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 653 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 654 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 655 | .name = "C3", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 656 | .desc = "MWAIT 0x10", |
| 657 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 658 | .exit_latency = 70, |
| 659 | .target_residency = 100, |
| 660 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 661 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 662 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 663 | .name = "C6", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 664 | .desc = "MWAIT 0x20", |
| 665 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 135919a | 2015-09-09 13:35:05 -0400 | [diff] [blame] | 666 | .exit_latency = 85, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 667 | .target_residency = 200, |
| 668 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 669 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 670 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 671 | .name = "C7s", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 672 | .desc = "MWAIT 0x33", |
| 673 | .flags = MWAIT2flg(0x33) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 674 | .exit_latency = 124, |
| 675 | .target_residency = 800, |
| 676 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 677 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 678 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 679 | .name = "C8", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 680 | .desc = "MWAIT 0x40", |
| 681 | .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 135919a | 2015-09-09 13:35:05 -0400 | [diff] [blame] | 682 | .exit_latency = 200, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 683 | .target_residency = 800, |
| 684 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 685 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 686 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 687 | .name = "C9", |
Len Brown | 135919a | 2015-09-09 13:35:05 -0400 | [diff] [blame] | 688 | .desc = "MWAIT 0x50", |
| 689 | .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 690 | .exit_latency = 480, |
| 691 | .target_residency = 5000, |
| 692 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 693 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 135919a | 2015-09-09 13:35:05 -0400 | [diff] [blame] | 694 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 695 | .name = "C10", |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 696 | .desc = "MWAIT 0x60", |
| 697 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 698 | .exit_latency = 890, |
| 699 | .target_residency = 5000, |
| 700 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 701 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 702 | { |
| 703 | .enter = NULL } |
| 704 | }; |
| 705 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 706 | static struct cpuidle_state skx_cstates[] __initdata = { |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 707 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 708 | .name = "C1", |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 709 | .desc = "MWAIT 0x00", |
Artem Bityutskiy | c227233 | 2021-09-17 10:20:22 +0300 | [diff] [blame] | 710 | .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_IRQ_ENABLE, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 711 | .exit_latency = 2, |
| 712 | .target_residency = 2, |
| 713 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 714 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 715 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 716 | .name = "C1E", |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 717 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 718 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 719 | .exit_latency = 10, |
| 720 | .target_residency = 20, |
| 721 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 722 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 723 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 724 | .name = "C6", |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 725 | .desc = "MWAIT 0x20", |
| 726 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 727 | .exit_latency = 133, |
| 728 | .target_residency = 600, |
| 729 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 730 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 731 | { |
| 732 | .enter = NULL } |
| 733 | }; |
| 734 | |
Chen Yu | a472ad2 | 2020-07-10 12:12:01 +0800 | [diff] [blame] | 735 | static struct cpuidle_state icx_cstates[] __initdata = { |
| 736 | { |
| 737 | .name = "C1", |
| 738 | .desc = "MWAIT 0x00", |
Artem Bityutskiy | c227233 | 2021-09-17 10:20:22 +0300 | [diff] [blame] | 739 | .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_IRQ_ENABLE, |
Chen Yu | a472ad2 | 2020-07-10 12:12:01 +0800 | [diff] [blame] | 740 | .exit_latency = 1, |
| 741 | .target_residency = 1, |
| 742 | .enter = &intel_idle, |
| 743 | .enter_s2idle = intel_idle_s2idle, }, |
| 744 | { |
| 745 | .name = "C1E", |
| 746 | .desc = "MWAIT 0x01", |
| 747 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
| 748 | .exit_latency = 4, |
| 749 | .target_residency = 4, |
| 750 | .enter = &intel_idle, |
| 751 | .enter_s2idle = intel_idle_s2idle, }, |
| 752 | { |
| 753 | .name = "C6", |
| 754 | .desc = "MWAIT 0x20", |
| 755 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
Artem Bityutskiy | d484b8b | 2021-03-08 16:31:46 +0200 | [diff] [blame] | 756 | .exit_latency = 170, |
| 757 | .target_residency = 600, |
Chen Yu | a472ad2 | 2020-07-10 12:12:01 +0800 | [diff] [blame] | 758 | .enter = &intel_idle, |
| 759 | .enter_s2idle = intel_idle_s2idle, }, |
| 760 | { |
| 761 | .enter = NULL } |
| 762 | }; |
| 763 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 764 | static struct cpuidle_state atom_cstates[] __initdata = { |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 765 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 766 | .name = "C1E", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 767 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 768 | .flags = MWAIT2flg(0x00), |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 769 | .exit_latency = 10, |
| 770 | .target_residency = 20, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 771 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 772 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 773 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 774 | .name = "C2", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 775 | .desc = "MWAIT 0x10", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 776 | .flags = MWAIT2flg(0x10), |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 777 | .exit_latency = 20, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 778 | .target_residency = 80, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 779 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 780 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 781 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 782 | .name = "C4", |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 783 | .desc = "MWAIT 0x30", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 784 | .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 785 | .exit_latency = 100, |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 786 | .target_residency = 400, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 787 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 788 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 789 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 790 | .name = "C6", |
Len Brown | 7fcca7d | 2010-10-05 13:43:14 -0400 | [diff] [blame] | 791 | .desc = "MWAIT 0x52", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 792 | .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | 7fcca7d | 2010-10-05 13:43:14 -0400 | [diff] [blame] | 793 | .exit_latency = 140, |
Len Brown | 7fcca7d | 2010-10-05 13:43:14 -0400 | [diff] [blame] | 794 | .target_residency = 560, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 795 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 796 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 797 | { |
| 798 | .enter = NULL } |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 799 | }; |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 800 | static struct cpuidle_state tangier_cstates[] __initdata = { |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 801 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 802 | .name = "C1", |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 803 | .desc = "MWAIT 0x00", |
| 804 | .flags = MWAIT2flg(0x00), |
| 805 | .exit_latency = 1, |
| 806 | .target_residency = 4, |
| 807 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 808 | .enter_s2idle = intel_idle_s2idle, }, |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 809 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 810 | .name = "C4", |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 811 | .desc = "MWAIT 0x30", |
| 812 | .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 813 | .exit_latency = 100, |
| 814 | .target_residency = 400, |
| 815 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 816 | .enter_s2idle = intel_idle_s2idle, }, |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 817 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 818 | .name = "C6", |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 819 | .desc = "MWAIT 0x52", |
| 820 | .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 821 | .exit_latency = 140, |
| 822 | .target_residency = 560, |
| 823 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 824 | .enter_s2idle = intel_idle_s2idle, }, |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 825 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 826 | .name = "C7", |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 827 | .desc = "MWAIT 0x60", |
| 828 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 829 | .exit_latency = 1200, |
| 830 | .target_residency = 4000, |
| 831 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 832 | .enter_s2idle = intel_idle_s2idle, }, |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 833 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 834 | .name = "C9", |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 835 | .desc = "MWAIT 0x64", |
| 836 | .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 837 | .exit_latency = 10000, |
| 838 | .target_residency = 20000, |
| 839 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 840 | .enter_s2idle = intel_idle_s2idle, }, |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 841 | { |
| 842 | .enter = NULL } |
| 843 | }; |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 844 | static struct cpuidle_state avn_cstates[] __initdata = { |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 845 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 846 | .name = "C1", |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 847 | .desc = "MWAIT 0x00", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 848 | .flags = MWAIT2flg(0x00), |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 849 | .exit_latency = 2, |
| 850 | .target_residency = 2, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 851 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 852 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 853 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 854 | .name = "C6", |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 855 | .desc = "MWAIT 0x51", |
Daniel Lezcano | b82b6cc | 2014-11-12 16:03:50 +0100 | [diff] [blame] | 856 | .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TLB_FLUSHED, |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 857 | .exit_latency = 15, |
| 858 | .target_residency = 45, |
Rafael J. Wysocki | 5fe2e52 | 2015-02-11 05:04:17 +0100 | [diff] [blame] | 859 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 860 | .enter_s2idle = intel_idle_s2idle, }, |
Jiang Liu | 8839099 | 2014-01-09 15:30:27 +0800 | [diff] [blame] | 861 | { |
| 862 | .enter = NULL } |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 863 | }; |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 864 | static struct cpuidle_state knl_cstates[] __initdata = { |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 865 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 866 | .name = "C1", |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 867 | .desc = "MWAIT 0x00", |
| 868 | .flags = MWAIT2flg(0x00), |
| 869 | .exit_latency = 1, |
| 870 | .target_residency = 2, |
| 871 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 872 | .enter_s2idle = intel_idle_s2idle }, |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 873 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 874 | .name = "C6", |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 875 | .desc = "MWAIT 0x10", |
| 876 | .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 877 | .exit_latency = 120, |
| 878 | .target_residency = 500, |
| 879 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 880 | .enter_s2idle = intel_idle_s2idle }, |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 881 | { |
| 882 | .enter = NULL } |
| 883 | }; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 884 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 885 | static struct cpuidle_state bxt_cstates[] __initdata = { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 886 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 887 | .name = "C1", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 888 | .desc = "MWAIT 0x00", |
| 889 | .flags = MWAIT2flg(0x00), |
| 890 | .exit_latency = 2, |
| 891 | .target_residency = 2, |
| 892 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 893 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 894 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 895 | .name = "C1E", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 896 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 897 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 898 | .exit_latency = 10, |
| 899 | .target_residency = 20, |
| 900 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 901 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 902 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 903 | .name = "C6", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 904 | .desc = "MWAIT 0x20", |
| 905 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 906 | .exit_latency = 133, |
| 907 | .target_residency = 133, |
| 908 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 909 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 910 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 911 | .name = "C7s", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 912 | .desc = "MWAIT 0x31", |
| 913 | .flags = MWAIT2flg(0x31) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 914 | .exit_latency = 155, |
| 915 | .target_residency = 155, |
| 916 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 917 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 918 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 919 | .name = "C8", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 920 | .desc = "MWAIT 0x40", |
| 921 | .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 922 | .exit_latency = 1000, |
| 923 | .target_residency = 1000, |
| 924 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 925 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 926 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 927 | .name = "C9", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 928 | .desc = "MWAIT 0x50", |
| 929 | .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 930 | .exit_latency = 2000, |
| 931 | .target_residency = 2000, |
| 932 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 933 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 934 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 935 | .name = "C10", |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 936 | .desc = "MWAIT 0x60", |
| 937 | .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 938 | .exit_latency = 10000, |
| 939 | .target_residency = 10000, |
| 940 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 941 | .enter_s2idle = intel_idle_s2idle, }, |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 942 | { |
| 943 | .enter = NULL } |
| 944 | }; |
| 945 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 946 | static struct cpuidle_state dnv_cstates[] __initdata = { |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 947 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 948 | .name = "C1", |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 949 | .desc = "MWAIT 0x00", |
| 950 | .flags = MWAIT2flg(0x00), |
| 951 | .exit_latency = 2, |
| 952 | .target_residency = 2, |
| 953 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 954 | .enter_s2idle = intel_idle_s2idle, }, |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 955 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 956 | .name = "C1E", |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 957 | .desc = "MWAIT 0x01", |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 958 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 959 | .exit_latency = 10, |
| 960 | .target_residency = 20, |
| 961 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 962 | .enter_s2idle = intel_idle_s2idle, }, |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 963 | { |
Len Brown | de09cdd | 2017-02-28 16:32:44 -0500 | [diff] [blame] | 964 | .name = "C6", |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 965 | .desc = "MWAIT 0x20", |
| 966 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 967 | .exit_latency = 50, |
| 968 | .target_residency = 500, |
| 969 | .enter = &intel_idle, |
Rafael J. Wysocki | 28ba086 | 2017-08-10 00:14:45 +0200 | [diff] [blame] | 970 | .enter_s2idle = intel_idle_s2idle, }, |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 971 | { |
| 972 | .enter = NULL } |
| 973 | }; |
| 974 | |
Artem Bityutskiy | 9cf93f05 | 2020-12-27 12:11:16 +0200 | [diff] [blame] | 975 | /* |
| 976 | * Note, depending on HW and FW revision, SnowRidge SoC may or may not support |
| 977 | * C6, and this is indicated in the CPUID mwait leaf. |
| 978 | */ |
| 979 | static struct cpuidle_state snr_cstates[] __initdata = { |
| 980 | { |
| 981 | .name = "C1", |
| 982 | .desc = "MWAIT 0x00", |
| 983 | .flags = MWAIT2flg(0x00), |
| 984 | .exit_latency = 2, |
| 985 | .target_residency = 2, |
| 986 | .enter = &intel_idle, |
| 987 | .enter_s2idle = intel_idle_s2idle, }, |
| 988 | { |
| 989 | .name = "C1E", |
| 990 | .desc = "MWAIT 0x01", |
| 991 | .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, |
| 992 | .exit_latency = 15, |
| 993 | .target_residency = 25, |
| 994 | .enter = &intel_idle, |
| 995 | .enter_s2idle = intel_idle_s2idle, }, |
| 996 | { |
| 997 | .name = "C6", |
| 998 | .desc = "MWAIT 0x20", |
| 999 | .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, |
| 1000 | .exit_latency = 130, |
| 1001 | .target_residency = 500, |
| 1002 | .enter = &intel_idle, |
| 1003 | .enter_s2idle = intel_idle_s2idle, }, |
| 1004 | { |
| 1005 | .enter = NULL } |
| 1006 | }; |
| 1007 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1008 | static const struct idle_cpu idle_cpu_nehalem __initconst = { |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1009 | .state_table = nehalem_cstates, |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1010 | .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 1011 | .disable_promotion_to_c1e = true, |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1012 | }; |
| 1013 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1014 | static const struct idle_cpu idle_cpu_nhx __initconst = { |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1015 | .state_table = nehalem_cstates, |
| 1016 | .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE, |
| 1017 | .disable_promotion_to_c1e = true, |
| 1018 | .use_acpi = true, |
| 1019 | }; |
| 1020 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1021 | static const struct idle_cpu idle_cpu_atom __initconst = { |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1022 | .state_table = atom_cstates, |
| 1023 | }; |
| 1024 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1025 | static const struct idle_cpu idle_cpu_tangier __initconst = { |
Andy Shevchenko | 5e7ec26 | 2016-10-25 17:11:39 +0300 | [diff] [blame] | 1026 | .state_table = tangier_cstates, |
| 1027 | }; |
| 1028 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1029 | static const struct idle_cpu idle_cpu_lincroft __initconst = { |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1030 | .state_table = atom_cstates, |
| 1031 | .auto_demotion_disable_flags = ATM_LNC_C6_AUTO_DEMOTE, |
| 1032 | }; |
| 1033 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1034 | static const struct idle_cpu idle_cpu_snb __initconst = { |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1035 | .state_table = snb_cstates, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 1036 | .disable_promotion_to_c1e = true, |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1037 | }; |
| 1038 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1039 | static const struct idle_cpu idle_cpu_snx __initconst = { |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1040 | .state_table = snb_cstates, |
| 1041 | .disable_promotion_to_c1e = true, |
| 1042 | .use_acpi = true, |
| 1043 | }; |
| 1044 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1045 | static const struct idle_cpu idle_cpu_byt __initconst = { |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 1046 | .state_table = byt_cstates, |
| 1047 | .disable_promotion_to_c1e = true, |
Len Brown | 8c058d53 | 2014-07-31 15:21:24 -0400 | [diff] [blame] | 1048 | .byt_auto_demotion_disable_flag = true, |
Len Brown | 718987d | 2014-02-14 02:30:00 -0500 | [diff] [blame] | 1049 | }; |
| 1050 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1051 | static const struct idle_cpu idle_cpu_cht __initconst = { |
Len Brown | cab07a5 | 2015-03-27 20:54:01 -0400 | [diff] [blame] | 1052 | .state_table = cht_cstates, |
| 1053 | .disable_promotion_to_c1e = true, |
| 1054 | .byt_auto_demotion_disable_flag = true, |
| 1055 | }; |
| 1056 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1057 | static const struct idle_cpu idle_cpu_ivb __initconst = { |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 1058 | .state_table = ivb_cstates, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 1059 | .disable_promotion_to_c1e = true, |
Len Brown | 6edab08 | 2012-06-01 19:45:32 -0400 | [diff] [blame] | 1060 | }; |
| 1061 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1062 | static const struct idle_cpu idle_cpu_ivt __initconst = { |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 1063 | .state_table = ivt_cstates, |
| 1064 | .disable_promotion_to_c1e = true, |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1065 | .use_acpi = true, |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 1066 | }; |
| 1067 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1068 | static const struct idle_cpu idle_cpu_hsw __initconst = { |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 1069 | .state_table = hsw_cstates, |
Len Brown | 32e9518 | 2013-02-02 01:31:56 -0500 | [diff] [blame] | 1070 | .disable_promotion_to_c1e = true, |
Len Brown | 85a4d2d | 2013-01-31 14:40:49 -0500 | [diff] [blame] | 1071 | }; |
| 1072 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1073 | static const struct idle_cpu idle_cpu_hsx __initconst = { |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1074 | .state_table = hsw_cstates, |
| 1075 | .disable_promotion_to_c1e = true, |
| 1076 | .use_acpi = true, |
| 1077 | }; |
| 1078 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1079 | static const struct idle_cpu idle_cpu_bdw __initconst = { |
Len Brown | a138b56 | 2014-02-04 23:56:40 -0500 | [diff] [blame] | 1080 | .state_table = bdw_cstates, |
| 1081 | .disable_promotion_to_c1e = true, |
| 1082 | }; |
| 1083 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1084 | static const struct idle_cpu idle_cpu_bdx __initconst = { |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1085 | .state_table = bdw_cstates, |
| 1086 | .disable_promotion_to_c1e = true, |
| 1087 | .use_acpi = true, |
| 1088 | }; |
| 1089 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1090 | static const struct idle_cpu idle_cpu_skl __initconst = { |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 1091 | .state_table = skl_cstates, |
| 1092 | .disable_promotion_to_c1e = true, |
| 1093 | }; |
| 1094 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1095 | static const struct idle_cpu idle_cpu_skx __initconst = { |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 1096 | .state_table = skx_cstates, |
| 1097 | .disable_promotion_to_c1e = true, |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1098 | .use_acpi = true, |
Len Brown | f9e7165 | 2016-04-06 17:00:58 -0400 | [diff] [blame] | 1099 | }; |
Len Brown | 493f133 | 2015-03-25 23:20:37 -0400 | [diff] [blame] | 1100 | |
Chen Yu | a472ad2 | 2020-07-10 12:12:01 +0800 | [diff] [blame] | 1101 | static const struct idle_cpu idle_cpu_icx __initconst = { |
| 1102 | .state_table = icx_cstates, |
| 1103 | .disable_promotion_to_c1e = true, |
| 1104 | .use_acpi = true, |
| 1105 | }; |
| 1106 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1107 | static const struct idle_cpu idle_cpu_avn __initconst = { |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 1108 | .state_table = avn_cstates, |
| 1109 | .disable_promotion_to_c1e = true, |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1110 | .use_acpi = true, |
Len Brown | fab04b2 | 2013-11-09 00:30:17 -0500 | [diff] [blame] | 1111 | }; |
| 1112 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1113 | static const struct idle_cpu idle_cpu_knl __initconst = { |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 1114 | .state_table = knl_cstates, |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1115 | .use_acpi = true, |
Dasaratharaman Chandramouli | 281baf7 | 2014-09-04 17:22:54 -0700 | [diff] [blame] | 1116 | }; |
| 1117 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1118 | static const struct idle_cpu idle_cpu_bxt __initconst = { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1119 | .state_table = bxt_cstates, |
| 1120 | .disable_promotion_to_c1e = true, |
| 1121 | }; |
| 1122 | |
Rafael J. Wysocki | ab1a8522 | 2020-02-06 18:45:06 +0100 | [diff] [blame] | 1123 | static const struct idle_cpu idle_cpu_dnv __initconst = { |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 1124 | .state_table = dnv_cstates, |
| 1125 | .disable_promotion_to_c1e = true, |
Rafael J. Wysocki | e6d4f08 | 2019-12-13 09:56:38 +0100 | [diff] [blame] | 1126 | .use_acpi = true, |
Jacob Pan | 0080d65 | 2016-06-17 01:28:34 -0400 | [diff] [blame] | 1127 | }; |
| 1128 | |
Artem Bityutskiy | 9cf93f05 | 2020-12-27 12:11:16 +0200 | [diff] [blame] | 1129 | static const struct idle_cpu idle_cpu_snr __initconst = { |
| 1130 | .state_table = snr_cstates, |
| 1131 | .disable_promotion_to_c1e = true, |
| 1132 | .use_acpi = true, |
| 1133 | }; |
| 1134 | |
Mathias Krause | d5cdc3c | 2015-03-25 22:15:14 +0100 | [diff] [blame] | 1135 | static const struct x86_cpu_id intel_idle_ids[] __initconst = { |
Thomas Gleixner | 4a9f45a | 2020-03-20 14:14:00 +0100 | [diff] [blame] | 1136 | X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EP, &idle_cpu_nhx), |
| 1137 | X86_MATCH_INTEL_FAM6_MODEL(NEHALEM, &idle_cpu_nehalem), |
| 1138 | X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_G, &idle_cpu_nehalem), |
| 1139 | X86_MATCH_INTEL_FAM6_MODEL(WESTMERE, &idle_cpu_nehalem), |
| 1140 | X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EP, &idle_cpu_nhx), |
| 1141 | X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EX, &idle_cpu_nhx), |
| 1142 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL, &idle_cpu_atom), |
| 1143 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL_MID, &idle_cpu_lincroft), |
| 1144 | X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EX, &idle_cpu_nhx), |
| 1145 | X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &idle_cpu_snb), |
| 1146 | X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &idle_cpu_snx), |
| 1147 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL, &idle_cpu_atom), |
| 1148 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, &idle_cpu_byt), |
| 1149 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &idle_cpu_tangier), |
| 1150 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, &idle_cpu_cht), |
| 1151 | X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, &idle_cpu_ivb), |
| 1152 | X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, &idle_cpu_ivt), |
| 1153 | X86_MATCH_INTEL_FAM6_MODEL(HASWELL, &idle_cpu_hsw), |
| 1154 | X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, &idle_cpu_hsx), |
| 1155 | X86_MATCH_INTEL_FAM6_MODEL(HASWELL_L, &idle_cpu_hsw), |
| 1156 | X86_MATCH_INTEL_FAM6_MODEL(HASWELL_G, &idle_cpu_hsw), |
| 1157 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D, &idle_cpu_avn), |
| 1158 | X86_MATCH_INTEL_FAM6_MODEL(BROADWELL, &idle_cpu_bdw), |
| 1159 | X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_G, &idle_cpu_bdw), |
| 1160 | X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, &idle_cpu_bdx), |
| 1161 | X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, &idle_cpu_bdx), |
| 1162 | X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, &idle_cpu_skl), |
| 1163 | X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, &idle_cpu_skl), |
| 1164 | X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, &idle_cpu_skl), |
| 1165 | X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, &idle_cpu_skl), |
| 1166 | X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &idle_cpu_skx), |
Chen Yu | a472ad2 | 2020-07-10 12:12:01 +0800 | [diff] [blame] | 1167 | X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &idle_cpu_icx), |
Artem Bityutskiy | 22141d5 | 2021-04-07 09:10:28 +0300 | [diff] [blame] | 1168 | X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &idle_cpu_icx), |
Thomas Gleixner | 4a9f45a | 2020-03-20 14:14:00 +0100 | [diff] [blame] | 1169 | X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &idle_cpu_knl), |
| 1170 | X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &idle_cpu_knl), |
| 1171 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, &idle_cpu_bxt), |
| 1172 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_PLUS, &idle_cpu_bxt), |
| 1173 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, &idle_cpu_dnv), |
Artem Bityutskiy | 9cf93f05 | 2020-12-27 12:11:16 +0200 | [diff] [blame] | 1174 | X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &idle_cpu_snr), |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1175 | {} |
| 1176 | }; |
Andi Kleen | b66b8b9 | 2012-01-26 00:09:07 +0100 | [diff] [blame] | 1177 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1178 | static const struct x86_cpu_id intel_mwait_ids[] __initconst = { |
Thomas Gleixner | 4a9f45a | 2020-03-20 14:14:00 +0100 | [diff] [blame] | 1179 | X86_MATCH_VENDOR_FAM_FEATURE(INTEL, 6, X86_FEATURE_MWAIT, NULL), |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1180 | {} |
| 1181 | }; |
| 1182 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1183 | static bool __init intel_idle_max_cstate_reached(int cstate) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1184 | { |
| 1185 | if (cstate + 1 > max_cstate) { |
| 1186 | pr_info("max_cstate %d reached\n", max_cstate); |
| 1187 | return true; |
| 1188 | } |
| 1189 | return false; |
| 1190 | } |
| 1191 | |
Peter Zijlstra | 4d91614 | 2020-11-30 12:54:34 +0100 | [diff] [blame] | 1192 | static bool __init intel_idle_state_needs_timer_stop(struct cpuidle_state *state) |
| 1193 | { |
| 1194 | unsigned long eax = flg2MWAIT(state->flags); |
| 1195 | |
| 1196 | if (boot_cpu_has(X86_FEATURE_ARAT)) |
| 1197 | return false; |
| 1198 | |
| 1199 | /* |
| 1200 | * Switch over to one-shot tick broadcast if the target C-state |
| 1201 | * is deeper than C1. |
| 1202 | */ |
| 1203 | return !!((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK); |
| 1204 | } |
| 1205 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1206 | #ifdef CONFIG_ACPI_PROCESSOR_CSTATE |
| 1207 | #include <acpi/processor.h> |
| 1208 | |
Rafael J. Wysocki | 4ec32d9 | 2019-12-13 09:56:29 +0100 | [diff] [blame] | 1209 | static bool no_acpi __read_mostly; |
| 1210 | module_param(no_acpi, bool, 0444); |
| 1211 | MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list"); |
| 1212 | |
Rafael J. Wysocki | 3a5be9b | 2020-02-03 11:57:08 +0100 | [diff] [blame] | 1213 | static bool force_use_acpi __read_mostly; /* No effect if no_acpi is set. */ |
| 1214 | module_param_named(use_acpi, force_use_acpi, bool, 0444); |
| 1215 | MODULE_PARM_DESC(use_acpi, "Use ACPI _CST for building the idle states list"); |
| 1216 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1217 | static struct acpi_processor_power acpi_state_table __initdata; |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1218 | |
| 1219 | /** |
| 1220 | * intel_idle_cst_usable - Check if the _CST information can be used. |
| 1221 | * |
| 1222 | * Check if all of the C-states listed by _CST in the max_cstate range are |
| 1223 | * ACPI_CSTATE_FFH, which means that they should be entered via MWAIT. |
| 1224 | */ |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1225 | static bool __init intel_idle_cst_usable(void) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1226 | { |
| 1227 | int cstate, limit; |
| 1228 | |
| 1229 | limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1), |
| 1230 | acpi_state_table.count); |
| 1231 | |
| 1232 | for (cstate = 1; cstate < limit; cstate++) { |
| 1233 | struct acpi_processor_cx *cx = &acpi_state_table.states[cstate]; |
| 1234 | |
| 1235 | if (cx->entry_method != ACPI_CSTATE_FFH) |
| 1236 | return false; |
| 1237 | } |
| 1238 | |
| 1239 | return true; |
| 1240 | } |
| 1241 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1242 | static bool __init intel_idle_acpi_cst_extract(void) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1243 | { |
| 1244 | unsigned int cpu; |
| 1245 | |
Rafael J. Wysocki | 4ec32d9 | 2019-12-13 09:56:29 +0100 | [diff] [blame] | 1246 | if (no_acpi) { |
| 1247 | pr_debug("Not allowed to use ACPI _CST\n"); |
| 1248 | return false; |
| 1249 | } |
| 1250 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1251 | for_each_possible_cpu(cpu) { |
| 1252 | struct acpi_processor *pr = per_cpu(processors, cpu); |
| 1253 | |
| 1254 | if (!pr) |
| 1255 | continue; |
| 1256 | |
| 1257 | if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table)) |
| 1258 | continue; |
| 1259 | |
| 1260 | acpi_state_table.count++; |
| 1261 | |
| 1262 | if (!intel_idle_cst_usable()) |
| 1263 | continue; |
| 1264 | |
Mel Gorman | 75af76d | 2020-10-16 17:28:32 +0200 | [diff] [blame] | 1265 | if (!acpi_processor_claim_cst_control()) |
| 1266 | break; |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1267 | |
| 1268 | return true; |
| 1269 | } |
| 1270 | |
Mel Gorman | 75af76d | 2020-10-16 17:28:32 +0200 | [diff] [blame] | 1271 | acpi_state_table.count = 0; |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1272 | pr_debug("ACPI _CST not found or not usable\n"); |
| 1273 | return false; |
| 1274 | } |
| 1275 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1276 | static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1277 | { |
| 1278 | int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count); |
| 1279 | |
| 1280 | /* |
| 1281 | * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of |
| 1282 | * the interesting states are ACPI_CSTATE_FFH. |
| 1283 | */ |
| 1284 | for (cstate = 1; cstate < limit; cstate++) { |
| 1285 | struct acpi_processor_cx *cx; |
| 1286 | struct cpuidle_state *state; |
| 1287 | |
Chen Yu | 4e0ba55 | 2020-10-25 00:29:53 +0800 | [diff] [blame] | 1288 | if (intel_idle_max_cstate_reached(cstate - 1)) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1289 | break; |
| 1290 | |
| 1291 | cx = &acpi_state_table.states[cstate]; |
| 1292 | |
| 1293 | state = &drv->states[drv->state_count++]; |
| 1294 | |
| 1295 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d_ACPI", cstate); |
| 1296 | strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); |
| 1297 | state->exit_latency = cx->latency; |
| 1298 | /* |
| 1299 | * For C1-type C-states use the same number for both the exit |
| 1300 | * latency and target residency, because that is the case for |
| 1301 | * C1 in the majority of the static C-states tables above. |
| 1302 | * For the other types of C-states, however, set the target |
| 1303 | * residency to 3 times the exit latency which should lead to |
| 1304 | * a reasonable balance between energy-efficiency and |
| 1305 | * performance in the majority of interesting cases. |
| 1306 | */ |
| 1307 | state->target_residency = cx->latency; |
| 1308 | if (cx->type > ACPI_STATE_C1) |
| 1309 | state->target_residency *= 3; |
| 1310 | |
| 1311 | state->flags = MWAIT2flg(cx->address); |
| 1312 | if (cx->type > ACPI_STATE_C2) |
| 1313 | state->flags |= CPUIDLE_FLAG_TLB_FLUSHED; |
| 1314 | |
Rafael J. Wysocki | 4dcb78e | 2020-02-03 11:57:18 +0100 | [diff] [blame] | 1315 | if (disabled_states_mask & BIT(cstate)) |
| 1316 | state->flags |= CPUIDLE_FLAG_OFF; |
| 1317 | |
Peter Zijlstra | 6e1d2bc | 2020-11-20 11:28:35 +0100 | [diff] [blame] | 1318 | if (intel_idle_state_needs_timer_stop(state)) |
| 1319 | state->flags |= CPUIDLE_FLAG_TIMER_STOP; |
| 1320 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1321 | state->enter = intel_idle; |
| 1322 | state->enter_s2idle = intel_idle_s2idle; |
| 1323 | } |
| 1324 | } |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1325 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1326 | static bool __init intel_idle_off_by_default(u32 mwait_hint) |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1327 | { |
| 1328 | int cstate, limit; |
| 1329 | |
| 1330 | /* |
| 1331 | * If there are no _CST C-states, do not disable any C-states by |
| 1332 | * default. |
| 1333 | */ |
| 1334 | if (!acpi_state_table.count) |
| 1335 | return false; |
| 1336 | |
| 1337 | limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count); |
| 1338 | /* |
| 1339 | * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of |
| 1340 | * the interesting states are ACPI_CSTATE_FFH. |
| 1341 | */ |
| 1342 | for (cstate = 1; cstate < limit; cstate++) { |
| 1343 | if (acpi_state_table.states[cstate].address == mwait_hint) |
| 1344 | return false; |
| 1345 | } |
| 1346 | return true; |
| 1347 | } |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1348 | #else /* !CONFIG_ACPI_PROCESSOR_CSTATE */ |
Rafael J. Wysocki | 3a5be9b | 2020-02-03 11:57:08 +0100 | [diff] [blame] | 1349 | #define force_use_acpi (false) |
| 1350 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1351 | static inline bool intel_idle_acpi_cst_extract(void) { return false; } |
| 1352 | static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { } |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1353 | static inline bool intel_idle_off_by_default(u32 mwait_hint) { return false; } |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1354 | #endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */ |
| 1355 | |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1356 | /** |
| 1357 | * ivt_idle_state_table_update - Tune the idle states table for Ivy Town. |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1358 | * |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1359 | * Tune IVT multi-socket targets. |
| 1360 | * Assumption: num_sockets == (max_package_num + 1). |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1361 | */ |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1362 | static void __init ivt_idle_state_table_update(void) |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1363 | { |
| 1364 | /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */ |
| 1365 | int cpu, package_num, num_sockets = 1; |
| 1366 | |
| 1367 | for_each_online_cpu(cpu) { |
| 1368 | package_num = topology_physical_package_id(cpu); |
| 1369 | if (package_num + 1 > num_sockets) { |
| 1370 | num_sockets = package_num + 1; |
| 1371 | |
| 1372 | if (num_sockets > 4) { |
| 1373 | cpuidle_state_table = ivt_cstates_8s; |
| 1374 | return; |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | if (num_sockets > 2) |
| 1380 | cpuidle_state_table = ivt_cstates_4s; |
| 1381 | |
| 1382 | /* else, 1 and 2 socket systems use default ivt_cstates */ |
| 1383 | } |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1384 | |
Rafael J. Wysocki | 86e9466 | 2020-01-17 11:46:24 +0100 | [diff] [blame] | 1385 | /** |
| 1386 | * irtl_2_usec - IRTL to microseconds conversion. |
| 1387 | * @irtl: IRTL MSR value. |
| 1388 | * |
| 1389 | * Translate the IRTL (Interrupt Response Time Limit) MSR value to microseconds. |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1390 | */ |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1391 | static unsigned long long __init irtl_2_usec(unsigned long long irtl) |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1392 | { |
Rafael J. Wysocki | 86e9466 | 2020-01-17 11:46:24 +0100 | [diff] [blame] | 1393 | static const unsigned int irtl_ns_units[] __initconst = { |
| 1394 | 1, 32, 1024, 32768, 1048576, 33554432, 0, 0 |
| 1395 | }; |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1396 | unsigned long long ns; |
| 1397 | |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1398 | if (!irtl) |
| 1399 | return 0; |
| 1400 | |
Jan Beulich | bef4509 | 2016-06-27 00:35:48 -0600 | [diff] [blame] | 1401 | ns = irtl_ns_units[(irtl >> 10) & 0x7]; |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1402 | |
Rafael J. Wysocki | 86e9466 | 2020-01-17 11:46:24 +0100 | [diff] [blame] | 1403 | return div_u64((irtl & 0x3FF) * ns, NSEC_PER_USEC); |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1404 | } |
Rafael J. Wysocki | 86e9466 | 2020-01-17 11:46:24 +0100 | [diff] [blame] | 1405 | |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1406 | /** |
| 1407 | * bxt_idle_state_table_update - Fix up the Broxton idle states table. |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1408 | * |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1409 | * On BXT, trust the IRTL (Interrupt Response Time Limit) MSR to show the |
| 1410 | * definitive maximum latency and use the same value for target_residency. |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1411 | */ |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1412 | static void __init bxt_idle_state_table_update(void) |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1413 | { |
| 1414 | unsigned long long msr; |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1415 | unsigned int usec; |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1416 | |
| 1417 | rdmsrl(MSR_PKGC6_IRTL, msr); |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1418 | usec = irtl_2_usec(msr); |
| 1419 | if (usec) { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1420 | bxt_cstates[2].exit_latency = usec; |
| 1421 | bxt_cstates[2].target_residency = usec; |
| 1422 | } |
| 1423 | |
| 1424 | rdmsrl(MSR_PKGC7_IRTL, msr); |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1425 | usec = irtl_2_usec(msr); |
| 1426 | if (usec) { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1427 | bxt_cstates[3].exit_latency = usec; |
| 1428 | bxt_cstates[3].target_residency = usec; |
| 1429 | } |
| 1430 | |
| 1431 | rdmsrl(MSR_PKGC8_IRTL, msr); |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1432 | usec = irtl_2_usec(msr); |
| 1433 | if (usec) { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1434 | bxt_cstates[4].exit_latency = usec; |
| 1435 | bxt_cstates[4].target_residency = usec; |
| 1436 | } |
| 1437 | |
| 1438 | rdmsrl(MSR_PKGC9_IRTL, msr); |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1439 | usec = irtl_2_usec(msr); |
| 1440 | if (usec) { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1441 | bxt_cstates[5].exit_latency = usec; |
| 1442 | bxt_cstates[5].target_residency = usec; |
| 1443 | } |
| 1444 | |
| 1445 | rdmsrl(MSR_PKGC10_IRTL, msr); |
Jan Beulich | 3451ab3 | 2016-06-27 00:35:12 -0600 | [diff] [blame] | 1446 | usec = irtl_2_usec(msr); |
| 1447 | if (usec) { |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1448 | bxt_cstates[6].exit_latency = usec; |
| 1449 | bxt_cstates[6].target_residency = usec; |
| 1450 | } |
| 1451 | |
| 1452 | } |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1453 | |
| 1454 | /** |
| 1455 | * sklh_idle_state_table_update - Fix up the Sky Lake idle states table. |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1456 | * |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1457 | * On SKL-H (model 0x5e) skip C8 and C9 if C10 is enabled and SGX disabled. |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1458 | */ |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1459 | static void __init sklh_idle_state_table_update(void) |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1460 | { |
| 1461 | unsigned long long msr; |
| 1462 | unsigned int eax, ebx, ecx, edx; |
| 1463 | |
| 1464 | |
| 1465 | /* if PC10 disabled via cmdline intel_idle.max_cstate=7 or shallower */ |
| 1466 | if (max_cstate <= 7) |
| 1467 | return; |
| 1468 | |
| 1469 | /* if PC10 not present in CPUID.MWAIT.EDX */ |
| 1470 | if ((mwait_substates & (0xF << 28)) == 0) |
| 1471 | return; |
| 1472 | |
Len Brown | 6cfb237 | 2017-01-07 23:23:25 -0500 | [diff] [blame] | 1473 | rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr); |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1474 | |
| 1475 | /* PC10 is not enabled in PKG C-state limit */ |
| 1476 | if ((msr & 0xF) != 8) |
| 1477 | return; |
| 1478 | |
| 1479 | ecx = 0; |
| 1480 | cpuid(7, &eax, &ebx, &ecx, &edx); |
| 1481 | |
| 1482 | /* if SGX is present */ |
| 1483 | if (ebx & (1 << 2)) { |
| 1484 | |
Sean Christopherson | 32ad73d | 2019-12-20 20:44:55 -0800 | [diff] [blame] | 1485 | rdmsrl(MSR_IA32_FEAT_CTL, msr); |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1486 | |
| 1487 | /* if SGX is enabled */ |
| 1488 | if (msr & (1 << 18)) |
| 1489 | return; |
| 1490 | } |
| 1491 | |
Rafael J. Wysocki | ba1e78a | 2019-11-21 19:41:51 +0100 | [diff] [blame] | 1492 | skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */ |
| 1493 | skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */ |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1494 | } |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1495 | |
Chen Yu | 6423333 | 2021-05-28 11:20:54 +0800 | [diff] [blame] | 1496 | /** |
| 1497 | * skx_idle_state_table_update - Adjust the Sky Lake/Cascade Lake |
| 1498 | * idle states table. |
| 1499 | */ |
| 1500 | static void __init skx_idle_state_table_update(void) |
| 1501 | { |
| 1502 | unsigned long long msr; |
| 1503 | |
| 1504 | rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr); |
| 1505 | |
| 1506 | /* |
| 1507 | * 000b: C0/C1 (no package C-state support) |
| 1508 | * 001b: C2 |
| 1509 | * 010b: C6 (non-retention) |
| 1510 | * 011b: C6 (retention) |
| 1511 | * 111b: No Package C state limits. |
| 1512 | */ |
| 1513 | if ((msr & 0x7) < 2) { |
| 1514 | /* |
| 1515 | * Uses the CC6 + PC0 latency and 3 times of |
| 1516 | * latency for target_residency if the PC6 |
| 1517 | * is disabled in BIOS. This is consistent |
| 1518 | * with how intel_idle driver uses _CST |
| 1519 | * to set the target_residency. |
| 1520 | */ |
| 1521 | skx_cstates[2].exit_latency = 92; |
| 1522 | skx_cstates[2].target_residency = 276; |
| 1523 | } |
| 1524 | } |
| 1525 | |
Rafael J. Wysocki | 1aefbd7 | 2020-01-10 11:52:32 +0100 | [diff] [blame] | 1526 | static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) |
| 1527 | { |
| 1528 | unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1; |
| 1529 | unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) & |
| 1530 | MWAIT_SUBSTATE_MASK; |
| 1531 | |
| 1532 | /* Ignore the C-state if there are NO sub-states in CPUID for it. */ |
| 1533 | if (num_substates == 0) |
| 1534 | return false; |
| 1535 | |
| 1536 | if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) |
| 1537 | mark_tsc_unstable("TSC halts in idle states deeper than C2"); |
| 1538 | |
| 1539 | return true; |
| 1540 | } |
| 1541 | |
Rafael J. Wysocki | 095928a | 2020-01-10 11:51:22 +0100 | [diff] [blame] | 1542 | static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 1543 | { |
Rafael J. Wysocki | 3d3a1ae | 2020-01-10 11:48:25 +0100 | [diff] [blame] | 1544 | int cstate; |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 1545 | |
Rafael J. Wysocki | 3d3a1ae | 2020-01-10 11:48:25 +0100 | [diff] [blame] | 1546 | switch (boot_cpu_data.x86_model) { |
Dave Hansen | db73c5a | 2016-06-02 17:19:32 -0700 | [diff] [blame] | 1547 | case INTEL_FAM6_IVYBRIDGE_X: |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1548 | ivt_idle_state_table_update(); |
| 1549 | break; |
Dave Hansen | db73c5a | 2016-06-02 17:19:32 -0700 | [diff] [blame] | 1550 | case INTEL_FAM6_ATOM_GOLDMONT: |
Peter Zijlstra | f2c4db1 | 2018-08-07 10:17:27 -0700 | [diff] [blame] | 1551 | case INTEL_FAM6_ATOM_GOLDMONT_PLUS: |
Len Brown | 5dcef69 | 2016-04-06 17:00:47 -0400 | [diff] [blame] | 1552 | bxt_idle_state_table_update(); |
| 1553 | break; |
Peter Zijlstra | c66f78a | 2019-08-27 21:48:21 +0200 | [diff] [blame] | 1554 | case INTEL_FAM6_SKYLAKE: |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1555 | sklh_idle_state_table_update(); |
| 1556 | break; |
Chen Yu | 6423333 | 2021-05-28 11:20:54 +0800 | [diff] [blame] | 1557 | case INTEL_FAM6_SKYLAKE_X: |
| 1558 | skx_idle_state_table_update(); |
| 1559 | break; |
Len Brown | 0138d8f | 2014-04-04 01:21:07 -0400 | [diff] [blame] | 1560 | } |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 1561 | |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 1562 | for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) { |
Rafael J. Wysocki | 9f3d6da | 2019-12-13 09:55:52 +0100 | [diff] [blame] | 1563 | unsigned int mwait_hint; |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 1564 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1565 | if (intel_idle_max_cstate_reached(cstate)) |
| 1566 | break; |
| 1567 | |
Rafael J. Wysocki | 9f3d6da | 2019-12-13 09:55:52 +0100 | [diff] [blame] | 1568 | if (!cpuidle_state_table[cstate].enter && |
| 1569 | !cpuidle_state_table[cstate].enter_s2idle) |
Len Brown | e022e7e | 2013-02-01 23:37:30 -0500 | [diff] [blame] | 1570 | break; |
| 1571 | |
Rafael J. Wysocki | 9f3d6da | 2019-12-13 09:55:52 +0100 | [diff] [blame] | 1572 | /* If marked as unusable, skip this state. */ |
Rafael J. Wysocki | ba1e78a | 2019-11-21 19:41:51 +0100 | [diff] [blame] | 1573 | if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) { |
Joe Perches | 654d08a | 2017-06-09 12:29:20 -0700 | [diff] [blame] | 1574 | pr_debug("state %s is disabled\n", |
| 1575 | cpuidle_state_table[cstate].name); |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1576 | continue; |
| 1577 | } |
| 1578 | |
Rafael J. Wysocki | 9f3d6da | 2019-12-13 09:55:52 +0100 | [diff] [blame] | 1579 | mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags); |
| 1580 | if (!intel_idle_verify_cstate(mwait_hint)) |
| 1581 | continue; |
Len Brown | d70e28f | 2016-03-13 00:33:48 -0500 | [diff] [blame] | 1582 | |
Rafael J. Wysocki | 9f3d6da | 2019-12-13 09:55:52 +0100 | [diff] [blame] | 1583 | /* Structure copy. */ |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1584 | drv->states[drv->state_count] = cpuidle_state_table[cstate]; |
| 1585 | |
Rafael J. Wysocki | 4dcb78e | 2020-02-03 11:57:18 +0100 | [diff] [blame] | 1586 | if ((disabled_states_mask & BIT(drv->state_count)) || |
| 1587 | ((icpu->use_acpi || force_use_acpi) && |
| 1588 | intel_idle_off_by_default(mwait_hint) && |
| 1589 | !(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1590 | drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF; |
| 1591 | |
Peter Zijlstra | 6e1d2bc | 2020-11-20 11:28:35 +0100 | [diff] [blame] | 1592 | if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count])) |
| 1593 | drv->states[drv->state_count].flags |= CPUIDLE_FLAG_TIMER_STOP; |
| 1594 | |
Rafael J. Wysocki | bff8e60 | 2019-12-13 09:56:21 +0100 | [diff] [blame] | 1595 | drv->state_count++; |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 1596 | } |
| 1597 | |
Len Brown | 8c058d53 | 2014-07-31 15:21:24 -0400 | [diff] [blame] | 1598 | if (icpu->byt_auto_demotion_disable_flag) { |
| 1599 | wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0); |
| 1600 | wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0); |
| 1601 | } |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 1602 | } |
| 1603 | |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1604 | /** |
| 1605 | * intel_idle_cpuidle_driver_init - Create the list of available idle states. |
| 1606 | * @drv: cpuidle driver structure to initialize. |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1607 | */ |
Rafael J. Wysocki | 3d3a1ae | 2020-01-10 11:48:25 +0100 | [diff] [blame] | 1608 | static void __init intel_idle_cpuidle_driver_init(struct cpuidle_driver *drv) |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1609 | { |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1610 | cpuidle_poll_state_init(drv); |
Rafael J. Wysocki | 4dcb78e | 2020-02-03 11:57:18 +0100 | [diff] [blame] | 1611 | |
| 1612 | if (disabled_states_mask & BIT(0)) |
| 1613 | drv->states[0].flags |= CPUIDLE_FLAG_OFF; |
| 1614 | |
Rafael J. Wysocki | 1873495 | 2019-12-13 09:56:01 +0100 | [diff] [blame] | 1615 | drv->state_count = 1; |
| 1616 | |
| 1617 | if (icpu) |
| 1618 | intel_idle_init_cstates_icpu(drv); |
| 1619 | else |
| 1620 | intel_idle_init_cstates_acpi(drv); |
| 1621 | } |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 1622 | |
Rafael J. Wysocki | 1aefbd7 | 2020-01-10 11:52:32 +0100 | [diff] [blame] | 1623 | static void auto_demotion_disable(void) |
| 1624 | { |
| 1625 | unsigned long long msr_bits; |
| 1626 | |
| 1627 | rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 1628 | msr_bits &= ~auto_demotion_disable_flags; |
Rafael J. Wysocki | 1aefbd7 | 2020-01-10 11:52:32 +0100 | [diff] [blame] | 1629 | wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); |
| 1630 | } |
| 1631 | |
| 1632 | static void c1e_promotion_disable(void) |
| 1633 | { |
| 1634 | unsigned long long msr_bits; |
| 1635 | |
| 1636 | rdmsrl(MSR_IA32_POWER_CTL, msr_bits); |
| 1637 | msr_bits &= ~0x2; |
| 1638 | wrmsrl(MSR_IA32_POWER_CTL, msr_bits); |
| 1639 | } |
| 1640 | |
Rafael J. Wysocki | 6eacb15 | 2020-02-06 18:45:29 +0100 | [diff] [blame] | 1641 | /** |
| 1642 | * intel_idle_cpu_init - Register the target CPU with the cpuidle core. |
| 1643 | * @cpu: CPU to initialize. |
| 1644 | * |
| 1645 | * Register a cpuidle device object for @cpu and update its MSRs in accordance |
| 1646 | * with the processor model flags. |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1647 | */ |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1648 | static int intel_idle_cpu_init(unsigned int cpu) |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1649 | { |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1650 | struct cpuidle_device *dev; |
| 1651 | |
Thomas Renninger | 65b7f83 | 2012-01-17 22:40:08 +0100 | [diff] [blame] | 1652 | dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu); |
Thomas Renninger | 65b7f83 | 2012-01-17 22:40:08 +0100 | [diff] [blame] | 1653 | dev->cpu = cpu; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1654 | |
Thomas Renninger | 65b7f83 | 2012-01-17 22:40:08 +0100 | [diff] [blame] | 1655 | if (cpuidle_register_device(dev)) { |
Joe Perches | 654d08a | 2017-06-09 12:29:20 -0700 | [diff] [blame] | 1656 | pr_debug("cpuidle_register_device %d failed!\n", cpu); |
Thomas Renninger | 65b7f83 | 2012-01-17 22:40:08 +0100 | [diff] [blame] | 1657 | return -EIO; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1658 | } |
| 1659 | |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 1660 | if (auto_demotion_disable_flags) |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1661 | auto_demotion_disable(); |
Thomas Renninger | 65b7f83 | 2012-01-17 22:40:08 +0100 | [diff] [blame] | 1662 | |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 1663 | if (disable_promotion_to_c1e) |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1664 | c1e_promotion_disable(); |
| 1665 | |
| 1666 | return 0; |
| 1667 | } |
| 1668 | |
| 1669 | static int intel_idle_cpu_online(unsigned int cpu) |
| 1670 | { |
| 1671 | struct cpuidle_device *dev; |
| 1672 | |
Rafael J. Wysocki | dab2017 | 2020-06-29 13:58:28 +0200 | [diff] [blame] | 1673 | if (!boot_cpu_has(X86_FEATURE_ARAT)) |
Rafael J. Wysocki | cbd2c4c | 2020-01-10 11:43:23 +0100 | [diff] [blame] | 1674 | tick_broadcast_enable(); |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1675 | |
| 1676 | /* |
| 1677 | * Some systems can hotplug a cpu at runtime after |
| 1678 | * the kernel has booted, we have to initialize the |
| 1679 | * driver in this case |
| 1680 | */ |
| 1681 | dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu); |
| 1682 | if (!dev->registered) |
| 1683 | return intel_idle_cpu_init(cpu); |
Bartlomiej Zolnierkiewicz | dbf87ab | 2013-12-20 19:47:28 +0100 | [diff] [blame] | 1684 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1685 | return 0; |
| 1686 | } |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1687 | |
Rafael J. Wysocki | 0755a9b | 2020-01-10 11:49:58 +0100 | [diff] [blame] | 1688 | /** |
| 1689 | * intel_idle_cpuidle_devices_uninit - Unregister all cpuidle devices. |
| 1690 | */ |
| 1691 | static void __init intel_idle_cpuidle_devices_uninit(void) |
| 1692 | { |
| 1693 | int i; |
| 1694 | |
| 1695 | for_each_online_cpu(i) |
| 1696 | cpuidle_unregister_device(per_cpu_ptr(intel_idle_cpuidle_devices, i)); |
| 1697 | } |
| 1698 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1699 | static int __init intel_idle_init(void) |
| 1700 | { |
Rafael J. Wysocki | a6c86e3 | 2020-01-10 11:44:58 +0100 | [diff] [blame] | 1701 | const struct x86_cpu_id *id; |
| 1702 | unsigned int eax, ebx, ecx; |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1703 | int retval; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1704 | |
Thomas Renninger | d189604 | 2010-11-03 17:06:14 +0100 | [diff] [blame] | 1705 | /* Do not load intel_idle at all for now if idle= is passed */ |
| 1706 | if (boot_option_idle_override != IDLE_NO_OVERRIDE) |
| 1707 | return -ENODEV; |
| 1708 | |
Rafael J. Wysocki | a6c86e3 | 2020-01-10 11:44:58 +0100 | [diff] [blame] | 1709 | if (max_cstate == 0) { |
| 1710 | pr_debug("disabled\n"); |
| 1711 | return -EPERM; |
| 1712 | } |
| 1713 | |
| 1714 | id = x86_match_cpu(intel_idle_ids); |
| 1715 | if (id) { |
| 1716 | if (!boot_cpu_has(X86_FEATURE_MWAIT)) { |
| 1717 | pr_debug("Please enable MWAIT in BIOS SETUP\n"); |
| 1718 | return -ENODEV; |
| 1719 | } |
| 1720 | } else { |
| 1721 | id = x86_match_cpu(intel_mwait_ids); |
| 1722 | if (!id) |
| 1723 | return -ENODEV; |
| 1724 | } |
| 1725 | |
| 1726 | if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF) |
| 1727 | return -ENODEV; |
| 1728 | |
| 1729 | cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates); |
| 1730 | |
| 1731 | if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) || |
| 1732 | !(ecx & CPUID5_ECX_INTERRUPT_BREAK) || |
| 1733 | !mwait_substates) |
| 1734 | return -ENODEV; |
| 1735 | |
| 1736 | pr_debug("MWAIT substates: 0x%x\n", mwait_substates); |
| 1737 | |
| 1738 | icpu = (const struct idle_cpu *)id->driver_data; |
| 1739 | if (icpu) { |
| 1740 | cpuidle_state_table = icpu->state_table; |
Rafael J. Wysocki | 7f843dd | 2020-02-06 18:41:24 +0100 | [diff] [blame] | 1741 | auto_demotion_disable_flags = icpu->auto_demotion_disable_flags; |
| 1742 | disable_promotion_to_c1e = icpu->disable_promotion_to_c1e; |
Rafael J. Wysocki | 3a5be9b | 2020-02-03 11:57:08 +0100 | [diff] [blame] | 1743 | if (icpu->use_acpi || force_use_acpi) |
Rafael J. Wysocki | a6c86e3 | 2020-01-10 11:44:58 +0100 | [diff] [blame] | 1744 | intel_idle_acpi_cst_extract(); |
| 1745 | } else if (!intel_idle_acpi_cst_extract()) { |
| 1746 | return -ENODEV; |
| 1747 | } |
| 1748 | |
| 1749 | pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n", |
| 1750 | boot_cpu_data.x86_model); |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1751 | |
Richard Cochran | e9df69c | 2016-04-06 17:00:52 -0400 | [diff] [blame] | 1752 | intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device); |
Rafael J. Wysocki | 533da74 | 2020-01-10 11:45:49 +0100 | [diff] [blame] | 1753 | if (!intel_idle_cpuidle_devices) |
Richard Cochran | e9df69c | 2016-04-06 17:00:52 -0400 | [diff] [blame] | 1754 | return -ENOMEM; |
| 1755 | |
Rafael J. Wysocki | 3d3a1ae | 2020-01-10 11:48:25 +0100 | [diff] [blame] | 1756 | intel_idle_cpuidle_driver_init(&intel_idle_driver); |
| 1757 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1758 | retval = cpuidle_register_driver(&intel_idle_driver); |
| 1759 | if (retval) { |
Konrad Rzeszutek Wilk | 3735d52 | 2012-08-16 22:06:55 +0200 | [diff] [blame] | 1760 | struct cpuidle_driver *drv = cpuidle_get_driver(); |
Joe Perches | 654d08a | 2017-06-09 12:29:20 -0700 | [diff] [blame] | 1761 | printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"), |
| 1762 | drv ? drv->name : "none"); |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1763 | goto init_driver_fail; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1764 | } |
| 1765 | |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1766 | retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online", |
| 1767 | intel_idle_cpu_online, NULL); |
| 1768 | if (retval < 0) |
| 1769 | goto hp_setup_fail; |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1770 | |
Rafael J. Wysocki | 40ab82e | 2020-02-06 18:40:54 +0100 | [diff] [blame] | 1771 | pr_debug("Local APIC timer is reliable in %s\n", |
Rafael J. Wysocki | dab2017 | 2020-06-29 13:58:28 +0200 | [diff] [blame] | 1772 | boot_cpu_has(X86_FEATURE_ARAT) ? "all C-states" : "C1"); |
Richard Cochran | 2259a81 | 2016-04-06 17:00:54 -0400 | [diff] [blame] | 1773 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1774 | return 0; |
Sebastian Andrzej Siewior | fb1013a | 2016-11-29 10:51:43 +0100 | [diff] [blame] | 1775 | |
| 1776 | hp_setup_fail: |
| 1777 | intel_idle_cpuidle_devices_uninit(); |
| 1778 | cpuidle_unregister_driver(&intel_idle_driver); |
| 1779 | init_driver_fail: |
| 1780 | free_percpu(intel_idle_cpuidle_devices); |
| 1781 | return retval; |
| 1782 | |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1783 | } |
Paul Gortmaker | 02c4fae | 2016-06-17 01:28:33 -0400 | [diff] [blame] | 1784 | device_initcall(intel_idle_init); |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1785 | |
Paul Gortmaker | 02c4fae | 2016-06-17 01:28:33 -0400 | [diff] [blame] | 1786 | /* |
| 1787 | * We are not really modular, but we used to support that. Meaning we also |
| 1788 | * support "intel_idle.max_cstate=..." at boot and also a read-only export of |
| 1789 | * it at /sys/module/intel_idle/parameters/max_cstate -- so using module_param |
| 1790 | * is the easiest way (currently) to continue doing that. |
| 1791 | */ |
Len Brown | 2671717 | 2010-03-08 14:07:30 -0500 | [diff] [blame] | 1792 | module_param(max_cstate, int, 0444); |
Rafael J. Wysocki | 4dcb78e | 2020-02-03 11:57:18 +0100 | [diff] [blame] | 1793 | /* |
| 1794 | * The positions of the bits that are set in this number are the indices of the |
| 1795 | * idle states to be disabled by default (as reflected by the names of the |
| 1796 | * corresponding idle state directories in sysfs, "state0", "state1" ... |
| 1797 | * "state<i>" ..., where <i> is the index of the given state). |
| 1798 | */ |
| 1799 | module_param_named(states_off, disabled_states_mask, uint, 0444); |
| 1800 | MODULE_PARM_DESC(states_off, "Mask of disabled idle states"); |