Commit 8270ab48 authored by Matt Redfearn's avatar Matt Redfearn Committed by James Hogan

MIPS: Probe for MIPS MT perf counters per TC

Processors implementing the MIPS MT ASE may have performance counters
implemented per core or per TC. Processors implemented by MIPS
Technologies signify presence per TC through a bit in the implementation
specific Config7 register. Currently the code which probes for their
presence blindly reads a magic number corresponding to this bit, despite
it potentially having a different meaning in the CPU implementation.

Since CPU features are generally detected by cpu-probe.c, perform the
detection here instead. Introduce cpu_set_mt_per_tc_perf which checks
the bit in config7 and call it from MIPS CPUs known to implement this
bit and the MT ASE, specifically, the 34K, 1004K and interAptiv.

Once the presence of the per-tc counter is indicated in cpu_data, tests
for it can be updated to use this flag.
Suggested-by: default avatarJames Hogan <jhogan@kernel.org>
Signed-off-by: default avatarMatt Redfearn <matt.redfearn@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Matt Redfearn <matt.redfearn@mips.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Maciej W. Rozycki <macro@mips.com>
Cc: linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/19136/Signed-off-by: default avatarJames Hogan <jhogan@kernel.org>
parent 8798e392
...@@ -418,6 +418,8 @@ enum cpu_type_enum { ...@@ -418,6 +418,8 @@ enum cpu_type_enum {
MBIT_ULL(54) /* CPU shares FTLB RAM with another */ MBIT_ULL(54) /* CPU shares FTLB RAM with another */
#define MIPS_CPU_SHARED_FTLB_ENTRIES \ #define MIPS_CPU_SHARED_FTLB_ENTRIES \
MBIT_ULL(55) /* CPU shares FTLB entries with another */ MBIT_ULL(55) /* CPU shares FTLB entries with another */
#define MIPS_CPU_MT_PER_TC_PERF_COUNTERS \
MBIT_ULL(56) /* CPU has perf counters implemented per TC (MIPSMT ASE) */
/* /*
* CPU ASE encodings * CPU ASE encodings
......
...@@ -685,6 +685,11 @@ ...@@ -685,6 +685,11 @@
#define MIPS_CONF7_IAR (_ULCAST_(1) << 10) #define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
#define MIPS_CONF7_AR (_ULCAST_(1) << 16) #define MIPS_CONF7_AR (_ULCAST_(1) << 16)
/* Config7 Bits specific to MIPS Technologies. */
/* Performance counters implemented Per TC */
#define MTI_CONF7_PTC (_ULCAST_(1) << 19)
/* WatchLo* register definitions */ /* WatchLo* register definitions */
#define MIPS_WATCHLO_IRW (_ULCAST_(0x7) << 0) #define MIPS_WATCHLO_IRW (_ULCAST_(0x7) << 0)
......
...@@ -414,6 +414,14 @@ static int __init ftlb_disable(char *s) ...@@ -414,6 +414,14 @@ static int __init ftlb_disable(char *s)
__setup("noftlb", ftlb_disable); __setup("noftlb", ftlb_disable);
/*
* Check if the CPU has per tc perf counters
*/
static inline void cpu_set_mt_per_tc_perf(struct cpuinfo_mips *c)
{
if (read_c0_config7() & MTI_CONF7_PTC)
c->options |= MIPS_CPU_MT_PER_TC_PERF_COUNTERS;
}
static inline void check_errata(void) static inline void check_errata(void)
{ {
...@@ -1572,6 +1580,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) ...@@ -1572,6 +1580,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
c->cputype = CPU_34K; c->cputype = CPU_34K;
c->writecombine = _CACHE_UNCACHED; c->writecombine = _CACHE_UNCACHED;
__cpu_name[cpu] = "MIPS 34Kc"; __cpu_name[cpu] = "MIPS 34Kc";
cpu_set_mt_per_tc_perf(c);
break; break;
case PRID_IMP_74K: case PRID_IMP_74K:
c->cputype = CPU_74K; c->cputype = CPU_74K;
...@@ -1592,6 +1601,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) ...@@ -1592,6 +1601,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
c->cputype = CPU_1004K; c->cputype = CPU_1004K;
c->writecombine = _CACHE_UNCACHED; c->writecombine = _CACHE_UNCACHED;
__cpu_name[cpu] = "MIPS 1004Kc"; __cpu_name[cpu] = "MIPS 1004Kc";
cpu_set_mt_per_tc_perf(c);
break; break;
case PRID_IMP_1074K: case PRID_IMP_1074K:
c->cputype = CPU_1074K; c->cputype = CPU_1074K;
...@@ -1601,10 +1611,12 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) ...@@ -1601,10 +1611,12 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
case PRID_IMP_INTERAPTIV_UP: case PRID_IMP_INTERAPTIV_UP:
c->cputype = CPU_INTERAPTIV; c->cputype = CPU_INTERAPTIV;
__cpu_name[cpu] = "MIPS interAptiv"; __cpu_name[cpu] = "MIPS interAptiv";
cpu_set_mt_per_tc_perf(c);
break; break;
case PRID_IMP_INTERAPTIV_MP: case PRID_IMP_INTERAPTIV_MP:
c->cputype = CPU_INTERAPTIV; c->cputype = CPU_INTERAPTIV;
__cpu_name[cpu] = "MIPS interAptiv (multi)"; __cpu_name[cpu] = "MIPS interAptiv (multi)";
cpu_set_mt_per_tc_perf(c);
break; break;
case PRID_IMP_PROAPTIV_UP: case PRID_IMP_PROAPTIV_UP:
c->cputype = CPU_PROAPTIV; c->cputype = CPU_PROAPTIV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment