From: Abhishek Paliwal <abhishek.pali...@aricent.com>

From: David Daney <david.da...@cavium.com>

commit  45b585c8dcdc469bb40b58cc2801acd7a2332525 upstream

This returns the CPUNum from the low order Ebase bits.

Signed-off-by: David Daney <david.da...@cavium.com>
Signed-off-by: Andreas Herrmann <andreas.herrm...@caviumnetworks.com>
Cc: linux-m...@linux-mips.org
Cc: James Hogan <james.ho...@imgtec.com>
Cc: k...@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/7012/
Signed-off-by: Ralf Baechle <r...@linux-mips.org>
Signed-off-by: Abhishek Paliwal <abhishek.pali...@aricent.com>
---
 arch/mips/include/asm/mipsregs.h | 8 ++++++++
 arch/mips/kernel/cpu-probe.c     | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index bbc3dd4..327f989 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1894,6 +1894,14 @@ __BUILD_SET_C0(brcm_cmt_ctrl)
 __BUILD_SET_C0(brcm_config)
 __BUILD_SET_C0(brcm_mode)
 
+/*
+ * Return low 10 bits of ebase.
+ * Note that under KVM (MIPSVZ) this returns vcpu id.
+ */
+static inline unsigned int get_ebase_cpunum(void)
+{
+       return read_c0_ebase() & 0x3ff;
+}
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_MIPSREGS_H */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 530f832..19432da 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -399,7 +399,7 @@ static void decode_configs(struct cpuinfo_mips *c)
        mips_probe_watch_registers(c);
 
        if (cpu_has_mips_r2)
-               c->core = read_c0_ebase() & 0x3ff;
+               c->core = get_ebase_cpunum();
 }
 
 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
-- 
1.8.1.4

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to