MIPS: context switch: Use save/restore instead of set/clear for Status.CU2
authorHuacai Chen <chenhc@lemote.com>
Mon, 21 Sep 2020 09:12:26 +0000 (17:12 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Mon, 21 Sep 2020 20:14:47 +0000 (22:14 +0200)
Some processors (such as Loongson-3) need to enable CU2 in kernel mode,
current set/clear method will lose Status.CU2 during context switching,
so use save/restore method instead.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/switch_to.h

index 0b0a93bf83cd9e01e8a62a596c9bca9ee0631a9e..a4374b4cb88fd830f8b83caab52d6e3c133fd0c4 100644 (file)
@@ -117,6 +117,8 @@ do {                                                                        \
                __restore_dsp(next);                                    \
        }                                                               \
        if (cop2_present) {                                             \
+               u32 status = read_c0_status();                          \
+                                                                       \
                set_c0_status(ST0_CU2);                                 \
                if ((KSTK_STATUS(prev) & ST0_CU2)) {                    \
                        if (cop2_lazy_restore)                          \
@@ -127,7 +129,7 @@ do {                                                                        \
                    !cop2_lazy_restore) {                               \
                        cop2_restore(next);                             \
                }                                                       \
-               clear_c0_status(ST0_CU2);                               \
+               write_c0_status(status);                                \
        }                                                               \
        __clear_r5_hw_ll_bit();                                         \
        __clear_software_ll_bit();                                      \