ARC: [plat-eznps] handle extra aux regs #1: save/restore on context switch
authorNoam Camus <noamc@ezchip.com>
Thu, 15 Jun 2017 08:43:59 +0000 (11:43 +0300)
committerVineet Gupta <vgupta@synopsys.com>
Mon, 28 Aug 2017 22:17:36 +0000 (15:17 -0700)
save EFLAGS, and GPA1 auxiliary registers during context switch,
since they may be changed by the new task in kernel mode, while using atomic
ops e.g. cmpxchg.

Signed-off-by: Noam Camus <noamc@ezchip.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/processor.h
arch/arc/include/asm/switch_to.h
arch/arc/plat-eznps/Makefile
arch/arc/plat-eznps/ctop.c [new file with mode: 0644]

index 4104a08392146f6c479710557010135aa4774a15..d400a2161935de5442c0ae1ddc7159ae16c003a4 100644 (file)
@@ -27,6 +27,13 @@ struct arc_fpu {
 };
 #endif
 
+#ifdef CONFIG_ARC_PLAT_EZNPS
+struct eznps_dp {
+       unsigned int eflags;
+       unsigned int gpa1;
+};
+#endif
+
 /* Arch specific stuff which needs to be saved per task.
  * However these items are not so important so as to earn a place in
  * struct thread_info
@@ -38,6 +45,9 @@ struct thread_struct {
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
        struct arc_fpu fpu;
 #endif
+#ifdef CONFIG_ARC_PLAT_EZNPS
+       struct eznps_dp dp;
+#endif
 };
 
 #define INIT_THREAD  {                          \
index 1b171ab5fec0523f5dec5b1732b3d1c97f1243d8..f7d07feeea61593786682e0e81a7ce7236ee6016 100644 (file)
@@ -26,10 +26,19 @@ extern void fpu_save_restore(struct task_struct *p, struct task_struct *n);
 
 #endif /* !CONFIG_ARC_FPU_SAVE_RESTORE */
 
+#ifdef CONFIG_ARC_PLAT_EZNPS
+extern void dp_save_restore(struct task_struct *p, struct task_struct *n);
+#define ARC_EZNPS_DP_PREV(p, n)      dp_save_restore(p, n)
+#else
+#define ARC_EZNPS_DP_PREV(p, n)
+
+#endif /* !CONFIG_ARC_PLAT_EZNPS */
+
 struct task_struct *__switch_to(struct task_struct *p, struct task_struct *n);
 
 #define switch_to(prev, next, last)    \
 do {                                   \
+       ARC_EZNPS_DP_PREV(prev, next);  \
        ARC_FPU_PREV(prev, next);       \
        last = __switch_to(prev, next);\
        ARC_FPU_NEXT(next);             \
index 21091b199df025141c76b8c8fcac2e62fc5d6115..8d4371706b2fcc6d1c3d7c4487c9d7c2237dbbd3 100644 (file)
@@ -2,6 +2,6 @@
 # Makefile for the linux kernel.
 #
 
-obj-y := entry.o platform.o
+obj-y := entry.o platform.o ctop.o
 obj-$(CONFIG_SMP) += smp.o
 obj-$(CONFIG_EZNPS_MTM_EXT) += mtm.o
diff --git a/arch/arc/plat-eznps/ctop.c b/arch/arc/plat-eznps/ctop.c
new file mode 100644 (file)
index 0000000..030bcd0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright(c) 2015 EZchip Technologies.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ */
+
+#include <linux/sched.h>
+#include <asm/processor.h>
+#include <plat/ctop.h>
+
+void dp_save_restore(struct task_struct *prev, struct task_struct *next)
+{
+       struct eznps_dp *prev_task_dp = &prev->thread.dp;
+       struct eznps_dp *next_task_dp = &next->thread.dp;
+
+       /* Here we save all Data Plane related auxiliary registers */
+       prev_task_dp->eflags = read_aux_reg(CTOP_AUX_EFLAGS);
+       write_aux_reg(CTOP_AUX_EFLAGS, next_task_dp->eflags);
+
+       prev_task_dp->gpa1 = read_aux_reg(CTOP_AUX_GPA1);
+       write_aux_reg(CTOP_AUX_GPA1, next_task_dp->gpa1);
+}