leon: add SDK patches from buildroot-2022.02-1.2/5.10.175
[openwrt/staging/wigyori.git] / target / linux / leon / patches-5.15 / 0010-sparc32-leon-Handle-self-clearing-FSR.ftt-when-savin.patch
1 From ce71c62289d17a6e7d809759f6b10297bb066d11 Mon Sep 17 00:00:00 2001
2 From: Andreas Larsson <andreas@gaisler.com>
3 Date: Wed, 20 Sep 2017 09:10:46 +0200
4 Subject: [PATCH 10/32] sparc32,leon: Handle self clearing FSR.ftt when saving
5 FPU registers
6
7 GRFPU self clears the ftt field after a STFSR. Make sure that the ftt
8 field is not for cases with multiple STFSRs.
9
10 Signed-off-by: Andreas Larsson <andreas@gaisler.com>
11 ---
12 arch/sparc/kernel/entry.S | 8 +++++++-
13 1 file changed, 7 insertions(+), 1 deletion(-)
14
15 diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
16 index b56f489e38bb..87c68aeeb794 100644
17 --- a/arch/sparc/kernel/entry.S
18 +++ b/arch/sparc/kernel/entry.S
19 @@ -1062,6 +1062,7 @@ fpsave:
20 st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
21 ld [%o1], %g1
22 set 0x2000, %g4
23 + set 0x1c000, %g5
24 andcc %g1, %g4, %g0
25 be 2f
26 mov 0, %g2
27 @@ -1072,6 +1073,10 @@ fpsave:
28 fpsave_magic:
29 st %fsr, [%o1]
30 ld [%o1], %g3
31 + andn %g3, %g5, %g3 /* ftt gets cleared on stfsr for GRFPU... */
32 + and %g1, %g5, %g1
33 + or %g1, %g3, %g3
34 + st %g3, [%o1] /* ... so set ftt field from first fsr read */
35 andcc %g3, %g4, %g0
36 add %g2, 1, %g2
37 bne 1b
38 @@ -1108,8 +1113,9 @@ fpsave_catch:
39 st %fsr, [%o1]
40
41 fpsave_catch2:
42 + st %fsr, [%o1] /* In this case, this is the first successful fsr read */
43 b fpsave + 4
44 - st %fsr, [%o1]
45 + ld [%o1], %g1 /* so take care of it for GRFPU ftt field handling */
46
47 /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
48
49 --
50 2.34.1
51