Skip to content

Commit fea8826

Browse files
FlyGoattsbogend
authored andcommitted
MIPS: smp-cps: Don't rely on CP0_CMGCRBASE
CP0_CMGCRBASE is not always available on CPS enabled system such as early proAptiv. For early SMP bring up where we can't safely access memeory, we patch the entry of CPS NMI vector to inject CMGCR address directly into register during early core bringup. For VPE bringup as the core is already coherenct at that point we just read the variable to obtain the address. Signed-off-by: Jiaxun Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent dd83147 commit fea8826

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

arch/mips/include/asm/smp-cps.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef __MIPS_ASM_SMP_CPS_H__
88
#define __MIPS_ASM_SMP_CPS_H__
99

10+
#define CPS_ENTRY_PATCH_INSNS 6
11+
1012
#ifndef __ASSEMBLY__
1113

1214
struct vpe_boot_config {
@@ -30,6 +32,8 @@ extern void mips_cps_boot_vpes(struct core_boot_config *cfg, unsigned vpe);
3032
extern void mips_cps_pm_save(void);
3133
extern void mips_cps_pm_restore(void);
3234

35+
extern void *mips_cps_core_entry_patch_end;
36+
3337
#ifdef CONFIG_MIPS_CPS
3438

3539
extern bool mips_cps_smp_in_use(void);

arch/mips/kernel/cps-vec.S

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/mipsregs.h>
1414
#include <asm/mipsmtregs.h>
1515
#include <asm/pm.h>
16+
#include <asm/smp-cps.h>
1617

1718
#define GCR_CPC_BASE_OFS 0x0088
1819
#define GCR_CL_COHERENCE_OFS 0x2008
@@ -80,25 +81,20 @@
8081
nop
8182
.endm
8283

83-
/* Calculate an uncached address for the CM GCRs */
84-
.macro cmgcrb dest
85-
.set push
86-
.set noat
87-
MFC0 $1, CP0_CMGCRBASE
88-
PTR_SLL $1, $1, 4
89-
PTR_LI \dest, UNCAC_BASE
90-
PTR_ADDU \dest, \dest, $1
91-
.set pop
92-
.endm
9384

9485
.balign 0x1000
9586

9687
LEAF(mips_cps_core_entry)
9788
/*
98-
* These first 4 bytes will be patched by cps_smp_setup to load the
99-
* CCA to use into register s0.
89+
* These first several instructions will be patched by cps_smp_setup to load the
90+
* CCA to use into register s0 and GCR base address to register s1.
10091
*/
101-
.word 0
92+
.rept CPS_ENTRY_PATCH_INSNS
93+
nop
94+
.endr
95+
96+
.global mips_cps_core_entry_patch_end
97+
mips_cps_core_entry_patch_end:
10298

10399
/* Check whether we're here due to an NMI */
104100
mfc0 k0, CP0_STATUS
@@ -121,8 +117,7 @@ not_nmi:
121117
mtc0 t0, CP0_STATUS
122118

123119
/* Skip cache & coherence setup if we're already coherent */
124-
cmgcrb v1
125-
lw s7, GCR_CL_COHERENCE_OFS(v1)
120+
lw s7, GCR_CL_COHERENCE_OFS(s1)
126121
bnez s7, 1f
127122
nop
128123

@@ -132,7 +127,7 @@ not_nmi:
132127

133128
/* Enter the coherent domain */
134129
li t0, 0xff
135-
sw t0, GCR_CL_COHERENCE_OFS(v1)
130+
sw t0, GCR_CL_COHERENCE_OFS(s1)
136131
ehb
137132

138133
/* Set Kseg0 CCA to that in s0 */
@@ -305,8 +300,7 @@ LEAF(mips_cps_core_init)
305300
*/
306301
LEAF(mips_cps_get_bootcfg)
307302
/* Calculate a pointer to this cores struct core_boot_config */
308-
cmgcrb t0
309-
lw t0, GCR_CL_ID_OFS(t0)
303+
lw t0, GCR_CL_ID_OFS(s1)
310304
li t1, COREBOOTCFG_SIZE
311305
mul t0, t0, t1
312306
PTR_LA t1, mips_cps_core_bootcfg
@@ -366,8 +360,9 @@ LEAF(mips_cps_boot_vpes)
366360
has_vp t0, 5f
367361

368362
/* Find base address of CPC */
369-
cmgcrb t3
370-
PTR_L t1, GCR_CPC_BASE_OFS(t3)
363+
PTR_LA t1, mips_gcr_base
364+
PTR_L t1, 0(t1)
365+
PTR_L t1, GCR_CPC_BASE_OFS(t1)
371366
PTR_LI t2, ~0x7fff
372367
and t1, t1, t2
373368
PTR_LI t2, UNCAC_BASE

arch/mips/kernel/smp-cps.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
162162
*/
163163
entry_code = (u32 *)&mips_cps_core_entry;
164164
uasm_i_addiu(&entry_code, 16, 0, cca);
165+
UASM_i_LA(&entry_code, 17, (long)mips_gcr_base);
166+
BUG_ON((void *)entry_code > (void *)&mips_cps_core_entry_patch_end);
165167
blast_dcache_range((unsigned long)&mips_cps_core_entry,
166168
(unsigned long)entry_code);
167169
bc_wback_inv((unsigned long)&mips_cps_core_entry,

0 commit comments

Comments
 (0)