[Skiboot] [PATCH 25/34] cpu: Add cpu_idle() which we call when waiting for a job
Benjamin Herrenschmidt
benh at kernel.crashing.org
Sun Jul 24 09:27:19 AEST 2016
For now a simple generic implementation using cpu_relax()
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
core/cpu.c | 18 ++++++++++++++++++
core/init.c | 20 ++++----------------
include/cpu.h | 7 +++++++
3 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/core/cpu.c b/core/cpu.c
index 6dd841c..15c8fb9 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -212,6 +212,24 @@ void cpu_process_jobs(void)
unlock(&cpu->job_lock);
}
+static void cpu_idle_default(enum cpu_wake_cause wake_on __unused)
+{
+ /* Maybe do something better for simulators ? */
+ cpu_relax();
+ cpu_relax();
+ cpu_relax();
+ cpu_relax();
+}
+
+void cpu_idle(enum cpu_wake_cause wake_on)
+{
+ switch(proc_gen) {
+ default:
+ cpu_idle_default(wake_on);
+ break;
+ }
+}
+
void cpu_process_local_jobs(void)
{
struct cpu_thread *cpu = first_available_cpu();
diff --git a/core/init.c b/core/init.c
index bba7d96..237ccfb 100644
--- a/core/init.c
+++ b/core/init.c
@@ -866,22 +866,10 @@ void __noreturn __secondary_cpu_entry(void)
/* Wait for work to do */
while(true) {
- int i;
-
- /* Process pending jobs on this processor */
- cpu_process_jobs();
-
- /* Relax a bit to give the simulator some breathing space */
- i = 1000;
- smt_very_low();
- asm volatile("mtctr %0;\n"
- "1: nop; nop; nop; nop;\n"
- " nop; nop; nop; nop;\n"
- " nop; nop; nop; nop;\n"
- " nop; nop; nop; nop;\n"
- " bdnz 1b"
- : : "r" (i) : "memory", "ctr");
- smt_medium();
+ if (cpu_check_jobs(cpu))
+ cpu_process_jobs();
+ else
+ cpu_idle(cpu_wake_on_job);
}
}
diff --git a/include/cpu.h b/include/cpu.h
index 1188168..256fc5b 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -43,6 +43,11 @@ enum cpu_thread_state {
struct cpu_job;
struct xive_cpu_state;
+enum cpu_wake_cause {
+ cpu_wake_on_job,
+ cpu_wake_on_dec,
+};
+
struct cpu_thread {
uint32_t pir;
uint32_t server_no;
@@ -253,4 +258,6 @@ static inline void cpu_give_self_os(void)
extern unsigned long __attrconst cpu_stack_bottom(unsigned int pir);
extern unsigned long __attrconst cpu_stack_top(unsigned int pir);
+extern void cpu_idle(enum cpu_wake_cause wake_on);
+
#endif /* __CPU_H */
--
2.7.4
More information about the Skiboot
mailing list