Skip to content

Commit

Permalink
powerpc/smp: Move ppc_md.cpu_die() to smp_ops.cpu_offline_self()
Browse files Browse the repository at this point in the history
We have smp_ops->cpu_die() and ppc_md.cpu_die(). One of them offlines
the current CPU and one offlines another CPU, can you guess which is
which? Also one is in smp_ops and one is in ppc_md?

So rename ppc_md.cpu_die(), to cpu_offline_self(), because that's what
it does. And move it into smp_ops where it belongs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200819015634.1974478-3-mpe@ellerman.id.au
  • Loading branch information
mpe committed Sep 18, 2020
1 parent bf3c146 commit 39f8756
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/machdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct machdep_calls {
void __noreturn (*restart)(char *cmd);
void __noreturn (*halt)(void);
void (*panic)(char *str);
void (*cpu_die)(void);

long (*time_init)(void); /* Optional, may be NULL */

Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct smp_ops_t {
int (*cpu_disable)(void);
void (*cpu_die)(unsigned int nr);
int (*cpu_bootable)(unsigned int nr);
#ifdef CONFIG_HOTPLUG_CPU
void (*cpu_offline_self)(void);
#endif
};

extern int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,8 @@ void arch_cpu_idle_dead(void)
*/
this_cpu_disable_ftrace();

if (ppc_md.cpu_die)
ppc_md.cpu_die();
if (smp_ops->cpu_offline_self)
smp_ops->cpu_offline_self();

/* If we return, we re-enter start_secondary */
start_secondary_resume();
Expand Down
4 changes: 3 additions & 1 deletion arch/powerpc/kernel/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,15 +1160,17 @@ static int __init topology_init(void)
for_each_possible_cpu(cpu) {
struct cpu *c = &per_cpu(cpu_devices, cpu);

#ifdef CONFIG_HOTPLUG_CPU
/*
* For now, we just see if the system supports making
* the RTAS calls for CPU hotplug. But, there may be a
* more comprehensive way to do this for an individual
* CPU. For instance, the boot cpu might never be valid
* for hotplugging.
*/
if (ppc_md.cpu_die)
if (smp_ops->cpu_offline_self)
c->hotpluggable = 1;
#endif

if (cpu_online(cpu) || c->hotpluggable) {
register_cpu(c, cpu);
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/85xx/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void mpc85xx_take_timebase(void)
local_irq_restore(flags);
}

static void smp_85xx_mach_cpu_die(void)
static void smp_85xx_cpu_offline_self(void)
{
unsigned int cpu = smp_processor_id();

Expand Down Expand Up @@ -506,7 +506,7 @@ void __init mpc85xx_smp_init(void)
if (qoriq_pm_ops) {
smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
ppc_md.cpu_die = smp_85xx_mach_cpu_die;
smp_85xx_ops.cpu_offline_self = smp_85xx_cpu_offline_self;
smp_85xx_ops.cpu_die = qoriq_cpu_kill;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powermac/pmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern void pmac_check_ht_link(void);

extern void pmac_setup_smp(void);
extern int psurge_secondary_virq;
extern void low_cpu_die(void) __attribute__((noreturn));
extern void low_cpu_offline_self(void) __attribute__((noreturn));

extern int pmac_nvram_init(void);
extern void pmac_pic_init(void);
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/powermac/sleep.S
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
addi r3,r3,sleep_storage@l
stw r5,0(r3)

.globl low_cpu_die
low_cpu_die:
.globl low_cpu_offline_self
low_cpu_offline_self:
/* Flush & disable all caches */
bl flush_disable_caches

Expand Down Expand Up @@ -244,7 +244,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450)
mtmsr r2
isync
b 1b
_ASM_NOKPROBE_SYMBOL(low_cpu_die)
_ASM_NOKPROBE_SYMBOL(low_cpu_offline_self)
/*
* Here is the resume code.
*/
Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/platforms/powermac/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ static int smp_core99_cpu_disable(void)

#ifdef CONFIG_PPC32

static void pmac_cpu_die(void)
static void pmac_cpu_offline_self(void)
{
int cpu = smp_processor_id();

Expand All @@ -930,12 +930,12 @@ static void pmac_cpu_die(void)
generic_set_cpu_dead(cpu);
smp_wmb();
mb();
low_cpu_die();
low_cpu_offline_self();
}

#else /* CONFIG_PPC32 */

static void pmac_cpu_die(void)
static void pmac_cpu_offline_self(void)
{
int cpu = smp_processor_id();

Expand Down Expand Up @@ -1020,7 +1020,7 @@ void __init pmac_setup_smp(void)
#endif /* CONFIG_PPC_PMAC32_PSURGE */

#ifdef CONFIG_HOTPLUG_CPU
ppc_md.cpu_die = pmac_cpu_die;
smp_ops->cpu_offline_self = pmac_cpu_offline_self;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/powernv/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void pnv_flush_interrupts(void)
}
}

static void pnv_smp_cpu_kill_self(void)
static void pnv_cpu_offline_self(void)
{
unsigned long srr1, unexpected_mask, wmask;
unsigned int cpu;
Expand Down Expand Up @@ -417,6 +417,7 @@ static struct smp_ops_t pnv_smp_ops = {
#ifdef CONFIG_HOTPLUG_CPU
.cpu_disable = pnv_smp_cpu_disable,
.cpu_die = generic_cpu_die,
.cpu_offline_self = pnv_cpu_offline_self,
#endif /* CONFIG_HOTPLUG_CPU */
};

Expand All @@ -430,7 +431,6 @@ void __init pnv_smp_init(void)
smp_ops = &pnv_smp_ops;

#ifdef CONFIG_HOTPLUG_CPU
ppc_md.cpu_die = pnv_smp_cpu_kill_self;
#ifdef CONFIG_KEXEC_CORE
crash_wake_offline = 1;
#endif
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/pseries/hotplug-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void rtas_stop_self(void)
panic("Alas, I survived.\n");
}

static void pseries_mach_cpu_die(void)
static void pseries_cpu_offline_self(void)
{
unsigned int hwcpu = hard_smp_processor_id();

Expand Down Expand Up @@ -102,7 +102,7 @@ static int pseries_cpu_disable(void)
* to self-destroy so that the cpu-offline thread can send the CPU_DEAD
* notifications.
*
* OTOH, pseries_mach_cpu_die() is called by the @cpu when it wants to
* OTOH, pseries_cpu_offline_self() is called by the @cpu when it wants to
* self-destruct.
*/
static void pseries_cpu_die(unsigned int cpu)
Expand Down Expand Up @@ -901,7 +901,7 @@ static int __init pseries_cpu_hotplug_init(void)
return 0;
}

ppc_md.cpu_die = pseries_mach_cpu_die;
smp_ops->cpu_offline_self = pseries_cpu_offline_self;
smp_ops->cpu_disable = pseries_cpu_disable;
smp_ops->cpu_die = pseries_cpu_die;

Expand Down

0 comments on commit 39f8756

Please sign in to comment.