@@ -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) {
@@ -846,7 +846,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)
@@ -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))
@@ -242,6 +242,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)
{
cpu_get_core_index() currently uses pir_to_core_id() which returns an EC number always (ie, a small 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@kernel.crashing.org> --- core/chip.c | 13 +++++++++++++ core/cpu.c | 2 +- include/chip.h | 5 +++++ include/cpu.h | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-)