Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm64/include/asm/cpu_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ struct spin_table_power_ops {
int (*cpu_on)(u64 mpidr);
};

struct cpumask;

#ifdef CONFIG_HOTPLUG_CPU
int spin_table_set_power_ops(const struct spin_table_power_ops *ops);
int spin_table_hold_parked(void);
void spin_table_unhold_parked(void);
int spin_table_stop_parked(void);
void spin_table_release_stopped(void);
void spin_table_release_cpus(const struct cpumask *cpus);
void spin_table_stop_finished(void);
bool spin_table_cpus_stuck(void);
#else
Expand All @@ -90,6 +93,7 @@ static inline int spin_table_stop_parked(void)
}

static inline void spin_table_release_stopped(void) {}
static inline void spin_table_release_cpus(const struct cpumask *cpus) {}
static inline void spin_table_stop_finished(void) {}

static inline int spin_table_set_power_ops(const struct spin_table_power_ops *ops)
Expand Down
17 changes: 16 additions & 1 deletion arch/arm64/kernel/smp_spin_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ static u32 spin_table_hold_generation, spin_table_held_generation[NR_CPUS];
static bool spin_table_hold_requested;
static bool spin_table_stop_requested;
static bool spin_table_stop_released;
/* Stopped CPUs released to their last WFI ahead of the others: spin_table_release_cpus() */
static struct cpumask spin_table_cpus_early;

#define SPIN_TABLE_WAIT_US 100000

Expand Down Expand Up @@ -265,6 +267,17 @@ int spin_table_stop_parked(void)
return -ETIMEDOUT;
}

/*
* At the commit, after spin_table_stop_parked(): the stopped CPUs in @cpus take their last WFI
* now, ahead of the others, which wait for spin_table_release_stopped().
*/
void spin_table_release_cpus(const struct cpumask *cpus)
{
cpumask_or(&spin_table_cpus_early, &spin_table_cpus_early, cpus);
dsb(ish);
sev();
}

/* After the commit: the stopped CPUs take their last WFI. */
void spin_table_release_stopped(void)
{
Expand All @@ -282,6 +295,7 @@ void spin_table_stop_finished(void)
WRITE_ONCE(spin_table_hold_requested, false);
WRITE_ONCE(spin_table_stop_requested, false);
WRITE_ONCE(spin_table_stop_released, false);
cpumask_clear(&spin_table_cpus_early);
cpumask_or(&spin_table_cpus_off, &spin_table_cpus_off, &spin_table_cpus_parked);
cpumask_clear(&spin_table_cpus_parked);
cpumask_clear(&spin_table_cpus_held);
Expand Down Expand Up @@ -363,7 +377,8 @@ static void smp_rvbar_spin_table_hold(unsigned int cpu, u64 mpidr)
cpumask_clear_cpu(cpu, &spin_table_cpus_held);
cpumask_clear_cpu(cpu, &spin_table_cpus_parked);

while (!READ_ONCE(spin_table_stop_released))
while (!READ_ONCE(spin_table_stop_released) &&
!cpumask_test_cpu(cpu, &spin_table_cpus_early))
wfe();
spin_table_power->cpu_off(mpidr);
}
Expand Down
Loading