Skip to content
Open
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
11 changes: 10 additions & 1 deletion arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,17 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
*/
wait_for_completion_timeout(&cpu_running,
msecs_to_jiffies(5000));
if (cpu_online(cpu))
if (cpu_online(cpu)) {
/*
* The CPU has taken its task. Cleared, as kernels before 5.x did, so a core that
* reaches __secondary_switched without a bring-up of its own waits in
* __secondary_too_slow instead of running as this CPU a second time.
*/
WRITE_ONCE(secondary_data.task, NULL);
dcache_clean_inval_poc((unsigned long)&secondary_data,
(unsigned long)&secondary_data + sizeof(secondary_data));
return 0;
}

pr_crit("CPU%u: failed to come online\n", cpu);
secondary_data.task = NULL;
Expand Down
13 changes: 13 additions & 0 deletions arch/arm64/kernel/smp_spin_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ int spin_table_hold_parked(void)
int us, ret;
unsigned int cpu;

/* No CPU restarted from here to the wake may pass the pen without its own bring-up. */
write_pen_release(INVALID_HWID);

for_each_present_cpu(cpu)
WRITE_ONCE(spin_table_hold_error[cpu], 0);
WRITE_ONCE(spin_table_hold_generation, READ_ONCE(spin_table_hold_generation) + 1);
Expand Down Expand Up @@ -331,6 +334,8 @@ void spin_table_stop_finished(void)
/* Before any CPU is started again: the pen must let them boot. */
if (secondary_pen_deep)
spin_table_pen_deep_set(0);
/* ...but only the one its bring-up releases (cores started early wait in the pen). */
write_pen_release(INVALID_HWID);
WRITE_ONCE(spin_table_hold_requested, false);
WRITE_ONCE(spin_table_stop_requested, false);
WRITE_ONCE(spin_table_stop_released, false);
Expand Down Expand Up @@ -473,6 +478,14 @@ static int smp_rvbar_spin_table_cpu_kill(unsigned int cpu)

static void smp_rvbar_spin_table_postboot(void)
{
/*
* Close the pen behind this CPU. Left at its MPIDR, the next restart at the reset vector
* (after a sleep's commit, or a platform that starts every core at once at the wake)
* lets it straight through the pen into secondary_startup ahead of its own bring-up,
* with the secondary_data of its last boot: it then runs as that CPU with no STARTING
* callbacks run, e.g. without a tick device.
*/
write_pen_release(INVALID_HWID);
cpumask_clear_cpu(smp_processor_id(), &spin_table_cpus_off);
if (READ_ONCE(spin_table_power) && spin_table_power->cpu_restore)
spin_table_power->cpu_restore(read_cpuid_mpidr() & MPIDR_HWID_BITMASK);
Expand Down
Loading