Skip to content

Commit 5dacbbe

Browse files
committed
xtensa: simplify coprocessor.S
Use addresses instead of offsets and drop unneeded offset -> address calculations. Don't generate any code for undefined coprocessors. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent cad6fad commit 5dacbbe

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

‎arch/xtensa/kernel/coprocessor.S‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,33 @@
3333
*/
3434

3535
#define SAVE_CP_REGS(x) \
36-
.align 4; \
37-
.Lsave_cp_regs_cp##x: \
3836
.if XTENSA_HAVE_COPROCESSOR(x); \
37+
.align 4; \
38+
.Lsave_cp_regs_cp##x: \
3939
xchal_cp##x##_store a2 a4 a5 a6 a7; \
40-
.endif; \
41-
jx a0
40+
jx a0; \
41+
.endif
4242

4343
#define SAVE_CP_REGS_TAB(x) \
4444
.if XTENSA_HAVE_COPROCESSOR(x); \
45-
.long .Lsave_cp_regs_cp##x - .Lsave_cp_regs_jump_table; \
45+
.long .Lsave_cp_regs_cp##x; \
4646
.else; \
4747
.long 0; \
4848
.endif; \
4949
.long THREAD_XTREGS_CP##x
5050

5151

5252
#define LOAD_CP_REGS(x) \
53-
.align 4; \
54-
.Lload_cp_regs_cp##x: \
5553
.if XTENSA_HAVE_COPROCESSOR(x); \
54+
.align 4; \
55+
.Lload_cp_regs_cp##x: \
5656
xchal_cp##x##_load a2 a4 a5 a6 a7; \
57-
.endif; \
58-
jx a0
57+
jx a0; \
58+
.endif
5959

6060
#define LOAD_CP_REGS_TAB(x) \
6161
.if XTENSA_HAVE_COPROCESSOR(x); \
62-
.long .Lload_cp_regs_cp##x - .Lload_cp_regs_jump_table; \
62+
.long .Lload_cp_regs_cp##x; \
6363
.else; \
6464
.long 0; \
6565
.endif; \
@@ -83,6 +83,7 @@
8383
LOAD_CP_REGS(6)
8484
LOAD_CP_REGS(7)
8585

86+
.section ".rodata", "a"
8687
.align 4
8788
.Lsave_cp_regs_jump_table:
8889
SAVE_CP_REGS_TAB(0)
@@ -104,6 +105,8 @@
104105
LOAD_CP_REGS_TAB(6)
105106
LOAD_CP_REGS_TAB(7)
106107

108+
.previous
109+
107110
/*
108111
* coprocessor_flush(struct thread_info*, index)
109112
* a2 a3
@@ -126,8 +129,7 @@ ENTRY(coprocessor_flush)
126129
l32i a3, a3, 0
127130
add a2, a2, a4
128131
beqz a3, 1f
129-
add a0, a0, a3
130-
callx0 a0
132+
callx0 a3
131133
1: l32i a0, a1, 0
132134
retw
133135

@@ -212,10 +214,9 @@ ENTRY(fast_coprocessor)
212214
movi a0, 2f # a0: 'return' address
213215
addx8 a3, a3, a5 # a3: coprocessor number
214216
l32i a2, a3, 4 # a2: xtregs offset
215-
l32i a3, a3, 0 # a3: jump offset
217+
l32i a3, a3, 0 # a3: jump address
216218
add a2, a2, a4
217-
add a4, a3, a5 # a4: address of save routine
218-
jx a4
219+
jx a3
219220

220221
/* Note that only a0 and a1 were preserved. */
221222

@@ -235,10 +236,9 @@ ENTRY(fast_coprocessor)
235236
movi a0, 1f
236237
addx8 a3, a3, a5
237238
l32i a2, a3, 4 # a2: xtregs offset
238-
l32i a3, a3, 0 # a3: jump offset
239+
l32i a3, a3, 0 # a3: jump address
239240
add a2, a2, a4
240-
add a4, a3, a5
241-
jx a4
241+
jx a3
242242

243243
/* Restore all registers and return from exception handler. */
244244

0 commit comments

Comments
 (0)