diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2016-12-30 13:25:20 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-01-05 15:41:02 +1100 |
commit | c38fdc4908aa64819e17fd6fb7ce66bda2c56bdc (patch) | |
tree | a9b6121293893342461bc374f66758e81f654661 | |
parent | ee5c9e9cd107a44656ac1bfb5a52d99c39897881 (diff) | |
download | skiboot-c38fdc4908aa64819e17fd6fb7ce66bda2c56bdc.zip skiboot-c38fdc4908aa64819e17fd6fb7ce66bda2c56bdc.tar.gz skiboot-c38fdc4908aa64819e17fd6fb7ce66bda2c56bdc.tar.bz2 |
cpu: Add iterators for "present" CPUs
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@kernel.crashing.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | core/cpu.c | 14 | ||||
-rw-r--r-- | include/cpu.h | 10 |
2 files changed, 24 insertions, 0 deletions
@@ -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); |