Module: xenomai-3
Branch: next
Commit: f3978abba33c4d6841bca8db57b4b7dc2f50c71a
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f3978abba33c4d6841bca8db57b4b7dc2f50c71a

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon May 22 12:06:46 2017 +0200

cobalt/arm64: use regular context switching code

Since 4.9.x, the interrupt pipeline implementation guarantees that the
regular context switching code may be used over the head stage,
including the fpu management bits.

Drop the open coded support and use mainline's implementation instead.

At this chance, drop the useless conditionals for handling the non-FPU
case: this one does not apply to arm64.

---

 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |   44 +++++++-------------
 kernel/cobalt/arch/arm64/thread.c                  |   14 +++++--
 2 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 319f4d8..eab6851 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -19,11 +19,16 @@
 #ifndef _COBALT_ARM64_ASM_THREAD_H
 #define _COBALT_ARM64_ASM_THREAD_H
 
+#include <linux/version.h>
 #include <asm-generic/xenomai/thread.h>
 
+#if defined(CONFIG_XENO_ARCH_FPU) && LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
+#define ARM64_XENO_OLD_SWITCH
+#endif
+
 struct xnarchtcb {
        struct xntcb core;
-#ifdef CONFIG_XENO_ARCH_FPU
+#ifdef ARM64_XENO_OLD_SWITCH
        struct fpsimd_state xnfpsimd_state;
        struct fpsimd_state *fpup;
 #define xnarch_fpu_ptr(tcb)     ((tcb)->fpup)
@@ -58,53 +63,36 @@ static inline void xnarch_enter_root(struct xnthread *root) 
{ }
 
 int xnarch_escalate(void);
 
-#if defined(CONFIG_XENO_ARCH_FPU)
+#ifdef ARM64_XENO_OLD_SWITCH
 
 void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
-static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
-{
-       return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
-}
-
 void xnarch_leave_root(struct xnthread *root);
 
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
-static inline int
-xnarch_handle_fpu_fault(struct xnthread *from,
-                       struct xnthread *to, struct ipipe_trap_data *d)
-{
-       return 0;
-}
-
-#else /* !CONFIG_XENO_ARCH_FPU */
+#else /* !ARM64_XENO_OLD_SWITCH */
 
 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
+static inline void xnarch_leave_root(struct xnthread *root) { }
+static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
+
+#endif /*  !ARM64_XENO_OLD_SWITCH */
 
-/*
- * Userland may raise FPU faults with FPU-enabled kernels, regardless
- * of whether real-time threads actually use FPU, so we simply ignore
- * these faults.
- */
 static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-       return 0;
+       return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
 }
 
-static inline void xnarch_leave_root(struct xnthread *root) { }
-
-static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
-
-static inline int xnarch_handle_fpu_fault(struct xnthread *from, 
-                                       struct xnthread *to, struct 
ipipe_trap_data *d)
+static inline int
+xnarch_handle_fpu_fault(struct xnthread *from,
+                       struct xnthread *to, struct ipipe_trap_data *d)
 {
        return 0;
 }
-#endif /*  !CONFIG_XENO_ARCH_FPU */
 
 static inline void xnarch_enable_kfpu(void) { }
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 3097aeb..270c99f 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -33,9 +33,10 @@
 #include <asm/fpsimd.h>
 #include <asm/processor.h>
 #include <asm/hw_breakpoint.h>
-#include <asm/fpsimd.h>
 
-#ifdef CONFIG_XENO_ARCH_FPU
+#ifdef ARM64_XENO_OLD_SWITCH
+
+#include <asm/fpsimd.h>
 
 #define FPSIMD_EN (0x3 << 20)
 
@@ -104,13 +105,13 @@ void xnarch_init_root_tcb(struct xnthread *thread)
        tcb->fpup = NULL;
 }
 
-#endif /* CONFIG_XENO_ARCH_FPU */
+#endif /* ARM64_XENO_OLD_SWITCH */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 {
        struct xnarchtcb *out_tcb = &out->tcb, *in_tcb = &in->tcb;
+       struct task_struct *prev, *next, *last;
        struct mm_struct *prev_mm, *next_mm;
-       struct task_struct *prev, *next;
 
        next = in_tcb->core.host_task;
        prev = out_tcb->core.host_task;
@@ -133,7 +134,12 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
                        enter_lazy_tlb(prev_mm, next);
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
        ipipe_switch_to(prev, next);
+       (void)last;
+#else
+       switch_to(prev, next, last);
+#endif
 }
 
 int xnarch_escalate(void)


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

Reply via email to