Module: xenomai-gch
Branch: for-head
Commit: 00a99af7bfb3d1d2f8fece450320ce0d82d08db4
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=00a99af7bfb3d1d2f8fece450320ce0d82d08db4

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct  7 13:55:33 2009 +0200

testsuite: handle platforms with userland-only FPU support

---

 include/asm-arm/fptest.h          |    9 +++++++--
 include/asm-blackfin/fptest.h     |    9 +++++++--
 include/asm-nios2/fptest.h        |    9 +++++++--
 include/asm-powerpc/fptest.h      |   19 +++++++++++++++++--
 include/asm-x86/fptest.h          |    9 +++++++--
 ksrc/drivers/testing/switchtest.c |   17 +++++++++++++----
 6 files changed, 58 insertions(+), 14 deletions(-)

diff --git a/include/asm-arm/fptest.h b/include/asm-arm/fptest.h
index 89b550c..924c226 100644
--- a/include/asm-arm/fptest.h
+++ b/include/asm-arm/fptest.h
@@ -11,12 +11,17 @@
 #define have_vfp (0)
 #endif /* !CONFIG_VFP */
 
-static inline int fp_kernel_begin(void)
+static inline int fp_kernel_supported(void)
+{
+       return 1;
+}
+
+static inline int fp_linux_begin(void)
 {
        return -ENOSYS;
 }
 
-static inline void fp_kernel_end(void)
+static inline void fp_linux_end(void)
 {
 }
 
diff --git a/include/asm-blackfin/fptest.h b/include/asm-blackfin/fptest.h
index 6933ddb..d14181d 100644
--- a/include/asm-blackfin/fptest.h
+++ b/include/asm-blackfin/fptest.h
@@ -4,12 +4,17 @@
 #ifdef __KERNEL__
 #include <linux/module.h>
 
-static inline int fp_kernel_begin(void)
+static inline int fp_kernel_supported(void)
+{
+       return 0;
+}
+
+static inline int fp_linux_begin(void)
 {
        return -ENOSYS;
 }
 
-static inline void fp_kernel_end(void)
+static inline void fp_linux_end(void)
 {
 }
 
diff --git a/include/asm-nios2/fptest.h b/include/asm-nios2/fptest.h
index 6933ddb..d14181d 100644
--- a/include/asm-nios2/fptest.h
+++ b/include/asm-nios2/fptest.h
@@ -4,12 +4,17 @@
 #ifdef __KERNEL__
 #include <linux/module.h>
 
-static inline int fp_kernel_begin(void)
+static inline int fp_kernel_supported(void)
+{
+       return 0;
+}
+
+static inline int fp_linux_begin(void)
 {
        return -ENOSYS;
 }
 
-static inline void fp_kernel_end(void)
+static inline void fp_linux_end(void)
 {
 }
 
diff --git a/include/asm-powerpc/fptest.h b/include/asm-powerpc/fptest.h
index 06c73a8..de3e9af 100644
--- a/include/asm-powerpc/fptest.h
+++ b/include/asm-powerpc/fptest.h
@@ -5,12 +5,27 @@
 #include <linux/module.h>
 #include <asm/system.h>
 
-static inline int fp_kernel_begin(void)
+static inline int fp_kernel_supported(void)
+{
+#ifdef CONFIG_MATH_EMULATION
+       static int once = 0;
+       if (!once) {
+               once = 1;
+               printk("Warning: CONFIG_MATH_EMULATION defined in kernel\n"
+                      "         no kernel-based FPU support for this 
platform\n");
+       }
+       return 0;
+#else
+       return 1;
+#endif
+}
+
+static inline int fp_linux_begin(void)
 {
        return -ENOSYS;
 }
 
-static inline void fp_kernel_end(void)
+static inline void fp_linux_end(void)
 {
 }
 
diff --git a/include/asm-x86/fptest.h b/include/asm-x86/fptest.h
index 1d6b978..88baa34 100644
--- a/include/asm-x86/fptest.h
+++ b/include/asm-x86/fptest.h
@@ -5,7 +5,12 @@
 #include <linux/module.h>
 #include <asm/i387.h>
 
-static inline int fp_kernel_begin(void)
+static inline int fp_kernel_supported(void)
+{
+       return 1;
+}
+
+static inline int fp_linux_begin(void)
 {
 #if defined(CONFIG_X86_USE_3DNOW) \
        || defined(CONFIG_MD_RAID456) || defined(CONFIG_MD_RAID456_MODULE)
@@ -28,7 +33,7 @@ static inline int fp_kernel_begin(void)
        return 0;
 }
 
-static inline void fp_kernel_end(void)
+static inline void fp_linux_end(void)
 {
        kernel_fpu_end();
 }
diff --git a/ksrc/drivers/testing/switchtest.c 
b/ksrc/drivers/testing/switchtest.c
index 946641c..057094b 100644
--- a/ksrc/drivers/testing/switchtest.c
+++ b/ksrc/drivers/testing/switchtest.c
@@ -243,7 +243,7 @@ static int rtswitch_to_nrt(rtswitch_context_t *ctx,
 
                case RTSWITCH_RT:
 
-                       if (!fp_check || fp_kernel_begin() < 0) {
+                       if (!fp_check || fp_linux_begin() < 0) {
                                fp_check = 0;
                                goto signal_nofp;
                        }
@@ -254,7 +254,7 @@ static int rtswitch_to_nrt(rtswitch_context_t *ctx,
                        fp_regs_set(expected);
                        rtdm_event_signal(&to->rt_synch);
                        fp_val = fp_regs_check(expected);
-                       fp_kernel_end();
+                       fp_linux_end();
 
                        if(down_interruptible(&from->nrt_synch))
                                return -EINTR;
@@ -275,11 +275,11 @@ static int rtswitch_to_nrt(rtswitch_context_t *ctx,
                                (ctx->switches_count % 4000000) * 1000;
                        barrier();
 
-                       fp_kernel_begin();
+                       fp_linux_begin();
                        fp_regs_set(expected);
                        rtdm_event_signal(&to->rt_synch);
                        fp_val = fp_regs_check(expected);
-                       fp_kernel_end();
+                       fp_linux_end();
 
                        if (down_interruptible(&from->nrt_synch))
                                return -EINTR;
@@ -434,6 +434,15 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx,
        char name[30];
        int err;
 
+       /*
+        * Silently disable FP tests in kernel if FPU is not supported
+        * there. Typical case is math emulation support: we can use
+        * it from userland as a synthetic FPU, but there is no sane
+        * way to use it from kernel-based threads (Xenomai or Linux).
+        */
+       if (!fp_kernel_supported())
+               ptask->flags &= ~RTTST_SWTEST_USE_FPU;
+               
        ptask->flags |= RTSWITCH_KERNEL;
        err = rtswitch_register_task(ctx, ptask);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to