2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SMP boot-related support
|
|
|
|
*
|
2005-04-25 18:44:02 +00:00
|
|
|
* Copyright (C) 1998-2003, 2005 Hewlett-Packard Co
|
2005-04-16 22:20:36 +00:00
|
|
|
* David Mosberger-Tang <davidm@hpl.hp.com>
|
2005-04-25 20:25:06 +00:00
|
|
|
* Copyright (C) 2001, 2004-2005 Intel Corp
|
|
|
|
* Rohit Seth <rohit.seth@intel.com>
|
|
|
|
* Suresh Siddha <suresh.b.siddha@intel.com>
|
|
|
|
* Gordon Jin <gordon.jin@intel.com>
|
|
|
|
* Ashok Raj <ashok.raj@intel.com>
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* 01/05/16 Rohit Seth <rohit.seth@intel.com> Moved SMP booting functions from smp.c to here.
|
|
|
|
* 01/04/27 David Mosberger <davidm@hpl.hp.com> Added ITC synching code.
|
|
|
|
* 02/07/31 David Mosberger <davidm@hpl.hp.com> Switch over to hotplug-CPU boot-sequence.
|
|
|
|
* smp_boot_cpus()/smp_commence() is replaced by
|
|
|
|
* smp_prepare_cpus()/__cpu_up()/smp_cpus_done().
|
2005-04-22 21:44:40 +00:00
|
|
|
* 04/06/21 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support
|
2005-04-25 20:25:06 +00:00
|
|
|
* 04/12/26 Jin Gordon <gordon.jin@intel.com>
|
|
|
|
* 04/12/26 Rohit Seth <rohit.seth@intel.com>
|
|
|
|
* Add multi-threading and multi-core detection
|
|
|
|
* 05/01/30 Suresh Siddha <suresh.b.siddha@intel.com>
|
|
|
|
* Setup cpu_sibling_map and cpu_core_map
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/efi.h>
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
2011-07-26 23:09:06 +00:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <asm/current.h>
|
|
|
|
#include <asm/delay.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/machvec.h>
|
|
|
|
#include <asm/mca.h>
|
|
|
|
#include <asm/page.h>
|
2008-05-19 13:13:41 +00:00
|
|
|
#include <asm/paravirt.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/sal.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/unistd.h>
|
2007-08-23 00:32:06 +00:00
|
|
|
#include <asm/sn/arch.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define SMP_DEBUG 0
|
|
|
|
|
|
|
|
#if SMP_DEBUG
|
|
|
|
#define Dprintk(x...) printk(x)
|
|
|
|
#else
|
|
|
|
#define Dprintk(x...)
|
|
|
|
#endif
|
|
|
|
|
2005-04-22 21:44:40 +00:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2005-11-11 22:32:40 +00:00
|
|
|
#ifdef CONFIG_PERMIT_BSP_REMOVE
|
|
|
|
#define bsp_remove_ok 1
|
|
|
|
#else
|
|
|
|
#define bsp_remove_ok 0
|
|
|
|
#endif
|
|
|
|
|
2005-04-22 21:44:40 +00:00
|
|
|
/*
|
|
|
|
* Global array allocated for NR_CPUS at boot time
|
|
|
|
*/
|
|
|
|
struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* start_ap in head.S uses this to store current booting cpu
|
|
|
|
* info.
|
|
|
|
*/
|
|
|
|
struct sal_to_os_boot *sal_state_for_booting_cpu = &sal_boot_rendez_state[0];
|
|
|
|
|
|
|
|
#define set_brendez_area(x) (sal_state_for_booting_cpu = &sal_boot_rendez_state[(x)]);
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define set_brendez_area(x)
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ITC synchronization related stuff:
|
|
|
|
*/
|
2005-11-11 22:32:40 +00:00
|
|
|
#define MASTER (0)
|
2005-04-16 22:20:36 +00:00
|
|
|
#define SLAVE (SMP_CACHE_BYTES/8)
|
|
|
|
|
|
|
|
#define NUM_ROUNDS 64 /* magic value */
|
|
|
|
#define NUM_ITERS 5 /* likewise */
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(itc_sync_lock);
|
|
|
|
static volatile unsigned long go[SLAVE + 1];
|
|
|
|
|
|
|
|
#define DEBUG_ITC_SYNC 0
|
|
|
|
|
|
|
|
extern void start_ap (void);
|
|
|
|
extern unsigned long ia64_iobase;
|
|
|
|
|
2006-07-03 07:25:41 +00:00
|
|
|
struct task_struct *task_for_booting_cpu;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* State for each CPU
|
|
|
|
*/
|
|
|
|
DEFINE_PER_CPU(int, cpu_state);
|
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
|
2008-07-29 01:36:50 +00:00
|
|
|
EXPORT_SYMBOL(cpu_core_map);
|
2007-10-16 08:24:05 +00:00
|
|
|
DEFINE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
|
|
|
|
EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
|
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
int smp_num_siblings = 1;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* which logical CPU number maps to which CPU (physical APIC ID) */
|
|
|
|
volatile int ia64_cpu_to_sapicid[NR_CPUS];
|
|
|
|
EXPORT_SYMBOL(ia64_cpu_to_sapicid);
|
|
|
|
|
|
|
|
static volatile cpumask_t cpu_callin_map;
|
|
|
|
|
|
|
|
struct smp_boot_data smp_boot_data __initdata;
|
|
|
|
|
|
|
|
unsigned long ap_wakeup_vector = -1; /* External Int use to wakeup APs */
|
|
|
|
|
|
|
|
char __initdata no_int_routing;
|
|
|
|
|
|
|
|
unsigned char smp_int_redirect; /* are INT and IPI redirectable by the chipset? */
|
|
|
|
|
2005-11-11 22:32:40 +00:00
|
|
|
#ifdef CONFIG_FORCE_CPEI_RETARGET
|
|
|
|
#define CPEI_OVERRIDE_DEFAULT (1)
|
|
|
|
#else
|
|
|
|
#define CPEI_OVERRIDE_DEFAULT (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
unsigned int force_cpei_retarget = CPEI_OVERRIDE_DEFAULT;
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
cmdl_force_cpei(char *str)
|
|
|
|
{
|
|
|
|
int value=0;
|
|
|
|
|
|
|
|
get_option (&str, &value);
|
|
|
|
force_cpei_retarget = value;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("force_cpei=", cmdl_force_cpei);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int __init
|
|
|
|
nointroute (char *str)
|
|
|
|
{
|
|
|
|
no_int_routing = 1;
|
|
|
|
printk ("no_int_routing on\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("nointroute", nointroute);
|
|
|
|
|
2005-11-11 22:32:40 +00:00
|
|
|
static void fix_b0_for_bsp(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
int cpuid;
|
|
|
|
static int fix_bsp_b0 = 1;
|
|
|
|
|
|
|
|
cpuid = smp_processor_id();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cache the b0 value on the first AP that comes up
|
|
|
|
*/
|
|
|
|
if (!(fix_bsp_b0 && cpuid))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sal_boot_rendez_state[0].br[0] = sal_boot_rendez_state[cpuid].br[0];
|
|
|
|
printk ("Fixed BSP b0 value from CPU %d\n", cpuid);
|
|
|
|
|
|
|
|
fix_bsp_b0 = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
void
|
|
|
|
sync_master (void *arg)
|
|
|
|
{
|
|
|
|
unsigned long flags, i;
|
|
|
|
|
|
|
|
go[MASTER] = 0;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
{
|
|
|
|
for (i = 0; i < NUM_ROUNDS*NUM_ITERS; ++i) {
|
2005-04-25 18:44:02 +00:00
|
|
|
while (!go[MASTER])
|
|
|
|
cpu_relax();
|
2005-04-16 22:20:36 +00:00
|
|
|
go[MASTER] = 0;
|
|
|
|
go[SLAVE] = ia64_get_itc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of cycles by which our itc differs from the itc on the master
|
|
|
|
* (time-keeper) CPU. A positive number indicates our itc is ahead of the master,
|
|
|
|
* negative that it is behind.
|
|
|
|
*/
|
|
|
|
static inline long
|
|
|
|
get_delta (long *rt, long *master)
|
|
|
|
{
|
|
|
|
unsigned long best_t0 = 0, best_t1 = ~0UL, best_tm = 0;
|
|
|
|
unsigned long tcenter, t0, t1, tm;
|
|
|
|
long i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_ITERS; ++i) {
|
|
|
|
t0 = ia64_get_itc();
|
|
|
|
go[MASTER] = 1;
|
2005-04-25 18:44:02 +00:00
|
|
|
while (!(tm = go[SLAVE]))
|
|
|
|
cpu_relax();
|
2005-04-16 22:20:36 +00:00
|
|
|
go[SLAVE] = 0;
|
|
|
|
t1 = ia64_get_itc();
|
|
|
|
|
|
|
|
if (t1 - t0 < best_t1 - best_t0)
|
|
|
|
best_t0 = t0, best_t1 = t1, best_tm = tm;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rt = best_t1 - best_t0;
|
|
|
|
*master = best_tm - best_t0;
|
|
|
|
|
|
|
|
/* average best_t0 and best_t1 without overflow: */
|
|
|
|
tcenter = (best_t0/2 + best_t1/2);
|
|
|
|
if (best_t0 % 2 + best_t1 % 2 == 2)
|
|
|
|
++tcenter;
|
|
|
|
return tcenter - best_tm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Synchronize ar.itc of the current (slave) CPU with the ar.itc of the MASTER CPU
|
|
|
|
* (normally the time-keeper CPU). We use a closed loop to eliminate the possibility of
|
|
|
|
* unaccounted-for errors (such as getting a machine check in the middle of a calibration
|
|
|
|
* step). The basic idea is for the slave to ask the master what itc value it has and to
|
|
|
|
* read its own itc before and after the master responds. Each iteration gives us three
|
|
|
|
* timestamps:
|
|
|
|
*
|
|
|
|
* slave master
|
|
|
|
*
|
|
|
|
* t0 ---\
|
|
|
|
* ---\
|
|
|
|
* --->
|
|
|
|
* tm
|
|
|
|
* /---
|
|
|
|
* /---
|
|
|
|
* t1 <---
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The goal is to adjust the slave's ar.itc such that tm falls exactly half-way between t0
|
|
|
|
* and t1. If we achieve this, the clocks are synchronized provided the interconnect
|
|
|
|
* between the slave and the master is symmetric. Even if the interconnect were
|
|
|
|
* asymmetric, we would still know that the synchronization error is smaller than the
|
|
|
|
* roundtrip latency (t0 - t1).
|
|
|
|
*
|
|
|
|
* When the interconnect is quiet and symmetric, this lets us synchronize the itc to
|
|
|
|
* within one or two cycles. However, we can only *guarantee* that the synchronization is
|
|
|
|
* accurate to within a round-trip time, which is typically in the range of several
|
|
|
|
* hundred cycles (e.g., ~500 cycles). In practice, this means that the itc's are usually
|
|
|
|
* almost perfectly synchronized, but we shouldn't assume that the accuracy is much better
|
|
|
|
* than half a micro second or so.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ia64_sync_itc (unsigned int master)
|
|
|
|
{
|
|
|
|
long i, delta, adj, adjust_latency = 0, done = 0;
|
|
|
|
unsigned long flags, rt, master_time_stamp, bound;
|
|
|
|
#if DEBUG_ITC_SYNC
|
|
|
|
struct {
|
|
|
|
long rt; /* roundtrip time */
|
|
|
|
long master; /* master's timestamp */
|
|
|
|
long diff; /* difference between midpoint and master's timestamp */
|
|
|
|
long lat; /* estimate of itc adjustment latency */
|
|
|
|
} t[NUM_ROUNDS];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure local timer ticks are disabled while we sync. If
|
|
|
|
* they were enabled, we'd have to worry about nasty issues
|
|
|
|
* like setting the ITC ahead of (or a long time before) the
|
|
|
|
* next scheduled tick.
|
|
|
|
*/
|
|
|
|
BUG_ON((ia64_get_itv() & (1 << 16)) == 0);
|
|
|
|
|
|
|
|
go[MASTER] = 1;
|
|
|
|
|
2008-06-06 09:18:06 +00:00
|
|
|
if (smp_call_function_single(master, sync_master, NULL, 0) < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-25 18:44:02 +00:00
|
|
|
while (go[MASTER])
|
|
|
|
cpu_relax(); /* wait for master to be ready */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&itc_sync_lock, flags);
|
|
|
|
{
|
|
|
|
for (i = 0; i < NUM_ROUNDS; ++i) {
|
|
|
|
delta = get_delta(&rt, &master_time_stamp);
|
|
|
|
if (delta == 0) {
|
|
|
|
done = 1; /* let's lock on to this... */
|
|
|
|
bound = rt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!done) {
|
|
|
|
if (i > 0) {
|
|
|
|
adjust_latency += -delta;
|
|
|
|
adj = -delta + adjust_latency/4;
|
|
|
|
} else
|
|
|
|
adj = -delta;
|
|
|
|
|
|
|
|
ia64_set_itc(ia64_get_itc() + adj);
|
|
|
|
}
|
|
|
|
#if DEBUG_ITC_SYNC
|
|
|
|
t[i].rt = rt;
|
|
|
|
t[i].master = master_time_stamp;
|
|
|
|
t[i].diff = delta;
|
|
|
|
t[i].lat = adjust_latency/4;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&itc_sync_lock, flags);
|
|
|
|
|
|
|
|
#if DEBUG_ITC_SYNC
|
|
|
|
for (i = 0; i < NUM_ROUNDS; ++i)
|
|
|
|
printk("rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n",
|
|
|
|
t[i].rt, t[i].master, t[i].diff, t[i].lat);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
printk(KERN_INFO "CPU %d: synchronized ITC with CPU %u (last diff %ld cycles, "
|
|
|
|
"maxerr %lu cycles)\n", smp_processor_id(), master, delta, rt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ideally sets up per-cpu profiling hooks. Doesn't do much now...
|
|
|
|
*/
|
2012-12-21 22:05:13 +00:00
|
|
|
static inline void smp_setup_percpu_timer(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:51:20 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
smp_callin (void)
|
|
|
|
{
|
2005-11-11 22:32:40 +00:00
|
|
|
int cpuid, phys_id, itc_master;
|
2007-03-27 19:30:19 +00:00
|
|
|
struct cpuinfo_ia64 *last_cpuinfo, *this_cpuinfo;
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void ia64_init_itm(void);
|
2005-11-11 22:32:40 +00:00
|
|
|
extern volatile int time_keeper_id;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PERFMON
|
|
|
|
extern void pfm_init_percpu(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cpuid = smp_processor_id();
|
|
|
|
phys_id = hard_smp_processor_id();
|
2005-11-11 22:32:40 +00:00
|
|
|
itc_master = time_keeper_id;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (cpu_online(cpuid)) {
|
|
|
|
printk(KERN_ERR "huh, phys CPU#0x%x, CPU#0x%x already present??\n",
|
|
|
|
phys_id, cpuid);
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2005-11-11 22:32:40 +00:00
|
|
|
fix_b0_for_bsp();
|
|
|
|
|
2010-05-26 21:44:59 +00:00
|
|
|
/*
|
|
|
|
* numa_node_id() works after this.
|
|
|
|
*/
|
|
|
|
set_numa_node(cpu_to_node_map[cpuid]);
|
2010-05-26 21:45:01 +00:00
|
|
|
set_numa_mem(local_memory_node(cpu_to_node_map[cpuid]));
|
2010-05-26 21:44:59 +00:00
|
|
|
|
2007-07-17 12:22:23 +00:00
|
|
|
spin_lock(&vector_lock);
|
|
|
|
/* Setup the per cpu irq handling data structures */
|
|
|
|
__setup_vector_irq(cpuid);
|
2008-09-07 14:57:22 +00:00
|
|
|
notify_cpu_starting(cpuid);
|
2012-03-28 21:42:46 +00:00
|
|
|
set_cpu_online(cpuid, true);
|
2005-06-25 21:55:05 +00:00
|
|
|
per_cpu(cpu_state, cpuid) = CPU_ONLINE;
|
2007-07-17 12:22:23 +00:00
|
|
|
spin_unlock(&vector_lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
smp_setup_percpu_timer();
|
|
|
|
|
|
|
|
ia64_mca_cmc_vector_setup(); /* Setup vector on AP */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PERFMON
|
|
|
|
pfm_init_percpu();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
local_irq_enable();
|
|
|
|
|
|
|
|
if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) {
|
|
|
|
/*
|
|
|
|
* Synchronize the ITC with the BP. Need to do this after irqs are
|
|
|
|
* enabled because ia64_sync_itc() calls smp_call_function_single(), which
|
|
|
|
* calls spin_unlock_bh(), which calls spin_unlock_bh(), which calls
|
|
|
|
* local_bh_enable(), which bugs out if irqs are not enabled...
|
|
|
|
*/
|
2005-11-11 22:32:40 +00:00
|
|
|
Dprintk("Going to syncup ITC with ITC Master.\n");
|
|
|
|
ia64_sync_itc(itc_master);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get our bogomips.
|
|
|
|
*/
|
|
|
|
ia64_init_itm();
|
2007-03-27 19:30:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Delay calibration can be skipped if new processor is identical to the
|
|
|
|
* previous processor.
|
|
|
|
*/
|
|
|
|
last_cpuinfo = cpu_data(cpuid - 1);
|
|
|
|
this_cpuinfo = local_cpu_data;
|
|
|
|
if (last_cpuinfo->itc_freq != this_cpuinfo->itc_freq ||
|
|
|
|
last_cpuinfo->proc_freq != this_cpuinfo->proc_freq ||
|
|
|
|
last_cpuinfo->features != this_cpuinfo->features ||
|
|
|
|
last_cpuinfo->revision != this_cpuinfo->revision ||
|
|
|
|
last_cpuinfo->family != this_cpuinfo->family ||
|
|
|
|
last_cpuinfo->archrev != this_cpuinfo->archrev ||
|
|
|
|
last_cpuinfo->model != this_cpuinfo->model)
|
|
|
|
calibrate_delay();
|
2005-04-16 22:20:36 +00:00
|
|
|
local_cpu_data->loops_per_jiffy = loops_per_jiffy;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allow the master to continue.
|
|
|
|
*/
|
|
|
|
cpu_set(cpuid, cpu_callin_map);
|
|
|
|
Dprintk("Stack on CPU %d at about %p\n",cpuid, &cpuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Activate a secondary processor. head.S calls this.
|
|
|
|
*/
|
2013-06-17 19:51:20 +00:00
|
|
|
int
|
2005-04-16 22:20:36 +00:00
|
|
|
start_secondary (void *unused)
|
|
|
|
{
|
|
|
|
/* Early console may use I/O ports */
|
|
|
|
ia64_set_kr(IA64_KR_IO_BASE, __pa(ia64_iobase));
|
2008-08-12 17:34:20 +00:00
|
|
|
#ifndef CONFIG_PRINTK_TIME
|
2005-04-16 22:20:36 +00:00
|
|
|
Dprintk("start_secondary: starting CPU 0x%x\n", hard_smp_processor_id());
|
2008-08-12 17:34:20 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
efi_map_pal_code();
|
|
|
|
cpu_init();
|
2005-11-09 05:39:01 +00:00
|
|
|
preempt_disable();
|
2005-04-16 22:20:36 +00:00
|
|
|
smp_callin();
|
|
|
|
|
2013-03-21 21:49:47 +00:00
|
|
|
cpu_startup_entry(CPUHP_ONLINE);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:51:20 +00:00
|
|
|
static int
|
2012-04-20 13:05:49 +00:00
|
|
|
do_boot_cpu (int sapicid, int cpu, struct task_struct *idle)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int timeout;
|
|
|
|
|
2012-04-20 13:05:49 +00:00
|
|
|
task_for_booting_cpu = idle;
|
2005-04-16 22:20:36 +00:00
|
|
|
Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid);
|
|
|
|
|
2005-04-22 21:44:40 +00:00
|
|
|
set_brendez_area(cpu);
|
2005-04-16 22:20:36 +00:00
|
|
|
platform_send_ipi(cpu, ap_wakeup_vector, IA64_IPI_DM_INT, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait 10s total for the AP to start
|
|
|
|
*/
|
|
|
|
Dprintk("Waiting on callin_map ...");
|
|
|
|
for (timeout = 0; timeout < 100000; timeout++) {
|
|
|
|
if (cpu_isset(cpu, cpu_callin_map))
|
|
|
|
break; /* It has booted */
|
|
|
|
udelay(100);
|
|
|
|
}
|
|
|
|
Dprintk("\n");
|
|
|
|
|
|
|
|
if (!cpu_isset(cpu, cpu_callin_map)) {
|
|
|
|
printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);
|
|
|
|
ia64_cpu_to_sapicid[cpu] = -1;
|
2012-03-28 21:42:46 +00:00
|
|
|
set_cpu_online(cpu, false); /* was set in smp_callin() */
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
decay (char *str)
|
|
|
|
{
|
|
|
|
int ticks;
|
|
|
|
get_option (&str, &ticks);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("decay=", decay);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the logical CPU number to SAPICID mapping
|
|
|
|
*/
|
|
|
|
void __init
|
|
|
|
smp_build_cpu_map (void)
|
|
|
|
{
|
|
|
|
int sapicid, cpu, i;
|
|
|
|
int boot_cpu_id = hard_smp_processor_id();
|
|
|
|
|
|
|
|
for (cpu = 0; cpu < NR_CPUS; cpu++) {
|
|
|
|
ia64_cpu_to_sapicid[cpu] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ia64_cpu_to_sapicid[0] = boot_cpu_id;
|
2012-03-28 21:42:46 +00:00
|
|
|
init_cpu_present(cpumask_of(0));
|
2009-03-16 03:42:43 +00:00
|
|
|
set_cpu_possible(0, true);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) {
|
|
|
|
sapicid = smp_boot_data.cpu_phys_id[i];
|
|
|
|
if (sapicid == boot_cpu_id)
|
|
|
|
continue;
|
2009-03-16 03:42:43 +00:00
|
|
|
set_cpu_present(cpu, true);
|
|
|
|
set_cpu_possible(cpu, true);
|
2005-04-16 22:20:36 +00:00
|
|
|
ia64_cpu_to_sapicid[cpu] = sapicid;
|
|
|
|
cpu++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cycle through the APs sending Wakeup IPIs to boot each.
|
|
|
|
*/
|
|
|
|
void __init
|
|
|
|
smp_prepare_cpus (unsigned int max_cpus)
|
|
|
|
{
|
|
|
|
int boot_cpu_id = hard_smp_processor_id();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the per-CPU profiling counter/multiplier
|
|
|
|
*/
|
|
|
|
|
|
|
|
smp_setup_percpu_timer();
|
|
|
|
|
|
|
|
cpu_set(0, cpu_callin_map);
|
|
|
|
|
|
|
|
local_cpu_data->loops_per_jiffy = loops_per_jiffy;
|
|
|
|
ia64_cpu_to_sapicid[0] = boot_cpu_id;
|
|
|
|
|
|
|
|
printk(KERN_INFO "Boot processor id 0x%x/0x%x\n", 0, boot_cpu_id);
|
|
|
|
|
|
|
|
current_thread_info()->cpu = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If SMP should be disabled, then really disable it!
|
|
|
|
*/
|
|
|
|
if (!max_cpus) {
|
|
|
|
printk(KERN_INFO "SMP mode deactivated.\n");
|
2009-03-16 03:42:43 +00:00
|
|
|
init_cpu_online(cpumask_of(0));
|
|
|
|
init_cpu_present(cpumask_of(0));
|
|
|
|
init_cpu_possible(cpumask_of(0));
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-21 22:05:13 +00:00
|
|
|
void smp_prepare_boot_cpu(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-03-28 21:42:46 +00:00
|
|
|
set_cpu_online(smp_processor_id(), true);
|
2005-04-16 22:20:36 +00:00
|
|
|
cpu_set(smp_processor_id(), cpu_callin_map);
|
2010-05-26 21:44:59 +00:00
|
|
|
set_numa_node(cpu_to_node_map[smp_processor_id()]);
|
2005-06-25 21:55:05 +00:00
|
|
|
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
|
2008-05-19 13:13:41 +00:00
|
|
|
paravirt_post_smp_prepare_boot_cpu();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2005-04-25 20:25:06 +00:00
|
|
|
static inline void
|
|
|
|
clear_cpu_sibling_map(int cpu)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-10-16 08:24:05 +00:00
|
|
|
for_each_cpu_mask(i, per_cpu(cpu_sibling_map, cpu))
|
|
|
|
cpu_clear(cpu, per_cpu(cpu_sibling_map, i));
|
2005-04-25 20:25:06 +00:00
|
|
|
for_each_cpu_mask(i, cpu_core_map[cpu])
|
|
|
|
cpu_clear(cpu, cpu_core_map[i]);
|
|
|
|
|
2007-10-16 08:24:05 +00:00
|
|
|
per_cpu(cpu_sibling_map, cpu) = cpu_core_map[cpu] = CPU_MASK_NONE;
|
2005-04-25 20:25:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remove_siblinginfo(int cpu)
|
|
|
|
{
|
|
|
|
int last = 0;
|
|
|
|
|
|
|
|
if (cpu_data(cpu)->threads_per_core == 1 &&
|
|
|
|
cpu_data(cpu)->cores_per_socket == 1) {
|
|
|
|
cpu_clear(cpu, cpu_core_map[cpu]);
|
2007-10-16 08:24:05 +00:00
|
|
|
cpu_clear(cpu, per_cpu(cpu_sibling_map, cpu));
|
2005-04-25 20:25:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
last = (cpus_weight(cpu_core_map[cpu]) == 1 ? 1 : 0);
|
|
|
|
|
|
|
|
/* remove it from all sibling map's */
|
|
|
|
clear_cpu_sibling_map(cpu);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void fixup_irqs(void);
|
2005-11-11 22:32:40 +00:00
|
|
|
|
|
|
|
int migrate_platform_irqs(unsigned int cpu)
|
|
|
|
{
|
|
|
|
int new_cpei_cpu;
|
2011-03-25 18:00:33 +00:00
|
|
|
struct irq_data *data = NULL;
|
2008-12-13 10:50:26 +00:00
|
|
|
const struct cpumask *mask;
|
2005-11-11 22:32:40 +00:00
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dont permit CPEI target to removed.
|
|
|
|
*/
|
|
|
|
if (cpe_vector > 0 && is_cpu_cpei_target(cpu)) {
|
|
|
|
printk ("CPU (%d) is CPEI Target\n", cpu);
|
|
|
|
if (can_cpei_retarget()) {
|
|
|
|
/*
|
|
|
|
* Now re-target the CPEI to a different processor
|
|
|
|
*/
|
2012-03-28 21:42:46 +00:00
|
|
|
new_cpei_cpu = cpumask_any(cpu_online_mask);
|
2008-12-13 10:50:26 +00:00
|
|
|
mask = cpumask_of(new_cpei_cpu);
|
2005-11-11 22:32:40 +00:00
|
|
|
set_cpei_target_cpu(new_cpei_cpu);
|
2011-03-25 18:00:33 +00:00
|
|
|
data = irq_get_irq_data(ia64_cpe_irq);
|
2005-11-11 22:32:40 +00:00
|
|
|
/*
|
2007-05-11 21:55:43 +00:00
|
|
|
* Switch for now, immediately, we need to do fake intr
|
2005-11-11 22:32:40 +00:00
|
|
|
* as other interrupts, but need to study CPEI behaviour with
|
|
|
|
* polling before making changes.
|
|
|
|
*/
|
2011-03-25 18:00:33 +00:00
|
|
|
if (data && data->chip) {
|
|
|
|
data->chip->irq_disable(data);
|
|
|
|
data->chip->irq_set_affinity(data, mask, false);
|
|
|
|
data->chip->irq_enable(data);
|
2011-03-31 01:57:33 +00:00
|
|
|
printk ("Re-targeting CPEI to cpu %d\n", new_cpei_cpu);
|
2005-11-11 22:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-25 18:00:33 +00:00
|
|
|
if (!data) {
|
2005-11-11 22:32:40 +00:00
|
|
|
printk ("Unable to retarget CPEI, offline cpu [%d] failed\n", cpu);
|
|
|
|
retval = -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* must be called with cpucontrol mutex held */
|
|
|
|
int __cpu_disable(void)
|
|
|
|
{
|
|
|
|
int cpu = smp_processor_id();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dont permit boot processor for now
|
|
|
|
*/
|
2005-11-11 22:32:40 +00:00
|
|
|
if (cpu == 0 && !bsp_remove_ok) {
|
|
|
|
printk ("Your platform does not support removal of BSP\n");
|
|
|
|
return (-EBUSY);
|
|
|
|
}
|
|
|
|
|
2007-08-23 00:32:06 +00:00
|
|
|
if (ia64_platform_is("sn2")) {
|
|
|
|
if (!sn_cpu_disable_allowed(cpu))
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2012-03-28 21:42:46 +00:00
|
|
|
set_cpu_online(cpu, false);
|
[IA64] Revert "prevent ia64 from invoking irq handlers on offline CPUs"
This reverts commit e7b140365b86aaf94374214c6f4e6decbee2eb0a.
Commit e7b14036 removes the targetted disabled CPU from the
cpu_online_map after calls to migrate_platform_irqs and fixup_irqs.
Paul McKenney states that the reasoning behind the patch was to
prevent irq handlers from running on CPUs marked offline because:
RCU happily ignores CPUs that don't have their bits set in
cpu_online_map, so if there are RCU read-side critical sections
in the irq handlers being run, RCU will ignore them. If the
other CPUs were running, they might sequence through the RCU
state machine, which could result in data structures being
yanked out from under those irq handlers, which in turn could
result in oopses or worse.
Unfortunately, both ia64 functions above look at cpu_online_map to find
a new CPU to migrate interrupts onto. This means we can potentially
migrate an interrupt off ourself back to... ourself. Uh oh.
This causes an oops when we finally try to process pending interrupts on
the CPU we want to disable. The oops results from calling __do_IRQ with
a NULL pt_regs:
Unable to handle kernel NULL pointer dereference (address 0000000000000040)
Call Trace:
[<a000000100016930>] show_stack+0x50/0xa0
sp=e0000009c922fa00 bsp=e0000009c92214d0
[<a0000001000171a0>] show_regs+0x820/0x860
sp=e0000009c922fbd0 bsp=e0000009c9221478
[<a00000010003c700>] die+0x1a0/0x2e0
sp=e0000009c922fbd0 bsp=e0000009c9221438
[<a0000001006e92f0>] ia64_do_page_fault+0x950/0xa80
sp=e0000009c922fbd0 bsp=e0000009c92213d8
[<a00000010000c7a0>] ia64_native_leave_kernel+0x0/0x270
sp=e0000009c922fc60 bsp=e0000009c92213d8
[<a0000001000ecdb0>] profile_tick+0xd0/0x1c0
sp=e0000009c922fe30 bsp=e0000009c9221398
[<a00000010003bb90>] timer_interrupt+0x170/0x3e0
sp=e0000009c922fe30 bsp=e0000009c9221330
[<a00000010013a800>] handle_IRQ_event+0x80/0x120
sp=e0000009c922fe30 bsp=e0000009c92212f8
[<a00000010013aa00>] __do_IRQ+0x160/0x4a0
sp=e0000009c922fe30 bsp=e0000009c9221290
[<a000000100012290>] ia64_process_pending_intr+0x2b0/0x360
sp=e0000009c922fe30 bsp=e0000009c9221208
[<a0000001000112d0>] fixup_irqs+0xf0/0x2a0
sp=e0000009c922fe30 bsp=e0000009c92211a8
[<a00000010005bd80>] __cpu_disable+0x140/0x240
sp=e0000009c922fe30 bsp=e0000009c9221168
[<a0000001006c5870>] take_cpu_down+0x50/0xa0
sp=e0000009c922fe30 bsp=e0000009c9221148
[<a000000100122610>] stop_cpu+0xd0/0x200
sp=e0000009c922fe30 bsp=e0000009c92210f0
[<a0000001000e0440>] kthread+0xc0/0x140
sp=e0000009c922fe30 bsp=e0000009c92210c8
[<a000000100014ab0>] kernel_thread_helper+0xd0/0x100
sp=e0000009c922fe30 bsp=e0000009c92210a0
[<a00000010000a4c0>] start_kernel_thread+0x20/0x40
sp=e0000009c922fe30 bsp=e0000009c92210a0
I don't like this revert because it is fragile. ia64 is getting lucky
because we seem to only ever process timer interrupts in this path, but
if we ever race with an IPI here, we definitely use RCU and have the
potential of hitting an oops that Paul describes above.
Patching ia64's timer_interrupt() to check for NULL pt_regs is
insufficient though, as we still hit the above oops.
As a short term solution, I do think that this revert is the right
answer. The revert hold up under repeated testing (24+ hour test runs)
with this setup:
- 8-way rx6600
- randomly toggling CPU online/offline state every 2 seconds
- running CPU exercisers, memory hog, disk exercisers, and
network stressors
- average system load around ~160
In the long term, we really need to figure out why we set pt_regs = NULL
in ia64_process_pending_intr(). If it turns out that it is unnecessary
to do so, then we could safely re-introduce e7b14036 (along with some
other logic to be smarter about migrating interrupts).
One final note: x86 also removes the disabled CPU from cpu_online_map
and then re-enables interrupts for 1ms, presumably to handle any pending
interrupts:
arch/x86/kernel/irq_32.c (and irq_64.c):
cpu_disable_common:
[remove cpu from cpu_online_map]
fixup_irqs():
for_each_irq:
[break CPU affinities]
local_irq_enable();
mdelay(1);
local_irq_disable();
So they are doing implicitly what ia64 is doing explicitly.
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Tony Luck <aegl@agluck-desktop.(none)>
2009-02-09 18:16:16 +00:00
|
|
|
|
2005-11-11 22:32:40 +00:00
|
|
|
if (migrate_platform_irqs(cpu)) {
|
2012-03-28 21:42:46 +00:00
|
|
|
set_cpu_online(cpu, true);
|
2009-02-09 18:16:57 +00:00
|
|
|
return -EBUSY;
|
2005-11-11 22:32:40 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
remove_siblinginfo(cpu);
|
[IA64] Revert "prevent ia64 from invoking irq handlers on offline CPUs"
This reverts commit e7b140365b86aaf94374214c6f4e6decbee2eb0a.
Commit e7b14036 removes the targetted disabled CPU from the
cpu_online_map after calls to migrate_platform_irqs and fixup_irqs.
Paul McKenney states that the reasoning behind the patch was to
prevent irq handlers from running on CPUs marked offline because:
RCU happily ignores CPUs that don't have their bits set in
cpu_online_map, so if there are RCU read-side critical sections
in the irq handlers being run, RCU will ignore them. If the
other CPUs were running, they might sequence through the RCU
state machine, which could result in data structures being
yanked out from under those irq handlers, which in turn could
result in oopses or worse.
Unfortunately, both ia64 functions above look at cpu_online_map to find
a new CPU to migrate interrupts onto. This means we can potentially
migrate an interrupt off ourself back to... ourself. Uh oh.
This causes an oops when we finally try to process pending interrupts on
the CPU we want to disable. The oops results from calling __do_IRQ with
a NULL pt_regs:
Unable to handle kernel NULL pointer dereference (address 0000000000000040)
Call Trace:
[<a000000100016930>] show_stack+0x50/0xa0
sp=e0000009c922fa00 bsp=e0000009c92214d0
[<a0000001000171a0>] show_regs+0x820/0x860
sp=e0000009c922fbd0 bsp=e0000009c9221478
[<a00000010003c700>] die+0x1a0/0x2e0
sp=e0000009c922fbd0 bsp=e0000009c9221438
[<a0000001006e92f0>] ia64_do_page_fault+0x950/0xa80
sp=e0000009c922fbd0 bsp=e0000009c92213d8
[<a00000010000c7a0>] ia64_native_leave_kernel+0x0/0x270
sp=e0000009c922fc60 bsp=e0000009c92213d8
[<a0000001000ecdb0>] profile_tick+0xd0/0x1c0
sp=e0000009c922fe30 bsp=e0000009c9221398
[<a00000010003bb90>] timer_interrupt+0x170/0x3e0
sp=e0000009c922fe30 bsp=e0000009c9221330
[<a00000010013a800>] handle_IRQ_event+0x80/0x120
sp=e0000009c922fe30 bsp=e0000009c92212f8
[<a00000010013aa00>] __do_IRQ+0x160/0x4a0
sp=e0000009c922fe30 bsp=e0000009c9221290
[<a000000100012290>] ia64_process_pending_intr+0x2b0/0x360
sp=e0000009c922fe30 bsp=e0000009c9221208
[<a0000001000112d0>] fixup_irqs+0xf0/0x2a0
sp=e0000009c922fe30 bsp=e0000009c92211a8
[<a00000010005bd80>] __cpu_disable+0x140/0x240
sp=e0000009c922fe30 bsp=e0000009c9221168
[<a0000001006c5870>] take_cpu_down+0x50/0xa0
sp=e0000009c922fe30 bsp=e0000009c9221148
[<a000000100122610>] stop_cpu+0xd0/0x200
sp=e0000009c922fe30 bsp=e0000009c92210f0
[<a0000001000e0440>] kthread+0xc0/0x140
sp=e0000009c922fe30 bsp=e0000009c92210c8
[<a000000100014ab0>] kernel_thread_helper+0xd0/0x100
sp=e0000009c922fe30 bsp=e0000009c92210a0
[<a00000010000a4c0>] start_kernel_thread+0x20/0x40
sp=e0000009c922fe30 bsp=e0000009c92210a0
I don't like this revert because it is fragile. ia64 is getting lucky
because we seem to only ever process timer interrupts in this path, but
if we ever race with an IPI here, we definitely use RCU and have the
potential of hitting an oops that Paul describes above.
Patching ia64's timer_interrupt() to check for NULL pt_regs is
insufficient though, as we still hit the above oops.
As a short term solution, I do think that this revert is the right
answer. The revert hold up under repeated testing (24+ hour test runs)
with this setup:
- 8-way rx6600
- randomly toggling CPU online/offline state every 2 seconds
- running CPU exercisers, memory hog, disk exercisers, and
network stressors
- average system load around ~160
In the long term, we really need to figure out why we set pt_regs = NULL
in ia64_process_pending_intr(). If it turns out that it is unnecessary
to do so, then we could safely re-introduce e7b14036 (along with some
other logic to be smarter about migrating interrupts).
One final note: x86 also removes the disabled CPU from cpu_online_map
and then re-enables interrupts for 1ms, presumably to handle any pending
interrupts:
arch/x86/kernel/irq_32.c (and irq_64.c):
cpu_disable_common:
[remove cpu from cpu_online_map]
fixup_irqs():
for_each_irq:
[break CPU affinities]
local_irq_enable();
mdelay(1);
local_irq_disable();
So they are doing implicitly what ia64 is doing explicitly.
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Tony Luck <aegl@agluck-desktop.(none)>
2009-02-09 18:16:16 +00:00
|
|
|
fixup_irqs();
|
2005-04-16 22:20:36 +00:00
|
|
|
local_flush_tlb_all();
|
2005-04-22 21:44:40 +00:00
|
|
|
cpu_clear(cpu, cpu_callin_map);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __cpu_die(unsigned int cpu)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
/* They ack this in play_dead by setting CPU_DEAD */
|
|
|
|
if (per_cpu(cpu_state, cpu) == CPU_DEAD)
|
|
|
|
{
|
2005-04-22 21:44:40 +00:00
|
|
|
printk ("CPU %d is now offline\n", cpu);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
msleep(100);
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|
|
|
|
|
|
|
|
void
|
|
|
|
smp_cpus_done (unsigned int dummy)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
unsigned long bogosum = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allow the user to impress friends.
|
|
|
|
*/
|
|
|
|
|
2005-10-10 15:43:26 +00:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
bogosum += cpu_data(cpu)->loops_per_jiffy;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
|
|
|
|
(int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
|
|
|
|
}
|
|
|
|
|
2012-12-21 22:05:13 +00:00
|
|
|
static inline void set_cpu_sibling_map(int cpu)
|
2005-04-25 20:25:06 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_online_cpu(i) {
|
|
|
|
if ((cpu_data(cpu)->socket_id == cpu_data(i)->socket_id)) {
|
|
|
|
cpu_set(i, cpu_core_map[cpu]);
|
|
|
|
cpu_set(cpu, cpu_core_map[i]);
|
|
|
|
if (cpu_data(cpu)->core_id == cpu_data(i)->core_id) {
|
2007-10-16 08:24:05 +00:00
|
|
|
cpu_set(i, per_cpu(cpu_sibling_map, cpu));
|
|
|
|
cpu_set(cpu, per_cpu(cpu_sibling_map, i));
|
2005-04-25 20:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:51:20 +00:00
|
|
|
int
|
2012-04-20 13:05:42 +00:00
|
|
|
__cpu_up(unsigned int cpu, struct task_struct *tidle)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int sapicid;
|
|
|
|
|
|
|
|
sapicid = ia64_cpu_to_sapicid[cpu];
|
|
|
|
if (sapicid == -1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
2005-04-22 21:44:40 +00:00
|
|
|
* Already booted cpu? not valid anymore since we dont
|
|
|
|
* do idle loop tightspin anymore.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
if (cpu_isset(cpu, cpu_callin_map))
|
2005-04-22 21:44:40 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2005-06-25 21:55:05 +00:00
|
|
|
per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Processor goes to start_secondary(), sets online flag */
|
2012-04-20 13:05:49 +00:00
|
|
|
ret = do_boot_cpu(sapicid, cpu, tidle);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
if (cpu_data(cpu)->threads_per_core == 1 &&
|
|
|
|
cpu_data(cpu)->cores_per_socket == 1) {
|
2007-10-16 08:24:05 +00:00
|
|
|
cpu_set(cpu, per_cpu(cpu_sibling_map, cpu));
|
2005-04-25 20:25:06 +00:00
|
|
|
cpu_set(cpu, cpu_core_map[cpu]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_cpu_sibling_map(cpu);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-11 21:55:43 +00:00
|
|
|
* Assume that CPUs have been discovered by some platform-dependent interface. For
|
2005-04-16 22:20:36 +00:00
|
|
|
* SoftSDV/Lion, that would be ACPI.
|
|
|
|
*
|
|
|
|
* Setup of the IPI irq handler is done in irq.c:init_IRQ_SMP().
|
|
|
|
*/
|
|
|
|
void __init
|
|
|
|
init_smp_config(void)
|
|
|
|
{
|
|
|
|
struct fptr {
|
|
|
|
unsigned long fp;
|
|
|
|
unsigned long gp;
|
|
|
|
} *ap_startup;
|
|
|
|
long sal_ret;
|
|
|
|
|
2007-05-11 21:55:43 +00:00
|
|
|
/* Tell SAL where to drop the APs. */
|
2005-04-16 22:20:36 +00:00
|
|
|
ap_startup = (struct fptr *) start_ap;
|
|
|
|
sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,
|
|
|
|
ia64_tpa(ap_startup->fp), ia64_tpa(ap_startup->gp), 0, 0, 0, 0);
|
|
|
|
if (sal_ret < 0)
|
|
|
|
printk(KERN_ERR "SMP: Can't set SAL AP Boot Rendezvous: %s\n",
|
|
|
|
ia64_sal_strerror(sal_ret));
|
|
|
|
}
|
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
/*
|
|
|
|
* identify_siblings(cpu) gets called from identify_cpu. This populates the
|
|
|
|
* information related to logical execution units in per_cpu_data structure.
|
|
|
|
*/
|
2012-12-21 22:05:13 +00:00
|
|
|
void identify_siblings(struct cpuinfo_ia64 *c)
|
2005-04-25 20:25:06 +00:00
|
|
|
{
|
2009-05-22 20:49:49 +00:00
|
|
|
long status;
|
2005-04-25 20:25:06 +00:00
|
|
|
u16 pltid;
|
|
|
|
pal_logical_to_physical_t info;
|
|
|
|
|
2008-04-24 18:57:08 +00:00
|
|
|
status = ia64_pal_logical_to_phys(-1, &info);
|
|
|
|
if (status != PAL_STATUS_SUCCESS) {
|
2007-10-19 19:20:09 +00:00
|
|
|
if (status != PAL_STATUS_UNIMPLEMENTED) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ia64_pal_logical_to_phys failed with %ld\n",
|
|
|
|
status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.overview_ppid = 0;
|
|
|
|
info.overview_cpp = 1;
|
|
|
|
info.overview_tpc = 1;
|
2005-04-25 20:25:06 +00:00
|
|
|
}
|
2008-04-24 18:57:08 +00:00
|
|
|
|
|
|
|
status = ia64_sal_physical_id_info(&pltid);
|
|
|
|
if (status != PAL_STATUS_SUCCESS) {
|
|
|
|
if (status != PAL_STATUS_UNIMPLEMENTED)
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ia64_sal_pltid failed with %ld\n",
|
|
|
|
status);
|
2005-04-25 20:25:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->socket_id = (pltid << 8) | info.overview_ppid;
|
2007-10-19 19:20:09 +00:00
|
|
|
|
|
|
|
if (info.overview_cpp == 1 && info.overview_tpc == 1)
|
|
|
|
return;
|
|
|
|
|
2005-04-25 20:25:06 +00:00
|
|
|
c->cores_per_socket = info.overview_cpp;
|
|
|
|
c->threads_per_core = info.overview_tpc;
|
2006-02-28 00:16:22 +00:00
|
|
|
c->num_log = info.overview_num_log;
|
2005-04-25 20:25:06 +00:00
|
|
|
|
2006-02-28 00:16:22 +00:00
|
|
|
c->core_id = info.log1_cid;
|
|
|
|
c->thread_id = info.log1_tid;
|
2005-04-25 20:25:06 +00:00
|
|
|
}
|
2006-09-21 17:35:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* returns non zero, if multi-threading is enabled
|
|
|
|
* on at least one physical package. Due to hotplug cpu
|
|
|
|
* and (maxcpus=), all threads may not necessarily be enabled
|
|
|
|
* even though the processor supports multi-threading.
|
|
|
|
*/
|
|
|
|
int is_multithreading_enabled(void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for_each_present_cpu(i) {
|
|
|
|
for_each_present_cpu(j) {
|
|
|
|
if (j == i)
|
|
|
|
continue;
|
|
|
|
if ((cpu_data(j)->socket_id == cpu_data(i)->socket_id)) {
|
|
|
|
if (cpu_data(j)->core_id == cpu_data(i)->core_id)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(is_multithreading_enabled);
|