[Skiboot] [PATCH v3 7/8] cpu: Make cpu_get_core_index() return the fused core number

Vaidyanathan Srinivasan svaidy at linux.vnet.ibm.com
Mon Mar 25 04:25:42 AEDT 2019


From: Benjamin Herrenschmidt <benh at kernel.crashing.org>

cpu_get_core_index() currently uses pir_to_core_id() which returns
an EC number always (ie, a normal core number) even in fused core
mode. This is inconsistent with cpu_get_thread_index() which returns
a thread within a fused core (0...7) on P9.

So let's make things consistent and document it.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 core/chip.c    | 13 +++++++++++++
 core/cpu.c     |  2 +-
 include/chip.h |  5 +++++
 include/cpu.h  |  6 ++++++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/core/chip.c b/core/chip.c
index 902327e1..60c7a6e7 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -48,6 +48,19 @@ uint32_t pir_to_core_id(uint32_t pir)
 		return P7_PIR2COREID(pir);
 }
 
+uint32_t pir_to_fused_core_id(uint32_t pir)
+{
+	if (proc_gen == proc_gen_p9) {
+		if (this_cpu()->is_fused_core)
+			return P9_PIR2FUSEDCOREID(pir);
+		else
+			return P9_PIR2COREID(pir);
+	} else if (proc_gen == proc_gen_p8)
+		return P8_PIR2COREID(pir);
+	else
+		return P7_PIR2COREID(pir);
+}
+
 uint32_t pir_to_thread_id(uint32_t pir)
 {
 	if (proc_gen == proc_gen_p9) {
diff --git a/core/cpu.c b/core/cpu.c
index 010a2570..0ce09a33 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -875,7 +875,7 @@ struct cpu_thread *first_available_core_in_chip(u32 chip_id)
 
 uint32_t cpu_get_core_index(struct cpu_thread *cpu)
 {
-	return pir_to_core_id(cpu->pir);
+	return pir_to_fused_core_id(cpu->pir);
 }
 
 void cpu_remove_node(const struct cpu_thread *t)
diff --git a/include/chip.h b/include/chip.h
index afb2e3e9..72d4bafe 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -268,6 +268,11 @@ extern uint32_t pir_to_chip_id(uint32_t pir);
 extern uint32_t pir_to_core_id(uint32_t pir);
 extern uint32_t pir_to_thread_id(uint32_t pir);
 
+/* In P9 fused core mode, this is the "fused" core ID, in
+ * normal core mode or P8, this is the same as pir_to_core_id
+ */
+extern uint32_t pir_to_fused_core_id(uint32_t pir);
+
 extern struct proc_chip *next_chip(struct proc_chip *chip);
 
 #define for_each_chip(__c) for (__c=next_chip(NULL); __c; __c=next_chip(__c))
diff --git a/include/cpu.h b/include/cpu.h
index ba222882..52d424e6 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -233,6 +233,12 @@ static inline __nomcount struct cpu_thread *this_cpu(void)
 	return __this_cpu;
 }
 
+/*
+ * Note: On POWER9 fused core, cpu_get_thread_index() and cpu_get_core_index()
+ * return respectively the thread number within a fused core (0..7) and
+ * the fused core number. If you want the EC (small core) number, you have
+ * to use the low level pir_to_core_id() and pir_to_thread_id().
+ */
 /* Get the thread # of a cpu within the core */
 static inline uint32_t cpu_get_thread_index(struct cpu_thread *cpu)
 {
-- 
2.20.1



More information about the Skiboot mailing list