Module: xenomai-2.5
Branch: master
Commit: 348638e82364649062f60e60abbc448adffdf164
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=348638e82364649062f60e60abbc448adffdf164

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Thu Sep  2 22:57:15 2010 +0200

arm: fix VFP context handling on SMP systems

---

 include/asm-arm/bits/pod.h |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/asm-arm/bits/pod.h b/include/asm-arm/bits/pod.h
index 3dc51f8..71a7330 100644
--- a/include/asm-arm/bits/pod.h
+++ b/include/asm-arm/bits/pod.h
@@ -141,17 +141,31 @@ static inline void xnarch_enable_fpu(xnarchtcb_t *tcb)
           newly switched thread uses the FPU, to allow the kernel handler to
           pick the correct FPU context.
        */
-       if (likely(!tcb->is_root)
-           || (tcb->fpup && tcb->fpup == rthal_task_fpenv(tcb->user_task))) {
+       if (likely(!tcb->is_root)) {
+               rthal_enable_fpu();
+               /* No exception should be pending, since it should have caused
+                  a trap earlier.
+               */
+       } else if (tcb->fpup && tcb->fpup == rthal_task_fpenv(tcb->user_task)) {
                unsigned fpexc = rthal_enable_fpu();
+#ifndef CONFIG_SMP
                if (likely(!(fpexc & RTHAL_VFP_ANY_EXC)
                           && !(rthal_vfp_fmrx(FPSCR) & FPSCR_IXE)))
                        return;
-
-               /* If current process has pending exceptions it is
+               /*
+                  If current process has pending exceptions it is
                   illegal to restore the FPEXC register with them, we must
                   save the fpu state and disable them, to get linux
-                  fpu fault handler take care of them correctly. */
+                  fpu fault handler take care of them correctly.
+               */
+#endif
+               /*
+                  On SMP systems, if we are restoring the root
+                  thread, running the task holding the FPU context at
+                  the time when we switched to real-time domain,
+                  forcibly save the FPU context. It seems to fix SMP
+                  systems for still unknown reasons.
+               */
                rthal_save_fpu(tcb->fpup, fpexc);
                last_VFP_context[rthal_processor_id()] = NULL;
                rthal_disable_fpu();


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

Reply via email to