diff options
author | Paul Burton <paul.burton@imgtec.com> | 2017-08-12 19:49:35 -0700 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-08-30 00:57:26 +0200 |
commit | f875a832d2028523f9b53c261b67e05a359bab8b (patch) | |
tree | db7934e092508a34db756e9906738ea4ab50e653 /arch/mips/include | |
parent | 15e6529fc337309e699dbb71827362fcd9c616ae (diff) | |
download | blackbird-obmc-linux-f875a832d2028523f9b53c261b67e05a359bab8b.tar.gz blackbird-obmc-linux-f875a832d2028523f9b53c261b67e05a359bab8b.zip |
MIPS: Abstract CPU core & VP(E) ID access through accessor functions
We currently have fields in struct cpuinfo_mips for the core & VP(E) ID
of a particular CPU, and various pieces of code directly access those
fields. This patch abstracts such access by introducing accessor
functions cpu_core(), cpu_set_core(), cpu_vpe_id() & cpu_set_vpe_id()
and having code that needs to access these values call those functions
rather than directly accessing the struct cpuinfo_mips fields. This
prepares us for changes to the way in which those values are stored in
later patches.
The cpu_vpe_id() function is introduced even though we already had a
cpu_vpe_id() macro for a couple of reasons:
1) It's more consistent with the core, and future cluster, accessors.
2) It ensures a sensible return type without explicit casts.
3) It's generally preferable to use functions rather than macros.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17009/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include')
-rw-r--r-- | arch/mips/include/asm/cpu-info.h | 27 | ||||
-rw-r--r-- | arch/mips/include/asm/mips-cm.h | 2 | ||||
-rw-r--r-- | arch/mips/include/asm/topology.h | 2 |
3 files changed, 26 insertions, 5 deletions
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h index cd6efb07c980..2b2f97023705 100644 --- a/arch/mips/include/asm/cpu-info.h +++ b/arch/mips/include/asm/cpu-info.h @@ -144,11 +144,32 @@ struct proc_cpuinfo_notifier_args { unsigned long n; }; +static inline unsigned int cpu_core(struct cpuinfo_mips *cpuinfo) +{ + return cpuinfo->core; +} + +static inline void cpu_set_core(struct cpuinfo_mips *cpuinfo, + unsigned int core) +{ + cpuinfo->core = core; +} + +static inline unsigned int cpu_vpe_id(struct cpuinfo_mips *cpuinfo) +{ #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6) -# define cpu_vpe_id(cpuinfo) ((cpuinfo)->vpe_id) -#else -# define cpu_vpe_id(cpuinfo) ({ (void)cpuinfo; 0; }) + return cpuinfo->vpe_id; #endif + return 0; +} + +static inline void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, + unsigned int vpe) +{ +#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6) + cpuinfo->vpe_id = vpe; +#endif +} static inline unsigned long cpu_asid_inc(void) { diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h index 225586bdd81c..6cfc0cc265d7 100644 --- a/arch/mips/include/asm/mips-cm.h +++ b/arch/mips/include/asm/mips-cm.h @@ -428,7 +428,7 @@ static inline unsigned int mips_cm_max_vp_width(void) */ static inline unsigned int mips_cm_vp_id(unsigned int cpu) { - unsigned int core = cpu_data[cpu].core; + unsigned int core = cpu_core(&cpu_data[cpu]); unsigned int vp = cpu_vpe_id(&cpu_data[cpu]); return (core * mips_cm_max_vp_width()) + vp; diff --git a/arch/mips/include/asm/topology.h b/arch/mips/include/asm/topology.h index 7afda4150a59..0673d2d0f2e6 100644 --- a/arch/mips/include/asm/topology.h +++ b/arch/mips/include/asm/topology.h @@ -13,7 +13,7 @@ #ifdef CONFIG_SMP #define topology_physical_package_id(cpu) (cpu_data[cpu].package) -#define topology_core_id(cpu) (cpu_data[cpu].core) +#define topology_core_id(cpu) (cpu_core(&cpu_data[cpu])) #define topology_core_cpumask(cpu) (&cpu_core_map[cpu]) #define topology_sibling_cpumask(cpu) (&cpu_sibling_map[cpu]) #endif |