forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/arc/kernel/fpu.c
....@@ -1,15 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * fpu.c - save/restore of Floating Point Unit Registers on task switch
34 *
45 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #include <linux/sched.h>
12
-#include <asm/switch_to.h>
9
+#include <asm/fpu.h>
10
+
11
+#ifdef CONFIG_ISA_ARCOMPACT
1312
1413 /*
1514 * To save/restore FPU regs, simplest scheme would use LR/SR insns.
....@@ -53,3 +52,31 @@
5352 : "r" (zero), "r" (*(readfrom + 3)), "r" (*(readfrom + 2))
5453 );
5554 }
55
+
56
+#else
57
+
58
+void fpu_init_task(struct pt_regs *regs)
59
+{
60
+ const unsigned int fwe = 0x80000000;
61
+
62
+ /* default rounding mode */
63
+ write_aux_reg(ARC_REG_FPU_CTRL, 0x100);
64
+
65
+ /* Initialize to zero: setting requires FWE be set */
66
+ write_aux_reg(ARC_REG_FPU_STATUS, fwe);
67
+}
68
+
69
+void fpu_save_restore(struct task_struct *prev, struct task_struct *next)
70
+{
71
+ struct arc_fpu *save = &prev->thread.fpu;
72
+ struct arc_fpu *restore = &next->thread.fpu;
73
+ const unsigned int fwe = 0x80000000;
74
+
75
+ save->ctrl = read_aux_reg(ARC_REG_FPU_CTRL);
76
+ save->status = read_aux_reg(ARC_REG_FPU_STATUS);
77
+
78
+ write_aux_reg(ARC_REG_FPU_CTRL, restore->ctrl);
79
+ write_aux_reg(ARC_REG_FPU_STATUS, (fwe | restore->status));
80
+}
81
+
82
+#endif