From bd891015867ecd310abe94744e09360934e60cee Mon Sep 17 00:00:00 2001 From: Michal Meloun Date: Sun, 29 Nov 2020 18:59:01 +0000 Subject: [PATCH] Store MPIDR register in pcpu. MPIDR represents physical locality of given core and it should be used as the only viable/robust connection between cpuid (which have zero relation to cores topology) and external description (for example in FDT). It can be used for determining which interrupt is associated to given per-CPU PMU or by scheduler for determining big/little core or cluster topology. MFC after: 3 weeks --- sys/arm/arm/machdep.c | 3 +++ sys/arm/arm/mp_machdep.c | 1 + sys/arm/include/pcpu.h | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 53588ed358e..3296adaaa44 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -302,6 +302,8 @@ DELAY(int usec) void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) { + + pcpu->pc_mpidr = 0xffffffff; } void @@ -684,6 +686,7 @@ pcpu0_init(void) { set_curthread(&thread0); pcpu_init(pcpup, 0, sizeof(struct pcpu)); + pcpup->pc_mpidr = cp15_mpidr_get() & 0xFFFFFF; PCPU_SET(curthread, &thread0); } diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 7507eb6d59a..6368f7b72da 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -162,6 +162,7 @@ init_secondary(int cpu) ; pcpu_init(pc, cpu, sizeof(struct pcpu)); + pc->pc_mpidr = cp15_mpidr_get() & 0xFFFFFF; dpcpu_init(dpcpu[cpu - 1], cpu); #if defined(DDB) dbg_monitor_init_secondary(); diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h index b1b1f8bb3de..4d609b10bf7 100644 --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -65,7 +65,8 @@ struct vmspace; int pc_bp_harden_kind; \ uint32_t pc_original_actlr; \ uint64_t pc_clock; \ - char __pad[139] + uint32_t pc_mpidr; \ + char __pad[135] #ifdef _KERNEL