@@ -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) {
@@ -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)
@@ -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))
@@ -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)
{