Skip to content

Commit a3deecf

Browse files
jchandra-brcmralfbaechle
authored andcommitted
MIPS: Netlogic: Reduce size of reset code
Update thread wakeup function to use scratch registers for saving SP and RA. Move the register restore code needed for thread 0 to the calling function. This reduces the size of code copied to the reset vector. Signed-off-by: Jayachandran C <jchandra@broadcom.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6910/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 2e240dd commit a3deecf

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎arch/mips/netlogic/common/reset.S‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ FEXPORT(nlm_reset_entry)
197197
EXPORT(nlm_boot_siblings)
198198
/* core L1D flush before enable threads */
199199
xlp_flush_l1_dcache
200+
/* save ra and sp, will be used later (only for boot cpu) */
201+
dmtc0 ra, $22, 6
202+
dmtc0 sp, $22, 7
200203
/* Enable hw threads by writing to MAP_THREADMODE of the core */
201204
li t0, CKSEG1ADDR(RESET_DATA_PHYS)
202205
lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */
@@ -238,14 +241,12 @@ EXPORT(nlm_boot_siblings)
238241
nop
239242

240243
/*
241-
* For the boot CPU, we have to restore registers and
242-
* return
244+
* For the boot CPU, we have to restore ra and sp and return, rest
245+
* of the registers will be restored by the caller
243246
*/
244-
4: dmfc0 t0, $4, 2 /* restore SP from UserLocal */
245-
li t1, 0xfadebeef
246-
dmtc0 t1, $4, 2 /* restore SP from UserLocal */
247-
PTR_SUBU sp, t0, PT_SIZE
248-
RESTORE_ALL
247+
4:
248+
dmfc0 ra, $22, 6
249+
dmfc0 sp, $22, 7
249250
jr ra
250251
nop
251252
EXPORT(nlm_reset_entry_end)

‎arch/mips/netlogic/common/smpboot.S‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
.set noat
5555
.set arch=xlr /* for mfcr/mtcr, XLR is sufficient */
5656

57-
FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
58-
dmtc0 sp, $4, 2 /* SP saved in UserLocal */
57+
/* Called by the boot cpu to wake up its sibling threads */
58+
NESTED(xlp_boot_core0_siblings, PT_SIZE, sp)
59+
/* CPU register contents lost when enabling threads, save them first */
5960
SAVE_ALL
6061
sync
6162
/* find the location to which nlm_boot_siblings was relocated */
@@ -65,9 +66,12 @@ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
6566
dsubu t2, t1
6667
daddu t2, t0
6768
/* call it */
68-
jr t2
69+
jalr t2
6970
nop
70-
/* not reached */
71+
RESTORE_ALL
72+
jr ra
73+
nop
74+
END(xlp_boot_core0_siblings)
7175

7276
NESTED(nlm_boot_secondary_cpus, 16, sp)
7377
/* Initialize CP0 Status */

0 commit comments

Comments
 (0)