[Skiboot] [PATCH 1/2] cpu: Add iterators for "present" CPUs
Benjamin Herrenschmidt
benh at kernel.crashing.org
Fri Dec 30 13:25:20 AEDT 2016
Some code path want to look at all the CPUs that are "present",
which means they have been enabled by HB/Cronus and can be accessed
via XSCOMs, even if they haven't called in yet.
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
core/cpu.c | 14 ++++++++++++++
include/cpu.h | 10 ++++++++++
2 files changed, 24 insertions(+)
diff --git a/core/cpu.c b/core/cpu.c
index 5d76adf..c7e650d 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -494,6 +494,20 @@ struct cpu_thread *first_available_cpu(void)
return next_available_cpu(NULL);
}
+struct cpu_thread *next_present_cpu(struct cpu_thread *cpu)
+{
+ do {
+ cpu = next_cpu(cpu);
+ } while(cpu && !cpu_is_present(cpu));
+
+ return cpu;
+}
+
+struct cpu_thread *first_present_cpu(void)
+{
+ return next_present_cpu(NULL);
+}
+
u8 get_available_nr_cores_in_chip(u32 chip_id)
{
struct cpu_thread *core;
diff --git a/include/cpu.h b/include/cpu.h
index f649a13..1e147aa 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -165,6 +165,11 @@ extern struct cpu_thread *next_cpu(struct cpu_thread *cpu);
* this API standpoint.
*/
+static inline bool cpu_is_present(struct cpu_thread *cpu)
+{
+ return cpu->state >= cpu_state_present;
+}
+
static inline bool cpu_is_available(struct cpu_thread *cpu)
{
return cpu->state == cpu_state_active ||
@@ -173,6 +178,8 @@ static inline bool cpu_is_available(struct cpu_thread *cpu)
extern struct cpu_thread *first_available_cpu(void);
extern struct cpu_thread *next_available_cpu(struct cpu_thread *cpu);
+extern struct cpu_thread *first_present_cpu(void);
+extern struct cpu_thread *next_present_cpu(struct cpu_thread *cpu);
#define for_each_cpu(cpu) \
for (cpu = first_cpu(); cpu; cpu = next_cpu(cpu))
@@ -180,6 +187,9 @@ extern struct cpu_thread *next_available_cpu(struct cpu_thread *cpu);
#define for_each_available_cpu(cpu) \
for (cpu = first_available_cpu(); cpu; cpu = next_available_cpu(cpu))
+#define for_each_present_cpu(cpu) \
+ for (cpu = first_present_cpu(); cpu; cpu = next_present_cpu(cpu))
+
extern struct cpu_thread *first_available_core_in_chip(u32 chip_id);
extern struct cpu_thread *next_available_core_in_chip(struct cpu_thread *cpu, u32 chip_id);
extern u8 get_available_nr_cores_in_chip(u32 chip_id);
More information about the Skiboot
mailing list