Commit 9246de4c authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

arm/arm64: smp: rename secondary_halt to do_idle

Also prepare the newly renamed function to come out of idle
and use sev/wfe rather than a busy wait in smp_run().
Signed-off-by: Andrew Jones's avatarAndrew Jones <>
Message-Id: <>
Signed-off-by: default avatarPaolo Bonzini <>
parent 4da93626
......@@ -119,7 +119,7 @@ secondary_entry:
/* r0 is now the entry function, run it */
blx r0
b secondary_halt
b do_idle
.globl halt
......@@ -80,7 +80,7 @@ secondary_entry:
/* x0 is now the entry function, run it */
blr x0
b secondary_halt
b do_idle
.globl halt
......@@ -11,12 +11,14 @@
#define smp_processor_id() (current_thread_info()->cpu)
extern void halt(void);
extern void do_idle(void);
extern cpumask_t cpu_present_mask;
extern cpumask_t cpu_online_mask;
extern cpumask_t cpu_halted_mask;
extern cpumask_t cpu_idle_mask;
#define cpu_present(cpu) cpumask_test_cpu(cpu, &cpu_present_mask)
#define cpu_online(cpu) cpumask_test_cpu(cpu, &cpu_online_mask)
#define cpu_idle(cpu) cpumask_test_cpu(cpu, &cpu_idle_mask)
#define for_each_present_cpu(cpu) for_each_cpu(cpu, &cpu_present_mask)
#define for_each_online_cpu(cpu) for_each_cpu(cpu, &cpu_online_mask)
......@@ -36,6 +38,14 @@ static inline void set_cpu_online(int cpu, bool online)
cpumask_clear_cpu(cpu, &cpu_online_mask);
static inline void set_cpu_idle(int cpu, bool idle)
if (idle)
cpumask_set_cpu(cpu, &cpu_idle_mask);
cpumask_clear_cpu(cpu, &cpu_idle_mask);
typedef void (*secondary_entry_fn)(void);
extern void smp_boot_secondary(int cpu, secondary_entry_fn entry);
extern void smp_run(void (*func)(void));
......@@ -16,7 +16,7 @@
cpumask_t cpu_present_mask;
cpumask_t cpu_online_mask;
cpumask_t cpu_halted_mask;
cpumask_t cpu_idle_mask;
struct secondary_data {
void *stack; /* must be first member of struct */
......@@ -68,12 +68,19 @@ void smp_boot_secondary(int cpu, secondary_entry_fn entry)
void secondary_halt(void)
void do_idle(void)
struct thread_info *ti = current_thread_info();
int cpu = smp_processor_id();
set_cpu_idle(cpu, true);
cpumask_set_cpu(ti->cpu, &cpu_halted_mask);
for (;;) {
while (cpu_idle(cpu))
set_cpu_idle(cpu, true);
void smp_run(void (*func)(void))
......@@ -87,8 +94,8 @@ void smp_run(void (*func)(void))
cpumask_set_cpu(0, &cpu_halted_mask);
while (!cpumask_full(&cpu_halted_mask))
cpumask_clear_cpu(0, &cpu_halted_mask);
set_cpu_idle(0, true);
while (!cpumask_full(&cpu_idle_mask))
set_cpu_idle(0, false);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment