summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2019-05-29 04:42:59 -0400
committerPaul Burton <paul.burton@mips.com>2019-08-26 06:42:40 -0400
commitd2f965549006acb865c4638f1f030ebcefdc71f6 (patch)
tree26e5afbb10f7bf38b51aa276cafd52ec3d9e9cad
parent322e577b02ab096aaf630caae93f18e1e67b775f (diff)
MIPS: Treat Loongson Extensions as ASEs
Recently, binutils had split Loongson-3 Extensions into four ASEs: MMI, CAM, EXT, EXT2. This patch do the samething in kernel and expose them in cpuinfo so applications can probe supported ASEs at runtime. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: Huacai Chen <chenhc@lemote.com> Cc: Yunqiang Su <ysu@wavecomp.com> Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org
-rw-r--r--arch/mips/include/asm/cpu-features.h16
-rw-r--r--arch/mips/include/asm/cpu.h4
-rw-r--r--arch/mips/kernel/cpu-probe.c6
-rw-r--r--arch/mips/kernel/proc.c4
4 files changed, 30 insertions, 0 deletions
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 6998a9796499..4e2bea8875f5 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -397,6 +397,22 @@
397#define cpu_has_dsp3 __ase(MIPS_ASE_DSP3) 397#define cpu_has_dsp3 __ase(MIPS_ASE_DSP3)
398#endif 398#endif
399 399
400#ifndef cpu_has_loongson_mmi
401#define cpu_has_loongson_mmi __ase(MIPS_ASE_LOONGSON_MMI)
402#endif
403
404#ifndef cpu_has_loongson_cam
405#define cpu_has_loongson_cam __ase(MIPS_ASE_LOONGSON_CAM)
406#endif
407
408#ifndef cpu_has_loongson_ext
409#define cpu_has_loongson_ext __ase(MIPS_ASE_LOONGSON_EXT)
410#endif
411
412#ifndef cpu_has_loongson_ext2
413#define cpu_has_loongson_ext2 __ase(MIPS_ASE_LOONGSON_EXT2)
414#endif
415
400#ifndef cpu_has_mipsmt 416#ifndef cpu_has_mipsmt
401#define cpu_has_mipsmt __isa_lt_and_ase(6, MIPS_ASE_MIPSMT) 417#define cpu_has_mipsmt __isa_lt_and_ase(6, MIPS_ASE_MIPSMT)
402#endif 418#endif
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 6826f0a657fb..7fddcb8350c6 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -428,5 +428,9 @@ enum cpu_type_enum {
428#define MIPS_ASE_MSA 0x00000100 /* MIPS SIMD Architecture */ 428#define MIPS_ASE_MSA 0x00000100 /* MIPS SIMD Architecture */
429#define MIPS_ASE_DSP3 0x00000200 /* Signal Processing ASE Rev 3*/ 429#define MIPS_ASE_DSP3 0x00000200 /* Signal Processing ASE Rev 3*/
430#define MIPS_ASE_MIPS16E2 0x00000400 /* MIPS16e2 */ 430#define MIPS_ASE_MIPS16E2 0x00000400 /* MIPS16e2 */
431#define MIPS_ASE_LOONGSON_MMI 0x00000800 /* Loongson MultiMedia extensions Instructions */
432#define MIPS_ASE_LOONGSON_CAM 0x00001000 /* Loongson CAM */
433#define MIPS_ASE_LOONGSON_EXT 0x00002000 /* Loongson EXTensions */
434#define MIPS_ASE_LOONGSON_EXT2 0x00004000 /* Loongson EXTensions R2 */
431 435
432#endif /* _ASM_CPU_H */ 436#endif /* _ASM_CPU_H */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 93b46be14688..c2eb392597bf 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -1547,6 +1547,8 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
1547 __cpu_name[cpu] = "ICT Loongson-3"; 1547 __cpu_name[cpu] = "ICT Loongson-3";
1548 set_elf_platform(cpu, "loongson3a"); 1548 set_elf_platform(cpu, "loongson3a");
1549 set_isa(c, MIPS_CPU_ISA_M64R1); 1549 set_isa(c, MIPS_CPU_ISA_M64R1);
1550 c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM |
1551 MIPS_ASE_LOONGSON_EXT);
1550 break; 1552 break;
1551 case PRID_REV_LOONGSON3B_R1: 1553 case PRID_REV_LOONGSON3B_R1:
1552 case PRID_REV_LOONGSON3B_R2: 1554 case PRID_REV_LOONGSON3B_R2:
@@ -1554,6 +1556,8 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
1554 __cpu_name[cpu] = "ICT Loongson-3"; 1556 __cpu_name[cpu] = "ICT Loongson-3";
1555 set_elf_platform(cpu, "loongson3b"); 1557 set_elf_platform(cpu, "loongson3b");
1556 set_isa(c, MIPS_CPU_ISA_M64R1); 1558 set_isa(c, MIPS_CPU_ISA_M64R1);
1559 c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM |
1560 MIPS_ASE_LOONGSON_EXT);
1557 break; 1561 break;
1558 } 1562 }
1559 1563
@@ -1920,6 +1924,8 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
1920 decode_configs(c); 1924 decode_configs(c);
1921 c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE; 1925 c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE;
1922 c->writecombine = _CACHE_UNCACHED_ACCELERATED; 1926 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
1927 c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM |
1928 MIPS_ASE_LOONGSON_EXT | MIPS_ASE_LOONGSON_EXT2);
1923 break; 1929 break;
1924 default: 1930 default:
1925 panic("Unknown Loongson Processor ID!"); 1931 panic("Unknown Loongson Processor ID!");
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index b2de408a259e..f8d36710cd58 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -124,6 +124,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
124 if (cpu_has_eva) seq_printf(m, "%s", " eva"); 124 if (cpu_has_eva) seq_printf(m, "%s", " eva");
125 if (cpu_has_htw) seq_printf(m, "%s", " htw"); 125 if (cpu_has_htw) seq_printf(m, "%s", " htw");
126 if (cpu_has_xpa) seq_printf(m, "%s", " xpa"); 126 if (cpu_has_xpa) seq_printf(m, "%s", " xpa");
127 if (cpu_has_loongson_mmi) seq_printf(m, "%s", " loongson-mmi");
128 if (cpu_has_loongson_cam) seq_printf(m, "%s", " loongson-cam");
129 if (cpu_has_loongson_ext) seq_printf(m, "%s", " loongson-ext");
130 if (cpu_has_loongson_ext2) seq_printf(m, "%s", " loongson-ext2");
127 seq_printf(m, "\n"); 131 seq_printf(m, "\n");
128 132
129 if (cpu_has_mmips) { 133 if (cpu_has_mmips) {