Skip to content

Commit efd1b4a

Browse files
xen0ntsbogend
authored andcommitted
MIPS: only register FTLBPar exception handler for supported models
Previously ExcCode 16 is unconditionally treated as the FTLB parity exception (FTLBPar), but in fact its semantic is implementation- dependent. Looking at various manuals it seems the FTLBPar exception is only present on some recent MIPS Technologies cores, so only register the handler on these. Fixes: 75b5b5e ("MIPS: Add support for FTLBs") Reviewed-by: Huacai Chen <[email protected]> Signed-off-by: WANG Xuerui <[email protected]> Cc: Paul Burton <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 48f5dd5 commit efd1b4a

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

arch/mips/include/asm/cpu-features.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@
568568
# define cpu_has_mac2008_only __opt(MIPS_CPU_MAC_2008_ONLY)
569569
#endif
570570

571+
#ifndef cpu_has_ftlbparex
572+
# define cpu_has_ftlbparex __opt(MIPS_CPU_FTLBPAREX)
573+
#endif
574+
571575
#ifdef CONFIG_SMP
572576
/*
573577
* Some systems share FTLB RAMs between threads within a core (siblings in

arch/mips/include/asm/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ enum cpu_type_enum {
427427
#define MIPS_CPU_MM_SYSAD BIT_ULL(58) /* CPU supports write-through SysAD Valid merge */
428428
#define MIPS_CPU_MM_FULL BIT_ULL(59) /* CPU supports write-through full merge */
429429
#define MIPS_CPU_MAC_2008_ONLY BIT_ULL(60) /* CPU Only support MAC2008 Fused multiply-add instruction */
430+
#define MIPS_CPU_FTLBPAREX BIT_ULL(61) /* CPU has FTLB parity exception */
430431

431432
/*
432433
* CPU ASE encodings

arch/mips/kernel/cpu-probe.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,19 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
18271827
default:
18281828
break;
18291829
}
1830+
1831+
/* Recent MIPS cores use the implementation-dependent ExcCode 16 for
1832+
* cache/FTLB parity exceptions.
1833+
*/
1834+
switch (__get_cpu_type(c->cputype)) {
1835+
case CPU_PROAPTIV:
1836+
case CPU_P5600:
1837+
case CPU_P6600:
1838+
case CPU_I6400:
1839+
case CPU_I6500:
1840+
c->options |= MIPS_CPU_FTLBPAREX;
1841+
break;
1842+
}
18301843
}
18311844

18321845
static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)

arch/mips/kernel/traps.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,8 @@ void __init trap_init(void)
24542454
if (cpu_has_fpu && !cpu_has_nofpuex)
24552455
set_except_vector(EXCCODE_FPE, handle_fpe);
24562456

2457-
set_except_vector(MIPS_EXCCODE_TLBPAR, handle_ftlb);
2457+
if (cpu_has_ftlbparex)
2458+
set_except_vector(MIPS_EXCCODE_TLBPAR, handle_ftlb);
24582459

24592460
if (cpu_has_rixiex) {
24602461
set_except_vector(EXCCODE_TLBRI, tlb_do_page_fault_0);

0 commit comments

Comments
 (0)