Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Add CPU cluster number accessors

Introduce cpu_cluster() & cpu_set_cluster() accessor functions in the
same vein as cpu_core(), cpu_vpe_id() & their set variants. These will
be used in further patches to allow users to get or set a CPUs cluster
number.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17012/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
5616897e fe7a38c6

+21
+11
arch/mips/include/asm/cpu-info.h
··· 139 139 unsigned long n; 140 140 }; 141 141 142 + static inline unsigned int cpu_cluster(struct cpuinfo_mips *cpuinfo) 143 + { 144 + /* Optimisation for systems where multiple clusters aren't used */ 145 + if (!IS_ENABLED(CONFIG_CPU_MIPSR6)) 146 + return 0; 147 + 148 + return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CLUSTER) >> 149 + MIPS_GLOBALNUMBER_CLUSTER_SHF; 150 + } 151 + 142 152 static inline unsigned int cpu_core(struct cpuinfo_mips *cpuinfo) 143 153 { 144 154 return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CORE) >> ··· 165 155 MIPS_GLOBALNUMBER_VP_SHF; 166 156 } 167 157 158 + extern void cpu_set_cluster(struct cpuinfo_mips *cpuinfo, unsigned int cluster); 168 159 extern void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core); 169 160 extern void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, unsigned int vpe); 170 161
+10
arch/mips/kernel/cpu-probe.c
··· 2099 2099 pr_info("MSA revision is: %08x\n", c->msa_id); 2100 2100 } 2101 2101 2102 + void cpu_set_cluster(struct cpuinfo_mips *cpuinfo, unsigned int cluster) 2103 + { 2104 + /* Ensure the core number fits in the field */ 2105 + WARN_ON(cluster > (MIPS_GLOBALNUMBER_CLUSTER >> 2106 + MIPS_GLOBALNUMBER_CLUSTER_SHF)); 2107 + 2108 + cpuinfo->globalnumber &= ~MIPS_GLOBALNUMBER_CLUSTER; 2109 + cpuinfo->globalnumber |= cluster << MIPS_GLOBALNUMBER_CLUSTER_SHF; 2110 + } 2111 + 2102 2112 void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core) 2103 2113 { 2104 2114 /* Ensure the core number fits in the field */