Fix FTLB detection on R6
cover Fix FTLB detection on R6
These patches fix FTLB detection on R6 cores. Currently an FTLB will be assumed to exist, so if not then the setting of the FTLB page size will likely fail during boot.
The first patch adds cpu_has_ftlb, based on Config.MT (MMU type), which distinguishes a traditional TLB from a VTLB+FTLB configuration.
The second patch fixes the probe logic to use cpu_has_ftlb for R6.
James Hogan (2):
MIPS: cpu-features: Add cpu_has_ftlb
MIPS: Fix FTLB detection for R6
arch/mips/include/asm/cpu-features.h | 3 +++ arch/mips/include/asm/cpu.h | 1 + arch/mips/include/asm/mipsregs.h | 2 ++ arch/mips/kernel/cpu-probe.c | 23 ++++++++++++++--------- 4 files changed, 20 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.6
PATCH 1/2 MIPS: cpu-features: Add cpu_has_ftlb
Add cpu_has_ftlb, which specifies that an FTLB is present in addition to the VTLB, probed based on whether Config.MT == 4 (rather than 1 for standard JTLB).
This is necessary since MIPS release 6 removes Config4.MMUExtDef, so the presence of the FTLB fields in Config4 must be determined from Config.MT instead.
--- arch/mips/include/asm/cpu-features.h | 3 +++ arch/mips/include/asm/cpu.h | 1 + arch/mips/include/asm/mipsregs.h | 2 ++ arch/mips/kernel/cpu-probe.c | 8 +++++--- 4 files changed, 11 insertions(+), 3 deletions(-)
arch/mips/include/asm/cpu-features.h +3 -0
@@ -20,6 +20,9 @@#ifndef cpu_has_tlb#define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)#endif +#ifndef cpu_has_ftlb +#define cpu_has_ftlb (cpu_data[0].options & MIPS_CPU_FTLB) +#endif #ifndef cpu_has_tlbinv#define cpu_has_tlbinv (cpu_data[0].options & MIPS_CPU_TLBINV)#endif
arch/mips/include/asm/cpu.h +1 -0
@@ -385,6 +385,7 @@ enum cpu_type_enum {#define MIPS_CPU_CDMM 0x4000000000ull/* CPU has Common Device Memory Map */ #define MIPS_CPU_BP_GHIST 0x8000000000ull/* R12K+ Branch Prediction Global History */ #define MIPS_CPU_SP 0x10000000000ull/* Small (1KB) page support */ +#define MIPS_CPU_FTLB 0x20000000000ull/* CPU has Fixed-page-size TLB */ /* * CPU ASE encodings
arch/mips/include/asm/mipsregs.h +2 -0
@@ -487,6 +487,8 @@/* Bits specific to the MIPS32/64 PRA. */ #define MIPS_CONF_MT (_ULCAST_(7) << 7) +#define MIPS_CONF_MT_TLB (_ULCAST_(1) << 7) +#define MIPS_CONF_MT_FTLB (_ULCAST_(4) << 7)#define MIPS_CONF_AR (_ULCAST_(7) << 10)#define MIPS_CONF_AT (_ULCAST_(3) << 13)#define MIPS_CONF_M (_ULCAST_(1) << 31)
arch/mips/kernel/cpu-probe.c +5 -3
@@ -410,16 +410,18 @@ static int set_ftlb_enable(struct cpuinfo_mips *c, int enable)static inline unsigned int decode_config0 (struct cpuinfo_mips *c) {unsigned int config0; -int isa; +int isa, mt; config0 =read_c0_config ();/* * Look for Standard TLB or Dual VTLB and FTLB */ -if ((((config0 &MIPS_CONF_MT ) >>7 ) ==1 ) || - (((config0 &MIPS_CONF_MT ) >>7 ) ==4 )) + mt = config0 &MIPS_CONF_MT ; +if (mt ==MIPS_CONF_MT_TLB ) c->options |=MIPS_CPU_TLB ; +else if (mt ==MIPS_CONF_MT_FTLB ) + c->options |=MIPS_CPU_TLB |MIPS_CPU_FTLB ; isa = (config0 &MIPS_CONF_AT ) >>13 ;switch (isa) {
Signature · 1 line
2.4.6
PATCH 2/2 MIPS: Fix FTLB detection for R6
In reply to James HoganR6 removed the Config4.MMUExtDef field, with the low 16 bits only allowed to contain FTLB fields, and commit e87569cd6c57 ("MIPS:
cpu-probe: Fix VTLB/FTLB configuration for R6") updated the probing of this field to assume an FTLB is always present for R6.
However the FTLB may still be absent. The presence of those fields is actually specified by the MMU type in the Config.MT field, so use that (the new cpu_has_ftlb) to determine whether the FTLB is actually present.
--- arch/mips/kernel/cpu-probe.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/mips/kernel/cpu-probe.c +9 -6
@@ -561,15 +561,18 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c)if (cpu_has_tlb) {if (((config4 &MIPS_CONF4_IE ) >>29 ) ==2 ) c->options |=MIPS_CPU_TLBINV ; +/* -* This is a bit ugly. R6 has dropped that field from -* config4 and the only valid configuration is VTLB+FTLB so -* set a good value for mmuextdef for that case. +* R6 has dropped the MMUExtDef field from config4. +* On R6 the fields always describe the FTLB, and only if it is +* present according to Config.MT. */ -if (cpu_has_mips_r6) - mmuextdef =MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT ; -else +if (!cpu_has_mips_r6) mmuextdef = config4 &MIPS_CONF4_MMUEXTDEF ; +else if (cpu_has_ftlb) + mmuextdef =MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT ; +else + mmuextdef =0 ;switch (mmuextdef) {case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT :
Signature · 1 line
2.4.6