]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
x86: handle PAT more like other CPU features
authorH. Peter Anvin <hpa@linux.intel.com>
Fri, 23 Jan 2009 00:17:05 +0000 (16:17 -0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Sat, 24 Jan 2009 02:07:45 +0000 (18:07 -0800)
Impact: Cleanup

When PAT was originally introduced, it was handled specially for a few
reasons:

- PAT bugs are hard to track down, so we wanted to maintain a
  whitelist of CPUs.
- The i386 and x86-64 CPUID code was not yet unified.

Both of these are now obsolete, so handle PAT like any other features,
including ordinary feature blacklisting due to known bugs.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/pat.h
arch/x86/kernel/cpu/addon_cpuid_features.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/intel.c
arch/x86/mm/pat.c

index b8493b3b98901c811add567762a22b73aaa85c9a..9709fdff6615a0ed43930551fc345a3c64f19b87 100644 (file)
@@ -5,10 +5,8 @@
 
 #ifdef CONFIG_X86_PAT
 extern int pat_enabled;
-extern void validate_pat_support(struct cpuinfo_x86 *c);
 #else
 static const int pat_enabled;
-static inline void validate_pat_support(struct cpuinfo_x86 *c) { }
 #endif
 
 extern void pat_init(void);
@@ -17,6 +15,4 @@ extern int reserve_memtype(u64 start, u64 end,
                unsigned long req_type, unsigned long *ret_type);
 extern int free_memtype(u64 start, u64 end);
 
-extern void pat_disable(char *reason);
-
 #endif /* _ASM_X86_PAT_H */
index 2cf23634b6d94d60e239d3f63cd9d4d21526b3fd..4e581fdc0a5a3b7b278cbb77d50eabc1d0f3caa0 100644 (file)
@@ -143,37 +143,3 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
        return;
 #endif
 }
-
-#ifdef CONFIG_X86_PAT
-void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
-{
-       if (!cpu_has_pat)
-               pat_disable("PAT not supported by CPU.");
-
-       switch (c->x86_vendor) {
-       case X86_VENDOR_INTEL:
-               /*
-                * There is a known erratum on Pentium III and Core Solo
-                * and Core Duo CPUs.
-                * " Page with PAT set to WC while associated MTRR is UC
-                *   may consolidate to UC "
-                * Because of this erratum, it is better to stick with
-                * setting WC in MTRR rather than using PAT on these CPUs.
-                *
-                * Enable PAT WC only on P4, Core 2 or later CPUs.
-                */
-               if (c->x86 > 0x6 || (c->x86 == 6 && c->x86_model >= 15))
-                       return;
-
-               pat_disable("PAT WC disabled due to known CPU erratum.");
-               return;
-
-       case X86_VENDOR_AMD:
-       case X86_VENDOR_CENTAUR:
-       case X86_VENDOR_TRANSMETA:
-               return;
-       }
-
-       pat_disable("PAT disabled. Not yet verified on this CPU type.");
-}
-#endif
index 83492b1f93b11c5e0b851300ffdb3e314eaacc9e..0f8656361e04f2b7ac74ba086709080f387e8da6 100644 (file)
@@ -570,8 +570,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
        if (this_cpu->c_early_init)
                this_cpu->c_early_init(c);
 
-       validate_pat_support(c);
-
 #ifdef CONFIG_SMP
        c->cpu_index = boot_cpu_id;
 #endif
index 8ea6929e974c090142ed0d3744167792ce04d777..20ce03acf04bd329ef21e1a649ed99ed152e716b 100644 (file)
@@ -50,6 +50,18 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
                set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
        }
 
+       /*
+        * There is a known erratum on Pentium III and Core Solo
+        * and Core Duo CPUs.
+        * " Page with PAT set to WC while associated MTRR is UC
+        *   may consolidate to UC "
+        * Because of this erratum, it is better to stick with
+        * setting WC in MTRR rather than using PAT on these CPUs.
+        *
+        * Enable PAT WC only on P4, Core 2 or later CPUs.
+        */
+       if (c->x86 == 6 && c->x86_model < 15)
+               clear_cpu_cap(c, X86_FEATURE_PAT);
 }
 
 #ifdef CONFIG_X86_32
index 8b08fb955274148454a2acaa538c78215322e655..430cb44dd3f4b03864972ad3e143ff9f80e5604b 100644 (file)
@@ -30,7 +30,7 @@
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_enabled = 1;
 
-void __cpuinit pat_disable(char *reason)
+void __cpuinit pat_disable(const char *reason)
 {
        pat_enabled = 0;
        printk(KERN_INFO "%s\n", reason);
@@ -42,6 +42,11 @@ static int __init nopat(char *str)
        return 0;
 }
 early_param("nopat", nopat);
+#else
+static inline void pat_disable(const char *reason)
+{
+       (void)reason;
+}
 #endif
 
 
@@ -78,16 +83,20 @@ void pat_init(void)
        if (!pat_enabled)
                return;
 
-       /* Paranoia check. */
-       if (!cpu_has_pat && boot_pat_state) {
-               /*
-                * If this happens we are on a secondary CPU, but
-                * switched to PAT on the boot CPU. We have no way to
-                * undo PAT.
-                */
-               printk(KERN_ERR "PAT enabled, "
-                      "but not supported by secondary CPU\n");
-               BUG();
+       if (!cpu_has_pat) {
+               if (!boot_pat_state) {
+                       pat_disable("PAT not supported by CPU.");
+                       return;
+               } else {
+                       /*
+                        * If this happens we are on a secondary CPU, but
+                        * switched to PAT on the boot CPU. We have no way to
+                        * undo PAT.
+                        */
+                       printk(KERN_ERR "PAT enabled, "
+                              "but not supported by secondary CPU\n");
+                       BUG();
+               }
        }
 
        /* Set PWT to Write-Combining. All other bits stay the same */