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