2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SMP support for iSeries machines.
|
|
|
|
*
|
|
|
|
* Dave Engebretsen, Peter Bergner, and
|
|
|
|
* Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
|
|
|
|
*
|
|
|
|
* Plus various changes from other IBM teams...
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/cache.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/sysdev.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
2011-07-26 23:09:06 +00:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/smp.h>
|
|
|
|
#include <asm/paca.h>
|
2005-11-01 05:59:20 +00:00
|
|
|
#include <asm/iseries/hv_call.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
|
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-10 19:29:39 +00:00
|
|
|
static void smp_iSeries_cause_ipi(int cpu, unsigned long data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
HvCall_sendIPI(&(paca[cpu]));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int smp_iSeries_probe(void)
|
|
|
|
{
|
2010-04-26 15:32:36 +00:00
|
|
|
return cpumask_weight(cpu_possible_mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-04-11 21:46:19 +00:00
|
|
|
static int smp_iSeries_kick_cpu(int nr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-09-27 17:07:14 +00:00
|
|
|
BUG_ON((nr < 0) || (nr >= NR_CPUS));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Verify that our partition has a processor nr */
|
2010-08-12 20:18:15 +00:00
|
|
|
if (lppaca_of(nr).dyn_proc_status >= 2)
|
2011-04-11 21:46:19 +00:00
|
|
|
return -ENOENT;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* The processor is currently spinning, waiting
|
|
|
|
* for the cpu_start field to become non-zero
|
|
|
|
* After we set cpu_start, the processor will
|
|
|
|
* continue on to secondary_start in iSeries_head.S
|
|
|
|
*/
|
|
|
|
paca[nr].cpu_start = 1;
|
2011-04-11 21:46:19 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __devinit smp_iSeries_setup_cpu(int nr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct smp_ops_t iSeries_smp_ops = {
|
2011-05-25 23:34:12 +00:00
|
|
|
.message_pass = NULL, /* Use smp_muxed_ipi_message_pass */
|
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-10 19:29:39 +00:00
|
|
|
.cause_ipi = smp_iSeries_cause_ipi,
|
2005-04-16 22:20:36 +00:00
|
|
|
.probe = smp_iSeries_probe,
|
|
|
|
.kick_cpu = smp_iSeries_kick_cpu,
|
|
|
|
.setup_cpu = smp_iSeries_setup_cpu,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is called very early. */
|
|
|
|
void __init smp_init_iSeries(void)
|
|
|
|
{
|
|
|
|
smp_ops = &iSeries_smp_ops;
|
|
|
|
}
|