[v4,4/8] cpu: Keep track of the "ec_primary" in big core more
diff mbox series

Message ID 20200226101752.122998-5-svaidy@linux.vnet.ibm.com
State New
Headers show
Series
  • Initial fused-core support for POWER9
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (82aed17a5468aff6b600ee1694a10a60f942c018)

Commit Message

Vaidyanathan Srinivasan Feb. 26, 2020, 10:17 a.m. UTC
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

The "EC" primary is the primary thread of an EC, ie, the corresponding
small core "half" of the big core where the thread resides.

It will be necessary for the direct controls to target the right
half when doing special wakeups among others.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 core/cpu.c    | 20 ++++++++++++++------
 include/cpu.h |  1 +
 2 files changed, 15 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/core/cpu.c b/core/cpu.c
index 489cad56..98428dfb 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -823,9 +823,11 @@  struct cpu_thread *first_ungarded_cpu(void)
 
 struct cpu_thread *next_ungarded_primary(struct cpu_thread *cpu)
 {
+	bool is_primary;
 	do {
 		cpu = next_cpu(cpu);
-	} while(cpu && (cpu->state == cpu_state_unavailable || cpu->primary != cpu));
+		is_primary = cpu == cpu->primary || cpu == cpu->ec_primary;
+	} while(cpu && (cpu->state == cpu_state_unavailable || !is_primary));
 
 	return cpu;
 }
@@ -1165,7 +1167,7 @@  void init_all_cpus(void)
 		unsigned int pir, server_no, chip_id, threads;
 		enum cpu_thread_state state;
 		const struct dt_property *p;
-		struct cpu_thread *t, *pt;
+		struct cpu_thread *t, *pt0, *pt1;
 
 		/* Skip cache nodes */
 		if (strcmp(dt_prop_get(cpu, "device_type"), "cpu"))
@@ -1200,14 +1202,18 @@  void init_all_cpus(void)
 
 		/* Setup thread 0 */
 		assert(pir <= cpu_max_pir);
-		t = pt = &cpu_stacks[pir].cpu;
+		t = pt0 = &cpu_stacks[pir].cpu;
 		if (t != boot_cpu) {
 			init_cpu_thread(t, state, pir);
 			/* Each cpu gets its own later in init_trace_buffers */
 			t->trace = boot_cpu->trace;
 		}
+		if (t->is_fused_core)
+			pt1 = &cpu_stacks[pir + 1].cpu;
+		else
+			pt1 = pt0;
 		t->server_no = server_no;
-		t->primary = t;
+		t->primary = t->ec_primary = t;
 		t->node = cpu;
 		t->chip_id = chip_id;
 		t->icp_regs = NULL; /* Will be set later */
@@ -1245,10 +1251,12 @@  void init_all_cpus(void)
 			t->trace = boot_cpu->trace;
 			t->server_no = dt_property_get_cell(p, thread);
 			t->is_secondary = true;
-			t->primary = pt;
+			t->is_fused_core = pt0->is_fused_core;
+			t->primary = pt0;
+			t->ec_primary = (thread & 1) ? pt1 : pt0;
 			t->node = cpu;
 			t->chip_id = chip_id;
-			t->core_hmi_state_ptr = &pt->core_hmi_state;
+			t->core_hmi_state_ptr = &pt0->core_hmi_state;
 		}
 		prlog(PR_INFO, "CPU:  %d secondary threads\n", thread);
 	}
diff --git a/include/cpu.h b/include/cpu.h
index 05bd0941..5f8682bd 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -43,6 +43,7 @@  struct cpu_thread {
 	bool				is_secondary;
 	bool				is_fused_core;
 	struct cpu_thread		*primary;
+	struct cpu_thread		*ec_primary;
 	enum cpu_thread_state		state;
 	struct dt_node			*node;
 	struct trace_info		*trace;