Skip to content

Commit c8d2bcc

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
MIPS: SMP_CPS: Switch to hotplug core state synchronization
Switch to the CPU hotplug core state tracking and synchronization mechanim. This unfortunately requires to add dead reporting to the non CPS platforms as CPS is the only user, but it allows an overall consolidation of this functionality. No functional change intended. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Michael Kelley <mikelley@microsoft.com> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Tested-by: Helge Deller <deller@gmx.de> # parisc Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com> # Steam Deck Link: https://lore.kernel.org/r/20230512205256.803238859@linutronix.de
1 parent 7202e97 commit c8d2bcc

7 files changed

Lines changed: 18 additions & 9 deletions

File tree

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,7 @@ config MIPS_CPS
22852285
select MIPS_CM
22862286
select MIPS_CPS_PM if HOTPLUG_CPU
22872287
select SMP
2288+
select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU
22882289
select SYNC_R4K if (CEVT_R4K || CSRC_R4K)
22892290
select SYS_SUPPORTS_HOTPLUG_CPU
22902291
select SYS_SUPPORTS_SCHED_SMT if CPU_MIPSR6

arch/mips/cavium-octeon/smp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ void play_dead(void)
345345
int cpu = cpu_number_map(cvmx_get_core_num());
346346

347347
idle_task_exit();
348+
cpuhp_ap_report_dead();
348349
octeon_processor_boot = 0xff;
349350
per_cpu(cpu_state, cpu) = CPU_DEAD;
350351

arch/mips/include/asm/smp-ops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct plat_smp_ops {
3333
#ifdef CONFIG_HOTPLUG_CPU
3434
int (*cpu_disable)(void);
3535
void (*cpu_die)(unsigned int cpu);
36+
void (*cleanup_dead_cpu)(unsigned cpu);
3637
#endif
3738
#ifdef CONFIG_KEXEC
3839
void (*kexec_nonboot_cpu)(void);

arch/mips/kernel/smp-bmips.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ static void bmips_cpu_die(unsigned int cpu)
392392
void __ref play_dead(void)
393393
{
394394
idle_task_exit();
395+
cpuhp_ap_report_dead();
395396

396397
/* flush data cache */
397398
_dma_cache_wback_inv(0, ~0);

arch/mips/kernel/smp-cps.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ void play_dead(void)
503503
}
504504
}
505505

506-
/* This CPU has chosen its way out */
507-
(void)cpu_report_death();
506+
cpuhp_ap_report_dead();
508507

509508
cps_shutdown_this_cpu(cpu_death);
510509

@@ -527,20 +526,16 @@ static void wait_for_sibling_halt(void *ptr_cpu)
527526
} while (!(halted & TCHALT_H));
528527
}
529528

530-
static void cps_cpu_die(unsigned int cpu)
529+
static void cps_cpu_die(unsigned int cpu) { }
530+
531+
static void cps_cleanup_dead_cpu(unsigned cpu)
531532
{
532533
unsigned core = cpu_core(&cpu_data[cpu]);
533534
unsigned int vpe_id = cpu_vpe_id(&cpu_data[cpu]);
534535
ktime_t fail_time;
535536
unsigned stat;
536537
int err;
537538

538-
/* Wait for the cpu to choose its way out */
539-
if (!cpu_wait_death(cpu, 5)) {
540-
pr_err("CPU%u: didn't offline\n", cpu);
541-
return;
542-
}
543-
544539
/*
545540
* Now wait for the CPU to actually offline. Without doing this that
546541
* offlining may race with one or more of:
@@ -624,6 +619,7 @@ static const struct plat_smp_ops cps_smp_ops = {
624619
#ifdef CONFIG_HOTPLUG_CPU
625620
.cpu_disable = cps_cpu_disable,
626621
.cpu_die = cps_cpu_die,
622+
.cleanup_dead_cpu = cps_cleanup_dead_cpu,
627623
#endif
628624
#ifdef CONFIG_KEXEC
629625
.kexec_nonboot_cpu = cps_kexec_nonboot_cpu,

arch/mips/kernel/smp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,14 @@ void flush_tlb_one(unsigned long vaddr)
690690
EXPORT_SYMBOL(flush_tlb_page);
691691
EXPORT_SYMBOL(flush_tlb_one);
692692

693+
#ifdef CONFIG_HOTPLUG_CORE_SYNC_DEAD
694+
void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
695+
{
696+
if (mp_ops->cleanup_dead_cpu)
697+
mp_ops->cleanup_dead_cpu(cpu);
698+
}
699+
#endif
700+
693701
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
694702

695703
static void tick_broadcast_callee(void *info)

arch/mips/loongson64/smp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ void play_dead(void)
775775
void (*play_dead_at_ckseg1)(int *);
776776

777777
idle_task_exit();
778+
cpuhp_ap_report_dead();
778779

779780
prid_imp = read_c0_prid() & PRID_IMP_MASK;
780781
prid_rev = read_c0_prid() & PRID_REV_MASK;

0 commit comments

Comments
 (0)