Module: xenomai-forge
Branch: master
Commit: 02ecff5029afcf7ace8a007ffeb676baec1f9d7b
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=02ecff5029afcf7ace8a007ffeb676baec1f9d7b

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun May 13 16:41:47 2012 +0200

hal/x86: detect calibration at run-time

---

 include/asm-x86/calibration.h |   62 +++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/include/asm-x86/calibration.h b/include/asm-x86/calibration.h
index 864669a..8b60486 100644
--- a/include/asm-x86/calibration.h
+++ b/include/asm-x86/calibration.h
@@ -28,30 +28,52 @@ static inline unsigned long xnarch_get_sched_latency (void)
 
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
        sched_latency = CONFIG_XENO_OPT_TIMING_SCHEDLAT;
-#else
+#else /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
+
+       if (strcmp(RTHAL_TIMER_DEVICE, "lapic") == 0) {
 #ifdef CONFIG_SMP
-       sched_latency = 3350;
-#elif defined(CONFIG_X86_LOCAL_APIC)
-       sched_latency = 1000;
-#else /* !CONFIG_X86_LOCAL_APIC */
-       /*
-        * Use the bogomips formula to identify low-end x86 boards
-        * when using the 8254 PIT. The following is still grossly
-        * experimental and needs work (i.e. more specific cases), but
-        * the approach is definitely saner than previous attempts to
-        * guess such value dynamically.
-        */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
-#define __bogomips (current_cpu_data.loops_per_jiffy/(500000/HZ))
-#else
+               if (num_online_cpus() > 1)
+                       sched_latency = 3350;
+               else
+                       sched_latency = 2000;
+#else /* !SMP */
+               sched_latency = 1000;
+#endif /* !SMP */
+       } else if (strcmp(RTHAL_TIMER_DEVICE, "pit")) { /* HPET */
+#ifdef CONFIG_SMP
+               if (num_online_cpus() > 1)
+                       sched_latency = 3350;
+               else
+                       sched_latency = 1500;
+#else /* !SMP */
+               sched_latency = 1000;
+#endif /* !SMP */
+       } else {
+               /*
+                * Use the bogomips formula to identify low-end x86 boards
+                * when using the 8254 PIT. The following is still grossly
+                * experimental and needs work (i.e. more specific cases), but
+                * the approach is definitely saner than previous attempts to
+                * guess such value dynamically.
+                */
+#ifdef CONFIG_IPIPE_CORE
+#define __bogomips (this_cpu_read(cpu_info.loops_per_jiffy)/(500000/HZ))
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
 #define __bogomips (cpu_info.loops_per_jiffy/(500000/HZ))
+#else
+#define __bogomips (current_cpu_data.loops_per_jiffy/(500000/HZ))
 #endif
-       sched_latency = (__bogomips < 250 ? 17000 :
-                        __bogomips < 2500 ? 4200 :
-                        3500);
+
+               sched_latency = (__bogomips < 250 ? 17000 :
+                                __bogomips < 2500 ? 4200 :
+                                3500);
 #undef __bogomips
-#endif /* CONFIG_X86_LOCAL_APIC */
-#endif /* CONFIG_XENO_OPT_TIMING_SCHEDLAT */
+
+#ifdef CONFIG_SMP
+               sched_latency += 1000;
+#endif /* CONFIG_SMP */
+       }
+#endif /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
 
        return sched_latency;
 }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to