2008-11-19 23:35:56 +08:00
|
|
|
/*
|
|
|
|
* Author: Andy Fleming <afleming@freescale.com>
|
|
|
|
* Kumar Gala <galak@kernel.crashing.org>
|
|
|
|
*
|
2015-11-20 17:14:00 +08:00
|
|
|
* Copyright 2006-2008, 2011-2012, 2015 Freescale Semiconductor Inc.
|
2008-11-19 23:35:56 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/of.h>
|
2010-07-22 05:14:53 +08:00
|
|
|
#include <linux/kexec.h>
|
2010-09-17 06:58:26 +08:00
|
|
|
#include <linux/highmem.h>
|
2012-07-20 20:42:33 +08:00
|
|
|
#include <linux/cpu.h>
|
2015-09-20 12:29:53 +08:00
|
|
|
#include <linux/fsl/guts.h>
|
2008-11-19 23:35:56 +08:00
|
|
|
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/mpic.h>
|
|
|
|
#include <asm/cacheflush.h>
|
2009-02-12 12:50:42 +08:00
|
|
|
#include <asm/dbell.h>
|
2014-03-11 08:54:06 +08:00
|
|
|
#include <asm/code-patching.h>
|
2011-12-08 15:20:27 +08:00
|
|
|
#include <asm/cputhreads.h>
|
2015-11-20 17:14:00 +08:00
|
|
|
#include <asm/fsl_pm.h>
|
2008-11-19 23:35:56 +08:00
|
|
|
|
|
|
|
#include <sysdev/fsl_soc.h>
|
2010-07-22 05:14:53 +08:00
|
|
|
#include <sysdev/mpic.h>
|
2011-12-02 14:27:58 +08:00
|
|
|
#include "smp.h"
|
2008-11-19 23:35:56 +08:00
|
|
|
|
2012-07-20 20:42:33 +08:00
|
|
|
struct epapr_spin_table {
|
|
|
|
u32 addr_h;
|
|
|
|
u32 addr_l;
|
|
|
|
u32 r3_h;
|
|
|
|
u32 r3_l;
|
|
|
|
u32 reserved;
|
|
|
|
u32 pir;
|
|
|
|
};
|
2008-11-19 23:35:56 +08:00
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2012-07-20 20:42:35 +08:00
|
|
|
static u64 timebase;
|
|
|
|
static int tb_req;
|
|
|
|
static int tb_valid;
|
|
|
|
|
|
|
|
static void mpc85xx_give_timebase(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
2015-11-20 17:14:01 +08:00
|
|
|
hard_irq_disable();
|
2012-07-20 20:42:35 +08:00
|
|
|
|
|
|
|
while (!tb_req)
|
|
|
|
barrier();
|
|
|
|
tb_req = 0;
|
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
qoriq_pm_ops->freeze_time_base(true);
|
2013-07-24 09:21:11 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
/*
|
|
|
|
* e5500/e6500 have a workaround for erratum A-006958 in place
|
|
|
|
* that will reread the timebase until TBL is non-zero.
|
|
|
|
* That would be a bad thing when the timebase is frozen.
|
|
|
|
*
|
|
|
|
* Thus, we read it manually, and instead of checking that
|
|
|
|
* TBL is non-zero, we ensure that TB does not change. We don't
|
|
|
|
* do that for the main mftb implementation, because it requires
|
|
|
|
* a scratch register
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
u64 prev;
|
|
|
|
|
2013-08-21 08:33:12 +08:00
|
|
|
asm volatile("mfspr %0, %1" : "=r" (timebase) :
|
|
|
|
"i" (SPRN_TBRL));
|
2013-07-24 09:21:11 +08:00
|
|
|
|
|
|
|
do {
|
|
|
|
prev = timebase;
|
2013-08-21 08:33:12 +08:00
|
|
|
asm volatile("mfspr %0, %1" : "=r" (timebase) :
|
|
|
|
"i" (SPRN_TBRL));
|
2013-07-24 09:21:11 +08:00
|
|
|
} while (prev != timebase);
|
|
|
|
}
|
|
|
|
#else
|
2012-07-20 20:42:35 +08:00
|
|
|
timebase = get_tb();
|
2013-07-24 09:21:11 +08:00
|
|
|
#endif
|
2012-07-20 20:42:35 +08:00
|
|
|
mb();
|
|
|
|
tb_valid = 1;
|
|
|
|
|
|
|
|
while (tb_valid)
|
|
|
|
barrier();
|
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
qoriq_pm_ops->freeze_time_base(false);
|
2012-07-20 20:42:35 +08:00
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mpc85xx_take_timebase(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
2015-11-20 17:14:01 +08:00
|
|
|
hard_irq_disable();
|
2012-07-20 20:42:35 +08:00
|
|
|
|
|
|
|
tb_req = 1;
|
|
|
|
while (!tb_valid)
|
|
|
|
barrier();
|
|
|
|
|
|
|
|
set_tb(timebase >> 32, timebase & 0xffffffff);
|
|
|
|
isync();
|
|
|
|
tb_valid = 0;
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
2013-06-25 03:30:09 +08:00
|
|
|
static void smp_85xx_mach_cpu_die(void)
|
2012-07-20 20:42:36 +08:00
|
|
|
{
|
|
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
|
|
|
|
local_irq_disable();
|
2015-11-20 17:14:00 +08:00
|
|
|
hard_irq_disable();
|
|
|
|
/* mask all irqs to prevent cpu wakeup */
|
|
|
|
qoriq_pm_ops->irq_mask(cpu);
|
|
|
|
|
2012-07-20 20:42:36 +08:00
|
|
|
idle_task_exit();
|
|
|
|
|
|
|
|
mtspr(SPRN_TCR, 0);
|
2015-11-20 17:14:00 +08:00
|
|
|
mtspr(SPRN_TSR, mfspr(SPRN_TSR));
|
2012-07-20 20:42:36 +08:00
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
generic_set_cpu_dead(cpu);
|
2015-11-20 17:13:58 +08:00
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
cur_cpu_spec->cpu_down_flush();
|
2012-07-20 20:42:36 +08:00
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
qoriq_pm_ops->cpu_die(cpu);
|
2012-07-20 20:42:36 +08:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
;
|
|
|
|
}
|
2015-11-20 17:14:01 +08:00
|
|
|
|
|
|
|
static void qoriq_cpu_kill(unsigned int cpu)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 500; i++) {
|
|
|
|
if (is_cpu_dead(cpu)) {
|
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
paca[cpu].cpu_start = 0;
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
msleep(20);
|
|
|
|
}
|
|
|
|
pr_err("CPU%d didn't die...\n", cpu);
|
|
|
|
}
|
2012-07-20 20:42:36 +08:00
|
|
|
#endif
|
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
/*
|
|
|
|
* To keep it compatible with old boot program which uses
|
|
|
|
* cache-inhibit spin table, we need to flush the cache
|
|
|
|
* before accessing spin table to invalidate any staled data.
|
|
|
|
* We also need to flush the cache after writing to spin
|
|
|
|
* table to push data out.
|
|
|
|
*/
|
2012-09-30 07:44:35 +08:00
|
|
|
static inline void flush_spin_table(void *spin_table)
|
|
|
|
{
|
|
|
|
flush_dcache_range((ulong)spin_table,
|
|
|
|
(ulong)spin_table + sizeof(struct epapr_spin_table));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 read_spin_table_addr_l(void *spin_table)
|
|
|
|
{
|
|
|
|
flush_dcache_range((ulong)spin_table,
|
|
|
|
(ulong)spin_table + sizeof(struct epapr_spin_table));
|
|
|
|
return in_be32(&((struct epapr_spin_table *)spin_table)->addr_l);
|
|
|
|
}
|
|
|
|
|
2011-12-08 15:20:27 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
static void wake_hw_thread(void *info)
|
|
|
|
{
|
|
|
|
void fsl_secondary_thread_init(void);
|
2015-11-20 17:14:02 +08:00
|
|
|
unsigned long inia;
|
|
|
|
int cpu = *(const int *)info;
|
2011-12-08 15:20:27 +08:00
|
|
|
|
2015-10-07 11:48:05 +08:00
|
|
|
inia = *(unsigned long *)fsl_secondary_thread_init;
|
2015-11-20 17:14:02 +08:00
|
|
|
book3e_start_thread(cpu_thread_in_core(cpu), inia);
|
2011-12-08 15:20:27 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
static int smp_85xx_start_cpu(int cpu)
|
2008-11-19 23:35:56 +08:00
|
|
|
{
|
2015-11-20 17:14:01 +08:00
|
|
|
int ret = 0;
|
2008-11-19 23:35:56 +08:00
|
|
|
struct device_node *np;
|
2015-11-20 17:14:01 +08:00
|
|
|
const u64 *cpu_rel_addr;
|
|
|
|
unsigned long flags;
|
2009-12-19 06:50:37 +08:00
|
|
|
int ioremappable;
|
2015-11-20 17:14:01 +08:00
|
|
|
int hw_cpu = get_hard_smp_processor_id(cpu);
|
|
|
|
struct epapr_spin_table __iomem *spin_table;
|
2008-11-19 23:35:56 +08:00
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
np = of_get_cpu_node(cpu, NULL);
|
2008-11-19 23:35:56 +08:00
|
|
|
cpu_rel_addr = of_get_property(np, "cpu-release-addr", NULL);
|
2015-11-20 17:14:01 +08:00
|
|
|
if (!cpu_rel_addr) {
|
|
|
|
pr_err("No cpu-release-addr for cpu %d\n", cpu);
|
2011-04-12 05:46:19 +08:00
|
|
|
return -ENOENT;
|
2008-11-19 23:35:56 +08:00
|
|
|
}
|
|
|
|
|
2009-12-19 06:50:37 +08:00
|
|
|
/*
|
|
|
|
* A secondary core could be in a spinloop in the bootpage
|
|
|
|
* (0xfffff000), somewhere in highmem, or somewhere in lowmem.
|
|
|
|
* The bootpage and highmem can be accessed via ioremap(), but
|
|
|
|
* we need to directly access the spinloop if its in lowmem.
|
|
|
|
*/
|
|
|
|
ioremappable = *cpu_rel_addr > virt_to_phys(high_memory);
|
|
|
|
|
2008-11-19 23:35:56 +08:00
|
|
|
/* Map the spin table */
|
2009-12-19 06:50:37 +08:00
|
|
|
if (ioremappable)
|
2012-09-30 07:44:35 +08:00
|
|
|
spin_table = ioremap_prot(*cpu_rel_addr,
|
|
|
|
sizeof(struct epapr_spin_table), _PAGE_COHERENT);
|
2009-12-19 06:50:37 +08:00
|
|
|
else
|
2012-07-20 20:42:33 +08:00
|
|
|
spin_table = phys_to_virt(*cpu_rel_addr);
|
2008-11-19 23:35:56 +08:00
|
|
|
|
2009-06-19 16:30:42 +08:00
|
|
|
local_irq_save(flags);
|
2015-11-20 17:14:01 +08:00
|
|
|
hard_irq_disable();
|
2012-07-20 20:42:36 +08:00
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
if (qoriq_pm_ops)
|
|
|
|
qoriq_pm_ops->cpu_up_prepare(cpu);
|
2009-06-19 16:30:42 +08:00
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
/* if cpu is not spinning, reset it */
|
|
|
|
if (read_spin_table_addr_l(spin_table) != 1) {
|
2012-07-20 20:42:36 +08:00
|
|
|
/*
|
|
|
|
* We don't set the BPTR register here since it already points
|
|
|
|
* to the boot page properly.
|
|
|
|
*/
|
2015-11-20 17:14:01 +08:00
|
|
|
mpic_reset_core(cpu);
|
2012-07-20 20:42:36 +08:00
|
|
|
|
2012-09-30 07:44:35 +08:00
|
|
|
/*
|
|
|
|
* wait until core is ready...
|
|
|
|
* We need to invalidate the stale data, in case the boot
|
|
|
|
* loader uses a cache-inhibited spin table.
|
|
|
|
*/
|
|
|
|
if (!spin_event_timeout(
|
|
|
|
read_spin_table_addr_l(spin_table) == 1,
|
|
|
|
10000, 100)) {
|
2015-11-20 17:14:01 +08:00
|
|
|
pr_err("timeout waiting for cpu %d to reset\n",
|
|
|
|
hw_cpu);
|
|
|
|
ret = -EAGAIN;
|
|
|
|
goto err;
|
2012-07-20 20:42:36 +08:00
|
|
|
}
|
|
|
|
}
|
2011-02-15 12:45:48 +08:00
|
|
|
|
2012-09-30 07:44:35 +08:00
|
|
|
flush_spin_table(spin_table);
|
2012-07-20 20:42:36 +08:00
|
|
|
out_be32(&spin_table->pir, hw_cpu);
|
2015-11-20 17:14:01 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2012-07-20 20:42:33 +08:00
|
|
|
out_be64((u64 *)(&spin_table->addr_h),
|
2014-03-11 08:54:06 +08:00
|
|
|
__pa(ppc_function_entry(generic_secondary_smp_init)));
|
2015-11-20 17:14:01 +08:00
|
|
|
#else
|
|
|
|
out_be32(&spin_table->addr_l, __pa(__early_start));
|
2010-10-08 23:37:31 +08:00
|
|
|
#endif
|
2015-11-20 17:14:01 +08:00
|
|
|
flush_spin_table(spin_table);
|
|
|
|
err:
|
2008-11-19 23:35:56 +08:00
|
|
|
local_irq_restore(flags);
|
|
|
|
|
2009-12-19 06:50:37 +08:00
|
|
|
if (ioremappable)
|
2012-07-20 20:42:33 +08:00
|
|
|
iounmap(spin_table);
|
2009-06-19 16:30:42 +08:00
|
|
|
|
2012-07-20 20:42:36 +08:00
|
|
|
return ret;
|
2008-11-19 23:35:56 +08:00
|
|
|
}
|
|
|
|
|
2015-11-20 17:14:01 +08:00
|
|
|
static int smp_85xx_kick_cpu(int nr)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
int primary = nr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
WARN_ON(nr < 0 || nr >= num_possible_cpus());
|
|
|
|
|
|
|
|
pr_debug("kick CPU #%d\n", nr);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
2015-11-20 17:14:02 +08:00
|
|
|
if (threads_per_core == 2) {
|
2015-11-20 17:14:01 +08:00
|
|
|
if (WARN_ON_ONCE(!cpu_has_feature(CPU_FTR_SMT)))
|
|
|
|
return -ENOENT;
|
|
|
|
|
2015-11-20 17:14:02 +08:00
|
|
|
booting_thread_hwid = cpu_thread_in_core(nr);
|
|
|
|
primary = cpu_first_thread_sibling(nr);
|
2015-11-20 17:14:01 +08:00
|
|
|
|
2015-11-20 17:14:02 +08:00
|
|
|
if (qoriq_pm_ops)
|
|
|
|
qoriq_pm_ops->cpu_up_prepare(nr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If either thread in the core is online, use it to start
|
|
|
|
* the other.
|
|
|
|
*/
|
|
|
|
if (cpu_online(primary)) {
|
|
|
|
smp_call_function_single(primary,
|
|
|
|
wake_hw_thread, &nr, 1);
|
|
|
|
goto done;
|
|
|
|
} else if (cpu_online(primary + 1)) {
|
|
|
|
smp_call_function_single(primary + 1,
|
|
|
|
wake_hw_thread, &nr, 1);
|
|
|
|
goto done;
|
2015-11-20 17:14:01 +08:00
|
|
|
}
|
|
|
|
|
2015-11-20 17:14:02 +08:00
|
|
|
/*
|
|
|
|
* If getting here, it means both threads in the core are
|
|
|
|
* offline. So start the primary thread, then it will start
|
|
|
|
* the thread specified in booting_thread_hwid, the one
|
|
|
|
* corresponding to nr.
|
|
|
|
*/
|
|
|
|
|
|
|
|
} else if (threads_per_core == 1) {
|
|
|
|
/*
|
|
|
|
* If one core has only one thread, set booting_thread_hwid to
|
|
|
|
* an invalid value.
|
|
|
|
*/
|
|
|
|
booting_thread_hwid = INVALID_THREAD_HWID;
|
|
|
|
|
|
|
|
} else if (threads_per_core > 2) {
|
|
|
|
pr_err("Do not support more than 2 threads per CPU.");
|
|
|
|
return -EINVAL;
|
2015-11-20 17:14:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = smp_85xx_start_cpu(primary);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-11-20 17:14:02 +08:00
|
|
|
done:
|
2015-11-20 17:14:01 +08:00
|
|
|
paca[nr].cpu_start = 1;
|
|
|
|
generic_set_cpu_up(nr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
ret = smp_85xx_start_cpu(nr);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
generic_set_cpu_up(nr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-11-19 23:35:56 +08:00
|
|
|
struct smp_ops_t smp_85xx_ops = {
|
|
|
|
.kick_cpu = smp_85xx_kick_cpu,
|
2013-08-06 03:58:35 +08:00
|
|
|
.cpu_bootable = smp_generic_cpu_bootable,
|
2012-07-20 20:42:36 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
.cpu_disable = generic_cpu_disable,
|
|
|
|
.cpu_die = generic_cpu_die,
|
|
|
|
#endif
|
2015-10-07 11:48:07 +08:00
|
|
|
#if defined(CONFIG_KEXEC) && !defined(CONFIG_PPC64)
|
2010-07-22 05:14:53 +08:00
|
|
|
.give_timebase = smp_generic_give_timebase,
|
|
|
|
.take_timebase = smp_generic_take_timebase,
|
|
|
|
#endif
|
2008-11-19 23:35:56 +08:00
|
|
|
};
|
|
|
|
|
2010-07-22 05:14:53 +08:00
|
|
|
#ifdef CONFIG_KEXEC
|
2015-10-07 11:48:11 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2010-09-17 06:58:25 +08:00
|
|
|
atomic_t kexec_down_cpus = ATOMIC_INIT(0);
|
2010-07-22 05:14:53 +08:00
|
|
|
|
|
|
|
void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary)
|
|
|
|
{
|
2010-09-17 06:58:25 +08:00
|
|
|
local_irq_disable();
|
2010-07-22 05:14:53 +08:00
|
|
|
|
2010-09-17 06:58:25 +08:00
|
|
|
if (secondary) {
|
2015-11-20 17:13:58 +08:00
|
|
|
cur_cpu_spec->cpu_down_flush();
|
2010-09-17 06:58:25 +08:00
|
|
|
atomic_inc(&kexec_down_cpus);
|
|
|
|
/* loop forever */
|
2010-07-22 05:14:53 +08:00
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mpc85xx_smp_kexec_down(void *arg)
|
|
|
|
{
|
|
|
|
if (ppc_md.kexec_cpu_down)
|
|
|
|
ppc_md.kexec_cpu_down(0,1);
|
|
|
|
}
|
2015-10-07 11:48:11 +08:00
|
|
|
#else
|
|
|
|
void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary)
|
|
|
|
{
|
2015-10-07 11:48:12 +08:00
|
|
|
int cpu = smp_processor_id();
|
|
|
|
int sibling = cpu_last_thread_sibling(cpu);
|
|
|
|
bool notified = false;
|
|
|
|
int disable_cpu;
|
|
|
|
int disable_threadbit = 0;
|
|
|
|
long start = mftb();
|
|
|
|
long now;
|
|
|
|
|
2015-10-07 11:48:11 +08:00
|
|
|
local_irq_disable();
|
|
|
|
hard_irq_disable();
|
|
|
|
mpic_teardown_this_cpu(secondary);
|
2015-10-07 11:48:12 +08:00
|
|
|
|
|
|
|
if (cpu == crashing_cpu && cpu_thread_in_core(cpu) != 0) {
|
|
|
|
/*
|
|
|
|
* We enter the crash kernel on whatever cpu crashed,
|
|
|
|
* even if it's a secondary thread. If that's the case,
|
|
|
|
* disable the corresponding primary thread.
|
|
|
|
*/
|
|
|
|
disable_threadbit = 1;
|
|
|
|
disable_cpu = cpu_first_thread_sibling(cpu);
|
|
|
|
} else if (sibling != crashing_cpu &&
|
|
|
|
cpu_thread_in_core(cpu) == 0 &&
|
|
|
|
cpu_thread_in_core(sibling) != 0) {
|
|
|
|
disable_threadbit = 2;
|
|
|
|
disable_cpu = sibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disable_threadbit) {
|
|
|
|
while (paca[disable_cpu].kexec_state < KEXEC_STATE_REAL_MODE) {
|
|
|
|
barrier();
|
|
|
|
now = mftb();
|
|
|
|
if (!notified && now - start > 1000000) {
|
|
|
|
pr_info("%s/%d: waiting for cpu %d to enter KEXEC_STATE_REAL_MODE (%d)\n",
|
|
|
|
__func__, smp_processor_id(),
|
|
|
|
disable_cpu,
|
|
|
|
paca[disable_cpu].kexec_state);
|
|
|
|
notified = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notified) {
|
|
|
|
pr_info("%s: cpu %d done waiting\n",
|
|
|
|
__func__, disable_cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
mtspr(SPRN_TENC, disable_threadbit);
|
|
|
|
while (mfspr(SPRN_TENSR) & disable_threadbit)
|
|
|
|
cpu_relax();
|
|
|
|
}
|
2015-10-07 11:48:11 +08:00
|
|
|
}
|
|
|
|
#endif
|
2010-07-22 05:14:53 +08:00
|
|
|
|
|
|
|
static void mpc85xx_smp_machine_kexec(struct kimage *image)
|
|
|
|
{
|
2015-10-07 11:48:11 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2010-09-17 06:58:25 +08:00
|
|
|
int timeout = INT_MAX;
|
|
|
|
int i, num_cpus = num_present_cpus();
|
2010-07-22 05:14:53 +08:00
|
|
|
|
2010-09-17 06:58:25 +08:00
|
|
|
if (image->type == KEXEC_TYPE_DEFAULT)
|
|
|
|
smp_call_function(mpc85xx_smp_kexec_down, NULL, 0);
|
2010-07-22 05:14:53 +08:00
|
|
|
|
2010-09-17 06:58:25 +08:00
|
|
|
while ( (atomic_read(&kexec_down_cpus) != (num_cpus - 1)) &&
|
2010-07-22 05:14:53 +08:00
|
|
|
( timeout > 0 ) )
|
|
|
|
{
|
|
|
|
timeout--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !timeout )
|
|
|
|
printk(KERN_ERR "Unable to bring down secondary cpu(s)");
|
|
|
|
|
2011-10-26 06:54:04 +08:00
|
|
|
for_each_online_cpu(i)
|
2010-07-22 05:14:53 +08:00
|
|
|
{
|
|
|
|
if ( i == smp_processor_id() ) continue;
|
|
|
|
mpic_reset_core(i);
|
|
|
|
}
|
2015-10-07 11:48:11 +08:00
|
|
|
#endif
|
2010-07-22 05:14:53 +08:00
|
|
|
|
|
|
|
default_machine_kexec(image);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_KEXEC */
|
|
|
|
|
2013-11-07 15:17:17 +08:00
|
|
|
static void smp_85xx_basic_setup(int cpu_nr)
|
2010-08-26 15:49:07 +08:00
|
|
|
{
|
|
|
|
if (cpu_has_feature(CPU_FTR_DBELL))
|
|
|
|
doorbell_setup_this_cpu();
|
|
|
|
}
|
|
|
|
|
2013-11-07 15:17:17 +08:00
|
|
|
static void smp_85xx_setup_cpu(int cpu_nr)
|
|
|
|
{
|
|
|
|
mpic_setup_this_cpu();
|
|
|
|
smp_85xx_basic_setup(cpu_nr);
|
|
|
|
}
|
|
|
|
|
2009-02-12 12:50:42 +08:00
|
|
|
void __init mpc85xx_smp_init(void)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
|
2010-08-26 15:49:07 +08:00
|
|
|
|
2009-02-12 12:50:42 +08:00
|
|
|
np = of_find_node_by_type(NULL, "open-pic");
|
|
|
|
if (np) {
|
|
|
|
smp_85xx_ops.probe = smp_mpic_probe;
|
2013-11-07 15:17:17 +08:00
|
|
|
smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu;
|
2009-02-12 12:50:42 +08:00
|
|
|
smp_85xx_ops.message_pass = smp_mpic_message_pass;
|
2013-11-07 15:17:17 +08:00
|
|
|
} else
|
|
|
|
smp_85xx_ops.setup_cpu = smp_85xx_basic_setup;
|
2009-02-12 12:50:42 +08:00
|
|
|
|
powerpc: Consolidate ipi message mux and demux
Consolidate the mux and demux of ipi messages into smp.c and call
a new smp_ops callback to actually trigger the ipi.
The powerpc architecture code is optimised for having 4 distinct
ipi triggers, which are mapped to 4 distinct messages (ipi many, ipi
single, scheduler ipi, and enter debugger). However, several interrupt
controllers only provide a single software triggered interrupt that
can be delivered to each cpu. To resolve this limitation, each smp_ops
implementation created a per-cpu variable that is manipulated with atomic
bitops. Since these lines will be contended they are optimialy marked as
shared_aligned and take a full cache line for each cpu. Distro kernels
may have 2 or 3 of these in their config, each taking per-cpu space
even though at most one will be in use.
This consolidation removes smp_message_recv and replaces the single call
actions cases with direct calls from the common message recognition loop.
The complicated debugger ipi case with its muxed crash handling code is
moved to debug_ipi_action which is now called from the demux code (instead
of the multi-message action calling smp_message_recv).
I put a call to reschedule_action to increase the likelyhood of correctly
merging the anticipated scheduler_ipi() hook coming from the scheduler
tree; that single required call can be inlined later.
The actual message decode is a copy of the old pseries xics code with its
memory barriers and cache line spacing, augmented with a per-cpu unsigned
long based on the book-e doorbell code. The optional data is set via a
callback from the implementation and is passed to the new cause-ipi hook
along with the logical cpu number. While currently only the doorbell
implemntation uses this data it should be almost zero cost to retrieve and
pass it -- it adds a single register load for the argument from the same
cache line to which we just completed a store and the register is dead
on return from the call. I extended the data element from unsigned int
to unsigned long in case some other code wanted to associate a pointer.
The doorbell check_self is replaced by a call to smp_muxed_ipi_resend,
conditioned on the CPU_DBELL feature. The ifdef guard could be relaxed
to CONFIG_SMP but I left it with BOOKE for now.
Also, the doorbell interrupt vector for book-e was not calling irq_enter
and irq_exit, which throws off cpu accounting and causes code to not
realize it is running in interrupt context. Add the missing calls.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-05-11 03:29:39 +08:00
|
|
|
if (cpu_has_feature(CPU_FTR_DBELL)) {
|
2011-07-07 21:44:30 +08:00
|
|
|
/*
|
|
|
|
* If left NULL, .message_pass defaults to
|
|
|
|
* smp_muxed_ipi_message_pass
|
|
|
|
*/
|
2011-10-12 08:06:42 +08:00
|
|
|
smp_85xx_ops.message_pass = NULL;
|
powerpc: Consolidate ipi message mux and demux
Consolidate the mux and demux of ipi messages into smp.c and call
a new smp_ops callback to actually trigger the ipi.
The powerpc architecture code is optimised for having 4 distinct
ipi triggers, which are mapped to 4 distinct messages (ipi many, ipi
single, scheduler ipi, and enter debugger). However, several interrupt
controllers only provide a single software triggered interrupt that
can be delivered to each cpu. To resolve this limitation, each smp_ops
implementation created a per-cpu variable that is manipulated with atomic
bitops. Since these lines will be contended they are optimialy marked as
shared_aligned and take a full cache line for each cpu. Distro kernels
may have 2 or 3 of these in their config, each taking per-cpu space
even though at most one will be in use.
This consolidation removes smp_message_recv and replaces the single call
actions cases with direct calls from the common message recognition loop.
The complicated debugger ipi case with its muxed crash handling code is
moved to debug_ipi_action which is now called from the demux code (instead
of the multi-message action calling smp_message_recv).
I put a call to reschedule_action to increase the likelyhood of correctly
merging the anticipated scheduler_ipi() hook coming from the scheduler
tree; that single required call can be inlined later.
The actual message decode is a copy of the old pseries xics code with its
memory barriers and cache line spacing, augmented with a per-cpu unsigned
long based on the book-e doorbell code. The optional data is set via a
callback from the implementation and is passed to the new cause-ipi hook
along with the logical cpu number. While currently only the doorbell
implemntation uses this data it should be almost zero cost to retrieve and
pass it -- it adds a single register load for the argument from the same
cache line to which we just completed a store and the register is dead
on return from the call. I extended the data element from unsigned int
to unsigned long in case some other code wanted to associate a pointer.
The doorbell check_self is replaced by a call to smp_muxed_ipi_resend,
conditioned on the CPU_DBELL feature. The ifdef guard could be relaxed
to CONFIG_SMP but I left it with BOOKE for now.
Also, the doorbell interrupt vector for book-e was not calling irq_enter
and irq_exit, which throws off cpu accounting and causes code to not
realize it is running in interrupt context. Add the missing calls.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-05-11 03:29:39 +08:00
|
|
|
smp_85xx_ops.cause_ipi = doorbell_cause_ipi;
|
2013-11-07 15:17:17 +08:00
|
|
|
smp_85xx_ops.probe = NULL;
|
powerpc: Consolidate ipi message mux and demux
Consolidate the mux and demux of ipi messages into smp.c and call
a new smp_ops callback to actually trigger the ipi.
The powerpc architecture code is optimised for having 4 distinct
ipi triggers, which are mapped to 4 distinct messages (ipi many, ipi
single, scheduler ipi, and enter debugger). However, several interrupt
controllers only provide a single software triggered interrupt that
can be delivered to each cpu. To resolve this limitation, each smp_ops
implementation created a per-cpu variable that is manipulated with atomic
bitops. Since these lines will be contended they are optimialy marked as
shared_aligned and take a full cache line for each cpu. Distro kernels
may have 2 or 3 of these in their config, each taking per-cpu space
even though at most one will be in use.
This consolidation removes smp_message_recv and replaces the single call
actions cases with direct calls from the common message recognition loop.
The complicated debugger ipi case with its muxed crash handling code is
moved to debug_ipi_action which is now called from the demux code (instead
of the multi-message action calling smp_message_recv).
I put a call to reschedule_action to increase the likelyhood of correctly
merging the anticipated scheduler_ipi() hook coming from the scheduler
tree; that single required call can be inlined later.
The actual message decode is a copy of the old pseries xics code with its
memory barriers and cache line spacing, augmented with a per-cpu unsigned
long based on the book-e doorbell code. The optional data is set via a
callback from the implementation and is passed to the new cause-ipi hook
along with the logical cpu number. While currently only the doorbell
implemntation uses this data it should be almost zero cost to retrieve and
pass it -- it adds a single register load for the argument from the same
cache line to which we just completed a store and the register is dead
on return from the call. I extended the data element from unsigned int
to unsigned long in case some other code wanted to associate a pointer.
The doorbell check_self is replaced by a call to smp_muxed_ipi_resend,
conditioned on the CPU_DBELL feature. The ifdef guard could be relaxed
to CONFIG_SMP but I left it with BOOKE for now.
Also, the doorbell interrupt vector for book-e was not calling irq_enter
and irq_exit, which throws off cpu accounting and causes code to not
realize it is running in interrupt context. Add the missing calls.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-05-11 03:29:39 +08:00
|
|
|
}
|
2009-02-12 12:50:42 +08:00
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2015-11-20 17:14:01 +08:00
|
|
|
#ifdef CONFIG_FSL_CORENET_RCPM
|
|
|
|
fsl_rcpm_init();
|
|
|
|
#endif
|
|
|
|
|
2015-11-20 17:14:00 +08:00
|
|
|
#ifdef CONFIG_FSL_PMC
|
|
|
|
mpc85xx_setup_pmc();
|
|
|
|
#endif
|
|
|
|
if (qoriq_pm_ops) {
|
2012-07-20 20:42:35 +08:00
|
|
|
smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
|
|
|
|
smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
|
2012-07-20 20:42:36 +08:00
|
|
|
ppc_md.cpu_die = smp_85xx_mach_cpu_die;
|
2015-11-20 17:14:01 +08:00
|
|
|
smp_85xx_ops.cpu_die = qoriq_cpu_kill;
|
2012-07-20 20:42:35 +08:00
|
|
|
}
|
2015-11-20 17:14:00 +08:00
|
|
|
#endif
|
2008-11-19 23:35:56 +08:00
|
|
|
smp_ops = &smp_85xx_ops;
|
2010-07-22 05:14:53 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_KEXEC
|
|
|
|
ppc_md.kexec_cpu_down = mpc85xx_smp_kexec_cpu_down;
|
|
|
|
ppc_md.machine_kexec = mpc85xx_smp_machine_kexec;
|
|
|
|
#endif
|
2008-11-19 23:35:56 +08:00
|
|
|
}
|