]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86, hotplug: In the MWAIT case of play_dead, CLFLUSH the cache line
authorH. Peter Anvin <hpa@linux.intel.com>
Mon, 20 Sep 2010 20:04:45 +0000 (13:04 -0700)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Sun, 17 Apr 2011 20:16:05 +0000 (16:16 -0400)
commit ce5f68246bf2385d6174856708d0b746dc378f20 upstream.

When we're using MWAIT for play_dead, explicitly CLFLUSH the cache
line before executing MONITOR.  This is a potential workaround for the
Xeon 7400 erratum AAI65 after having a spurious wakeup and returning
around the loop.  "Potential" here because it is not certain that that
erratum could actually trigger; however, the CLFLUSH should be
harmless.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Acked-by: Venkatesh Pallipadi <venki@google.com>
Cc: Asit Mallick <asit.k.mallick@intel.com>
Cc: Arjan van de Ven <arjan@linux.kernel.org>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
arch/x86/kernel/smpboot.c

index b283dbfe939030a08e6c4eb5f6165e1e41d67a1d..9a4fdc5dd1069fae0b53d1347936d9b0280e103a 100644 (file)
@@ -1371,9 +1371,12 @@ static inline void mwait_play_dead(void)
        unsigned int highest_cstate = 0;
        unsigned int highest_subcstate = 0;
        int i;
+       void *mwait_ptr;
 
        if (!cpu_has(&current_cpu_data, X86_FEATURE_MWAIT))
                return;
+       if (!cpu_has(&current_cpu_data, X86_FEATURE_CLFLSH))
+               return;
        if (current_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
                return;
 
@@ -1399,10 +1402,25 @@ static inline void mwait_play_dead(void)
                        (highest_subcstate - 1);
        }
 
+       /*
+        * This should be a memory location in a cache line which is
+        * unlikely to be touched by other processors.  The actual
+        * content is immaterial as it is not actually modified in any way.
+        */
+       mwait_ptr = &current_thread_info()->flags;
+
        wbinvd();
 
        while (1) {
-               __monitor(&current_thread_info()->flags, 0, 0);
+               /*
+                * The CLFLUSH is a workaround for erratum AAI65 for
+                * the Xeon 7400 series.  It's not clear it is actually
+                * needed, but it should be harmless in either case.
+                * The WBINVD is insufficient due to the spurious-wakeup
+                * case where we return around the loop.
+                */
+               clflush(mwait_ptr);
+               __monitor(mwait_ptr, 0, 0);
                mb();
                __mwait(eax, 0);
        }