]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - arch/x86/kernel/fpu/init.c
Merge branches 'pm-core', 'pm-qos', 'pm-domains' and 'pm-opp'
[linux.git] / arch / x86 / kernel / fpu / init.c
index 60dece392b3a7ab0ef67ce57edc10f79332686eb..19bdd1bf81607cfe06d57bf4d4e0b42b9088d691 100644 (file)
@@ -48,13 +48,7 @@ void fpu__init_cpu(void)
        fpu__init_cpu_xstate();
 }
 
-/*
- * The earliest FPU detection code.
- *
- * Set the X86_FEATURE_FPU CPU-capability bit based on
- * trying to execute an actual sequence of FPU instructions:
- */
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+static bool fpu__probe_without_cpuid(void)
 {
        unsigned long cr0;
        u16 fsw, fcw;
@@ -65,18 +59,25 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
        cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
        write_cr0(cr0);
 
-       if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
-               asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
-                            : "+m" (fsw), "+m" (fcw));
+       asm volatile("fninit ; fnstsw %0 ; fnstcw %1" : "+m" (fsw), "+m" (fcw));
+
+       pr_info("x86/fpu: Probing for FPU: FSW=0x%04hx FCW=0x%04hx\n", fsw, fcw);
 
-               if (fsw == 0 && (fcw & 0x103f) == 0x003f)
-                       set_cpu_cap(c, X86_FEATURE_FPU);
+       return fsw == 0 && (fcw & 0x103f) == 0x003f;
+}
+
+static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+{
+       if (!boot_cpu_has(X86_FEATURE_CPUID) &&
+           !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
+               if (fpu__probe_without_cpuid())
+                       setup_force_cpu_cap(X86_FEATURE_FPU);
                else
-                       clear_cpu_cap(c, X86_FEATURE_FPU);
+                       setup_clear_cpu_cap(X86_FEATURE_FPU);
        }
 
 #ifndef CONFIG_MATH_EMULATION
-       if (!boot_cpu_has(X86_FEATURE_FPU)) {
+       if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_FPU)) {
                pr_emerg("x86/fpu: Giving up, no FPU found and no math emulation present\n");
                for (;;)
                        asm volatile("hlt");