diff options
| author | Venki Pallipadi <venkatesh.pallipadi@intel.com> | 2008-11-17 19:11:37 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-12-16 15:02:50 -0500 |
| commit | 40fb17152c50a69dc304dd632131c2f41281ce44 (patch) | |
| tree | ae4ab9fc72183968d4e3ff5c5d07cf7573954455 | |
| parent | 7e91a122b11bb250d08ab125afd2c232c87502e1 (diff) | |
x86: support always running TSC on Intel CPUs
Impact: reward non-stop TSCs with good TSC-based clocksources, etc.
Add support for CPUID_0x80000007_Bit8 on Intel CPUs as well. This bit means
that the TSC is invariant with C/P/T states and always runs at constant
frequency.
With Intel CPUs, we have 3 classes
* CPUs where TSC runs at constant rate and does not stop n C-states
* CPUs where TSC runs at constant rate, but will stop in deep C-states
* CPUs where TSC rate will vary based on P/T-states and TSC will stop in deep
C-states.
To cover these 3, one feature bit (CONSTANT_TSC) is not enough. So, add a
second bit (NONSTOP_TSC). CONSTANT_TSC indicates that the TSC runs at
constant frequency irrespective of P/T-states, and NONSTOP_TSC indicates
that TSC does not stop in deep C-states.
CPUID_0x8000000_Bit8 indicates both these feature bit can be set.
We still have CONSTANT_TSC _set_ and NONSTOP_TSC _not_set_ on some older Intel
CPUs, based on model checks. We can use TSC on such CPUs for time, as long as
those CPUs do not support/enter deep C-states.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/x86/kernel/cpu/amd.c | 9 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel.c | 10 | ||||
| -rw-r--r-- | arch/x86/kernel/process.c | 2 | ||||
| -rw-r--r-- | drivers/acpi/processor_idle.c | 6 |
4 files changed, 21 insertions, 6 deletions
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 8f1e31db2ad5..7c878f6aa919 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -283,9 +283,14 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) | |||
| 283 | { | 283 | { |
| 284 | early_init_amd_mc(c); | 284 | early_init_amd_mc(c); |
| 285 | 285 | ||
| 286 | /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */ | 286 | /* |
| 287 | if (c->x86_power & (1<<8)) | 287 | * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate |
| 288 | * with P/T states and does not stop in deep C-states | ||
| 289 | */ | ||
| 290 | if (c->x86_power & (1 << 8)) { | ||
| 288 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | 291 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); |
| 292 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); | ||
| 293 | } | ||
| 289 | 294 | ||
| 290 | #ifdef CONFIG_X86_64 | 295 | #ifdef CONFIG_X86_64 |
| 291 | set_cpu_cap(c, X86_FEATURE_SYSCALL32); | 296 | set_cpu_cap(c, X86_FEATURE_SYSCALL32); |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index cce0b6118d55..caec59437a22 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
| @@ -41,6 +41,16 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) | |||
| 41 | if (c->x86 == 15 && c->x86_cache_alignment == 64) | 41 | if (c->x86 == 15 && c->x86_cache_alignment == 64) |
| 42 | c->x86_cache_alignment = 128; | 42 | c->x86_cache_alignment = 128; |
| 43 | #endif | 43 | #endif |
| 44 | |||
| 45 | /* | ||
| 46 | * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate | ||
| 47 | * with P/T states and does not stop in deep C-states | ||
| 48 | */ | ||
| 49 | if (c->x86_power & (1 << 8)) { | ||
| 50 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | ||
| 51 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); | ||
| 52 | } | ||
| 53 | |||
| 44 | } | 54 | } |
| 45 | 55 | ||
| 46 | #ifdef CONFIG_X86_32 | 56 | #ifdef CONFIG_X86_32 |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index c622772744d8..18c70fedba32 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
| @@ -270,7 +270,7 @@ static void c1e_idle(void) | |||
| 270 | rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi); | 270 | rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi); |
| 271 | if (lo & K8_INTP_C1E_ACTIVE_MASK) { | 271 | if (lo & K8_INTP_C1E_ACTIVE_MASK) { |
| 272 | c1e_detected = 1; | 272 | c1e_detected = 1; |
| 273 | if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) | 273 | if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) |
| 274 | mark_tsc_unstable("TSC halt in AMD C1E"); | 274 | mark_tsc_unstable("TSC halt in AMD C1E"); |
| 275 | printk(KERN_INFO "System has AMD C1E enabled\n"); | 275 | printk(KERN_INFO "System has AMD C1E enabled\n"); |
| 276 | set_cpu_cap(&boot_cpu_data, X86_FEATURE_AMDC1E); | 276 | set_cpu_cap(&boot_cpu_data, X86_FEATURE_AMDC1E); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 5f8d746a9b81..38aca048e951 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
| @@ -374,15 +374,15 @@ static int tsc_halts_in_c(int state) | |||
| 374 | { | 374 | { |
| 375 | switch (boot_cpu_data.x86_vendor) { | 375 | switch (boot_cpu_data.x86_vendor) { |
| 376 | case X86_VENDOR_AMD: | 376 | case X86_VENDOR_AMD: |
| 377 | case X86_VENDOR_INTEL: | ||
| 377 | /* | 378 | /* |
| 378 | * AMD Fam10h TSC will tick in all | 379 | * AMD Fam10h TSC will tick in all |
| 379 | * C/P/S0/S1 states when this bit is set. | 380 | * C/P/S0/S1 states when this bit is set. |
| 380 | */ | 381 | */ |
| 381 | if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) | 382 | if (boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) |
| 382 | return 0; | 383 | return 0; |
| 384 | |||
| 383 | /*FALL THROUGH*/ | 385 | /*FALL THROUGH*/ |
| 384 | case X86_VENDOR_INTEL: | ||
| 385 | /* Several cases known where TSC halts in C2 too */ | ||
| 386 | default: | 386 | default: |
| 387 | return state > ACPI_STATE_C1; | 387 | return state > ACPI_STATE_C1; |
| 388 | } | 388 | } |
