Skip to content

Commit 1afde47

Browse files
committed
parisc: Find a new timesync master if current CPU is removed
When CPU hotplugging is enabled, the user may want to remove the current CPU which is providing the timer ticks. If this happens we need to find a new timesync master. Signed-off-by: Helge Deller <deller@gmx.de>
1 parent ca45ec3 commit 1afde47

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

arch/parisc/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct cpuinfo_parisc {
9595

9696
extern struct system_cpuinfo_parisc boot_cpu_data;
9797
DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
98+
extern int time_keeper_id; /* CPU used for timekeeping */
9899

99100
#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
100101

arch/parisc/kernel/smp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ int __cpu_disable(void)
465465
*/
466466
set_cpu_online(cpu, false);
467467

468+
/* Find a new timesync master */
469+
if (cpu == time_keeper_id) {
470+
time_keeper_id = cpumask_first(cpu_online_mask);
471+
pr_info("CPU %d is now promoted to time-keeper master\n", time_keeper_id);
472+
}
473+
468474
disable_percpu_irq(IPI_IRQ);
469475

470476
irq_migrate_all_off_this_cpu();

arch/parisc/kernel/time.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
#include <linux/timex.h>
4242

43+
int time_keeper_id __read_mostly; /* CPU used for timekeeping. */
44+
4345
static unsigned long clocktick __ro_after_init; /* timer cycles per tick */
4446

4547
/*
@@ -84,7 +86,7 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
8486
cpuinfo->it_value = next_tick;
8587

8688
/* Go do system house keeping. */
87-
if (cpu != 0)
89+
if (IS_ENABLED(CONFIG_SMP) && (cpu != time_keeper_id))
8890
ticks_elapsed = 0;
8991
legacy_timer_tick(ticks_elapsed);
9092

0 commit comments

Comments
 (0)