[Skiboot] [PATCH 3/6] core/cpu: refactor IPI sending

Nicholas Piggin npiggin at gmail.com
Tue Dec 22 03:10:39 AEDT 2020


Pull the IPI sending code into its own function where it is used in
two places.

cpu_wake() already checks in_idle, so its caller does not need to
check pm_enabled.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 core/cpu.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/core/cpu.c b/core/cpu.c
index 2c2b678ff..5505b681c 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -91,13 +91,8 @@ void __nomcount cpu_relax(void)
 	barrier();
 }
 
-static void cpu_wake(struct cpu_thread *cpu)
+static void cpu_send_ipi(struct cpu_thread *cpu)
 {
-	/* Is it idle ? If not, no need to wake */
-	sync();
-	if (!cpu->in_idle)
-		return;
-
 	if (proc_gen == proc_gen_p8) {
 		/* Poke IPI */
 		icp_kick_cpu(cpu);
@@ -106,6 +101,14 @@ static void cpu_wake(struct cpu_thread *cpu)
 	}
 }
 
+static void cpu_wake(struct cpu_thread *cpu)
+{
+	/* Is it idle ? If not, no need to wake */
+	sync();
+	if (cpu->in_idle)
+		cpu_send_ipi(cpu);
+}
+
 /*
  * If chip_id is >= 0, schedule the job on that node.
  * Otherwise schedule the job anywhere.
@@ -190,8 +193,7 @@ static void queue_job_on_cpu(struct cpu_thread *cpu, struct cpu_job *job)
 		cpu->job_has_no_return = true;
 	else
 		cpu->job_count++;
-	if (pm_enabled)
-		cpu_wake(cpu);
+	cpu_wake(cpu);
 	unlock(&cpu->job_lock);
 }
 
@@ -595,16 +597,9 @@ static void reconfigure_idle_start(void)
 	 */
 	sync();
 
-	if (proc_gen == proc_gen_p8) {
-		for_each_available_cpu(cpu) {
-			if (cpu->in_sleep || cpu->in_idle)
-				icp_kick_cpu(cpu);
-		}
-	} else if (proc_gen == proc_gen_p9) {
-		for_each_available_cpu(cpu) {
-			if (cpu->in_sleep || cpu->in_idle)
-				p9_dbell_send(cpu->pir);
-		}
+	for_each_available_cpu(cpu) {
+		if (cpu->in_sleep || cpu->in_idle)
+			cpu_send_ipi(cpu);
 	}
 
 	smt_lowest();
-- 
2.23.0



More information about the Skiboot mailing list