Skip to content

Commit c38fdc4

Browse files
ozbenhstewartsmith
authored andcommitted
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>
1 parent ee5c9e9 commit c38fdc4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

core/cpu.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,20 @@ struct cpu_thread *first_available_cpu(void)
494494
return next_available_cpu(NULL);
495495
}
496496

497+
struct cpu_thread *next_present_cpu(struct cpu_thread *cpu)
498+
{
499+
do {
500+
cpu = next_cpu(cpu);
501+
} while(cpu && !cpu_is_present(cpu));
502+
503+
return cpu;
504+
}
505+
506+
struct cpu_thread *first_present_cpu(void)
507+
{
508+
return next_present_cpu(NULL);
509+
}
510+
497511
u8 get_available_nr_cores_in_chip(u32 chip_id)
498512
{
499513
struct cpu_thread *core;

include/cpu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ extern struct cpu_thread *next_cpu(struct cpu_thread *cpu);
165165
* this API standpoint.
166166
*/
167167

168+
static inline bool cpu_is_present(struct cpu_thread *cpu)
169+
{
170+
return cpu->state >= cpu_state_present;
171+
}
172+
168173
static inline bool cpu_is_available(struct cpu_thread *cpu)
169174
{
170175
return cpu->state == cpu_state_active ||
@@ -173,13 +178,18 @@ static inline bool cpu_is_available(struct cpu_thread *cpu)
173178

174179
extern struct cpu_thread *first_available_cpu(void);
175180
extern struct cpu_thread *next_available_cpu(struct cpu_thread *cpu);
181+
extern struct cpu_thread *first_present_cpu(void);
182+
extern struct cpu_thread *next_present_cpu(struct cpu_thread *cpu);
176183

177184
#define for_each_cpu(cpu) \
178185
for (cpu = first_cpu(); cpu; cpu = next_cpu(cpu))
179186

180187
#define for_each_available_cpu(cpu) \
181188
for (cpu = first_available_cpu(); cpu; cpu = next_available_cpu(cpu))
182189

190+
#define for_each_present_cpu(cpu) \
191+
for (cpu = first_present_cpu(); cpu; cpu = next_present_cpu(cpu))
192+
183193
extern struct cpu_thread *first_available_core_in_chip(u32 chip_id);
184194
extern struct cpu_thread *next_available_core_in_chip(struct cpu_thread *cpu, u32 chip_id);
185195
extern u8 get_available_nr_cores_in_chip(u32 chip_id);

0 commit comments

Comments
 (0)