diff options
author | Len Brown <len.brown@intel.com> | 2011-01-18 20:48:27 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-02-17 17:08:46 -0500 |
commit | 14796fca2bd22acc73dd0887248d003b0f441d08 (patch) | |
tree | 45281c00405077fe1a099d585588d2173ee90fea /drivers/idle/intel_idle.c | |
parent | 100b33c8bd8a3235fd0b7948338d6cbb3db3c63d (diff) |
intel_idle: disable NHM/WSM HW C-state auto-demotion
Hardware C-state auto-demotion is a mechanism where the HW overrides
the OS C-state request, instead demoting to a shallower state,
which is less expensive, but saves less power.
Modern Linux should generally get exactly the states it requests.
In particular, when a CPU is taken off-line, it must not be demoted, else
it can prevent the entire package from reaching deep C-states.
https://bugzilla.kernel.org/show_bug.cgi?id=25252
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/idle/intel_idle.c')
-rw-r--r-- | drivers/idle/intel_idle.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 1fa091e05690..32b25bcaf865 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/notifier.h> | 62 | #include <linux/notifier.h> |
63 | #include <linux/cpu.h> | 63 | #include <linux/cpu.h> |
64 | #include <asm/mwait.h> | 64 | #include <asm/mwait.h> |
65 | #include <asm/msr.h> | ||
65 | 66 | ||
66 | #define INTEL_IDLE_VERSION "0.4" | 67 | #define INTEL_IDLE_VERSION "0.4" |
67 | #define PREFIX "intel_idle: " | 68 | #define PREFIX "intel_idle: " |
@@ -85,6 +86,12 @@ static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state); | |||
85 | static struct cpuidle_state *cpuidle_state_table; | 86 | static struct cpuidle_state *cpuidle_state_table; |
86 | 87 | ||
87 | /* | 88 | /* |
89 | * Hardware C-state auto-demotion may not always be optimal. | ||
90 | * Indicate which enable bits to clear here. | ||
91 | */ | ||
92 | static unsigned long long auto_demotion_disable_flags; | ||
93 | |||
94 | /* | ||
88 | * Set this flag for states where the HW flushes the TLB for us | 95 | * Set this flag for states where the HW flushes the TLB for us |
89 | * and so we don't need cross-calls to keep it consistent. | 96 | * and so we don't need cross-calls to keep it consistent. |
90 | * If this flag is set, SW flushes the TLB, so even if the | 97 | * If this flag is set, SW flushes the TLB, so even if the |
@@ -281,6 +288,15 @@ static struct notifier_block setup_broadcast_notifier = { | |||
281 | .notifier_call = setup_broadcast_cpuhp_notify, | 288 | .notifier_call = setup_broadcast_cpuhp_notify, |
282 | }; | 289 | }; |
283 | 290 | ||
291 | static void auto_demotion_disable(void *dummy) | ||
292 | { | ||
293 | unsigned long long msr_bits; | ||
294 | |||
295 | rdmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits); | ||
296 | msr_bits &= ~auto_demotion_disable_flags; | ||
297 | wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits); | ||
298 | } | ||
299 | |||
284 | /* | 300 | /* |
285 | * intel_idle_probe() | 301 | * intel_idle_probe() |
286 | */ | 302 | */ |
@@ -324,6 +340,8 @@ static int intel_idle_probe(void) | |||
324 | case 0x25: /* Westmere */ | 340 | case 0x25: /* Westmere */ |
325 | case 0x2C: /* Westmere */ | 341 | case 0x2C: /* Westmere */ |
326 | cpuidle_state_table = nehalem_cstates; | 342 | cpuidle_state_table = nehalem_cstates; |
343 | auto_demotion_disable_flags = | ||
344 | (NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE); | ||
327 | break; | 345 | break; |
328 | 346 | ||
329 | case 0x1C: /* 28 - Atom Processor */ | 347 | case 0x1C: /* 28 - Atom Processor */ |
@@ -436,6 +454,8 @@ static int intel_idle_cpuidle_devices_init(void) | |||
436 | return -EIO; | 454 | return -EIO; |
437 | } | 455 | } |
438 | } | 456 | } |
457 | if (auto_demotion_disable_flags) | ||
458 | smp_call_function(auto_demotion_disable, NULL, 1); | ||
439 | 459 | ||
440 | return 0; | 460 | return 0; |
441 | } | 461 | } |