[Skiboot] [PATCH v5 07/10] cpu: Make cpu_get_core_index() return the fused core number
Vaidyanathan Srinivasan
svaidy at linux.ibm.com
Wed Apr 22 15:04:16 AEST 2020
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 c57694ab..f1269d3f 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -34,6 +34,19 @@ uint32_t pir_to_core_id(uint32_t pir)
assert(false);
}
+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
+ assert(false);
+}
+
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 88d0b886..bc8b4493 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -866,7 +866,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 eed3839d..69d49dea 100644
--- a/include/chip.h
+++ b/include/chip.h
@@ -236,6 +236,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 5f8682bd..c8cb7664 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -220,6 +220,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.26.1
More information about the Skiboot
mailing list