aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/processor.h1
-rw-r--r--arch/x86/kernel/cpu/amd.c5
-rw-r--r--arch/x86/kernel/process.c39
3 files changed, 8 insertions, 37 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 5084c2f5ac20..eebdc1fde3d1 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -1029,6 +1029,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
1029 * AMD errata checking 1029 * AMD errata checking
1030 */ 1030 */
1031#ifdef CONFIG_CPU_SUP_AMD 1031#ifdef CONFIG_CPU_SUP_AMD
1032extern const int amd_erratum_400[];
1032extern bool cpu_has_amd_erratum(const int *); 1033extern bool cpu_has_amd_erratum(const int *);
1033 1034
1034#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 } 1035#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 80665410b064..a62a4ae7a11a 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -628,6 +628,11 @@ cpu_dev_register(amd_cpu_dev);
628 * AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0)); 628 * AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
629 */ 629 */
630 630
631const int amd_erratum_400[] =
632 AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
633 AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));
634
635
631bool cpu_has_amd_erratum(const int *erratum) 636bool cpu_has_amd_erratum(const int *erratum)
632{ 637{
633 struct cpuinfo_x86 *cpu = &current_cpu_data; 638 struct cpuinfo_x86 *cpu = &current_cpu_data;
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index e7e35219b32f..553b02f13094 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -525,42 +525,6 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
525 return (edx & MWAIT_EDX_C1); 525 return (edx & MWAIT_EDX_C1);
526} 526}
527 527
528/*
529 * Check for AMD CPUs, where APIC timer interrupt does not wake up CPU from C1e.
530 * For more information see
531 * - Erratum #400 for NPT family 0xf and family 0x10 CPUs
532 * - Erratum #365 for family 0x11 (not affected because C1e not in use)
533 */
534static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
535{
536 u64 val;
537 if (c->x86_vendor != X86_VENDOR_AMD)
538 goto no_c1e_idle;
539
540 /* Family 0x0f models < rev F do not have C1E */
541 if (c->x86 == 0x0F && c->x86_model >= 0x40)
542 return 1;
543
544 if (c->x86 == 0x10) {
545 /*
546 * check OSVW bit for CPUs that are not affected
547 * by erratum #400
548 */
549 if (cpu_has(c, X86_FEATURE_OSVW)) {
550 rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
551 if (val >= 2) {
552 rdmsrl(MSR_AMD64_OSVW_STATUS, val);
553 if (!(val & BIT(1)))
554 goto no_c1e_idle;
555 }
556 }
557 return 1;
558 }
559
560no_c1e_idle:
561 return 0;
562}
563
564static cpumask_var_t c1e_mask; 528static cpumask_var_t c1e_mask;
565static int c1e_detected; 529static int c1e_detected;
566 530
@@ -638,7 +602,8 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
638 */ 602 */
639 printk(KERN_INFO "using mwait in idle threads.\n"); 603 printk(KERN_INFO "using mwait in idle threads.\n");
640 pm_idle = mwait_idle; 604 pm_idle = mwait_idle;
641 } else if (check_c1e_idle(c)) { 605 } else if (cpu_has_amd_erratum(amd_erratum_400)) {
606 /* E400: APIC timer interrupt does not wake up CPU from C1e */
642 printk(KERN_INFO "using C1E aware idle routine\n"); 607 printk(KERN_INFO "using C1E aware idle routine\n");
643 pm_idle = c1e_idle; 608 pm_idle = c1e_idle;
644 } else 609 } else