2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-11-05 07:33:55 +08:00
|
|
|
* smp.h: PowerPC-specific SMP code.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Original was a copy of sparc smp.h. Now heavily modified
|
|
|
|
* for PPC.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
* Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-11-05 07:33:55 +08:00
|
|
|
#ifndef _ASM_POWERPC_SMP_H
|
|
|
|
#define _ASM_POWERPC_SMP_H
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/kernel.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-11 03:29:39 +08:00
|
|
|
#include <linux/irqreturn.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2005-11-05 07:33:55 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/paca.h>
|
2005-11-05 07:33:55 +08:00
|
|
|
#endif
|
2007-10-16 16:24:05 +08:00
|
|
|
#include <asm/percpu.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern int boot_cpuid;
|
2011-05-26 02:09:12 +08:00
|
|
|
extern int spinning_secondaries;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern void cpu_die(void);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
|
2011-05-11 03:29:35 +08:00
|
|
|
struct smp_ops_t {
|
|
|
|
void (*message_pass)(int cpu, int msg);
|
2011-05-11 03:29:42 +08:00
|
|
|
#ifdef CONFIG_PPC_SMP_MUXED_IPI
|
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
|
|
|
void (*cause_ipi)(int cpu, unsigned long data);
|
2011-05-11 03:29:42 +08:00
|
|
|
#endif
|
2011-05-11 03:29:35 +08:00
|
|
|
int (*probe)(void);
|
|
|
|
int (*kick_cpu)(int nr);
|
|
|
|
void (*setup_cpu)(int nr);
|
|
|
|
void (*bringup_done)(void);
|
|
|
|
void (*take_timebase)(void);
|
|
|
|
void (*give_timebase)(void);
|
|
|
|
int (*cpu_disable)(void);
|
|
|
|
void (*cpu_die)(unsigned int nr);
|
|
|
|
int (*cpu_bootable)(unsigned int nr);
|
|
|
|
};
|
|
|
|
|
2011-05-11 03:29:06 +08:00
|
|
|
extern void smp_send_debugger_break(void);
|
2011-02-10 15:45:24 +08:00
|
|
|
extern void start_secondary_resume(void);
|
2011-05-11 03:29:35 +08:00
|
|
|
extern void __devinit smp_generic_give_timebase(void);
|
|
|
|
extern void __devinit smp_generic_take_timebase(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-10-29 21:34:14 +08:00
|
|
|
DECLARE_PER_CPU(unsigned int, cpu_pvr);
|
2008-05-08 12:27:19 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2011-02-11 10:05:17 +08:00
|
|
|
extern void migrate_irqs(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
int generic_cpu_disable(void);
|
|
|
|
void generic_cpu_die(unsigned int cpu);
|
|
|
|
void generic_mach_cpu_die(void);
|
2011-04-01 06:23:37 +08:00
|
|
|
void generic_set_cpu_dead(unsigned int cpu);
|
2011-09-20 01:44:49 +08:00
|
|
|
int generic_check_cpu_restart(unsigned int cpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2005-11-05 07:33:55 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2006-11-01 02:44:54 +08:00
|
|
|
#define raw_smp_processor_id() (local_paca->paca_index)
|
2005-04-17 06:20:36 +08:00
|
|
|
#define hard_smp_processor_id() (get_paca()->hw_cpu_id)
|
2005-11-05 07:33:55 +08:00
|
|
|
#else
|
|
|
|
/* 32-bit */
|
|
|
|
extern int smp_hw_index[];
|
|
|
|
|
|
|
|
#define raw_smp_processor_id() (current_thread_info()->cpu)
|
|
|
|
#define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
|
2008-08-18 12:23:48 +08:00
|
|
|
|
|
|
|
static inline int get_hard_smp_processor_id(int cpu)
|
|
|
|
{
|
|
|
|
return smp_hw_index[cpu];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_hard_smp_processor_id(int cpu, int phys)
|
|
|
|
{
|
|
|
|
smp_hw_index[cpu] = phys;
|
|
|
|
}
|
2005-11-05 07:33:55 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-26 23:32:41 +08:00
|
|
|
DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
|
|
|
|
DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
|
|
|
|
|
|
|
|
static inline struct cpumask *cpu_sibling_mask(int cpu)
|
|
|
|
{
|
|
|
|
return per_cpu(cpu_sibling_map, cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct cpumask *cpu_core_mask(int cpu)
|
|
|
|
{
|
|
|
|
return per_cpu(cpu_core_map, cpu);
|
|
|
|
}
|
|
|
|
|
2008-07-27 13:24:54 +08:00
|
|
|
extern int cpu_to_core_id(int cpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
|
|
|
|
*
|
|
|
|
* Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
|
|
|
|
* in /proc/interrupts will be wrong!!! --Troy */
|
|
|
|
#define PPC_MSG_CALL_FUNCTION 0
|
|
|
|
#define PPC_MSG_RESCHEDULE 1
|
2008-06-26 17:22:13 +08:00
|
|
|
#define PPC_MSG_CALL_FUNC_SINGLE 2
|
2005-04-17 06:20:36 +08:00
|
|
|
#define PPC_MSG_DEBUGGER_BREAK 3
|
|
|
|
|
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
|
|
|
/* for irq controllers that have dedicated ipis per message (4) */
|
2008-11-15 04:11:49 +08:00
|
|
|
extern int smp_request_message_ipi(int virq, int message);
|
|
|
|
extern const char *smp_ipi_name[];
|
|
|
|
|
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
|
|
|
/* for irq controllers with only a single ipi */
|
|
|
|
extern void smp_muxed_ipi_set_data(int cpu, unsigned long data);
|
|
|
|
extern void smp_muxed_ipi_message_pass(int cpu, int msg);
|
|
|
|
extern irqreturn_t smp_ipi_demux(void);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void smp_init_iSeries(void);
|
|
|
|
void smp_init_pSeries(void);
|
2005-11-01 09:08:38 +08:00
|
|
|
void smp_init_cell(void);
|
2007-02-02 15:47:17 +08:00
|
|
|
void smp_init_celleb(void);
|
2005-11-05 07:33:55 +08:00
|
|
|
void smp_setup_cpu_maps(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern int __cpu_disable(void);
|
|
|
|
extern void __cpu_die(unsigned int cpu);
|
2005-11-05 07:33:55 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
/* for UP */
|
2008-10-10 17:44:33 +08:00
|
|
|
#define hard_smp_processor_id() get_hard_smp_processor_id(0)
|
2005-11-05 07:33:55 +08:00
|
|
|
#define smp_setup_cpu_maps()
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
2005-11-05 07:33:55 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2008-08-18 12:23:48 +08:00
|
|
|
static inline int get_hard_smp_processor_id(int cpu)
|
|
|
|
{
|
|
|
|
return paca[cpu].hw_cpu_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_hard_smp_processor_id(int cpu, int phys)
|
|
|
|
{
|
|
|
|
paca[cpu].hw_cpu_id = phys;
|
|
|
|
}
|
2005-11-07 10:18:13 +08:00
|
|
|
|
|
|
|
extern void smp_release_cpus(void);
|
|
|
|
|
2005-11-05 07:33:55 +08:00
|
|
|
#else
|
|
|
|
/* 32-bit */
|
|
|
|
#ifndef CONFIG_SMP
|
2006-03-25 14:25:17 +08:00
|
|
|
extern int boot_cpuid_phys;
|
2008-08-18 12:23:48 +08:00
|
|
|
static inline int get_hard_smp_processor_id(int cpu)
|
|
|
|
{
|
|
|
|
return boot_cpuid_phys;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_hard_smp_processor_id(int cpu, int phys)
|
|
|
|
{
|
2008-10-10 17:44:33 +08:00
|
|
|
boot_cpuid_phys = phys;
|
2008-08-18 12:23:48 +08:00
|
|
|
}
|
|
|
|
#endif /* !CONFIG_SMP */
|
|
|
|
#endif /* !CONFIG_PPC64 */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern int smt_enabled_at_boot;
|
|
|
|
|
|
|
|
extern int smp_mpic_probe(void);
|
|
|
|
extern void smp_mpic_setup_cpu(int cpu);
|
2011-04-12 05:46:19 +08:00
|
|
|
extern int smp_generic_kick_cpu(int nr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern void smp_generic_give_timebase(void);
|
|
|
|
extern void smp_generic_take_timebase(void);
|
|
|
|
|
|
|
|
extern struct smp_ops_t *smp_ops;
|
|
|
|
|
2008-06-26 17:22:13 +08:00
|
|
|
extern void arch_send_call_function_single_ipi(int cpu);
|
2009-09-24 23:34:45 +08:00
|
|
|
extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
|
2008-06-26 17:22:13 +08:00
|
|
|
|
2009-07-24 07:15:28 +08:00
|
|
|
/* Definitions relative to the secondary CPU spin loop
|
|
|
|
* and entry point. Not all of them exist on both 32 and
|
|
|
|
* 64-bit but defining them all here doesn't harm
|
|
|
|
*/
|
|
|
|
extern void generic_secondary_smp_init(void);
|
2009-07-24 07:15:59 +08:00
|
|
|
extern void generic_secondary_thread_init(void);
|
2009-07-24 07:15:28 +08:00
|
|
|
extern unsigned long __secondary_hold_spinloop;
|
|
|
|
extern unsigned long __secondary_hold_acknowledge;
|
|
|
|
extern char __secondary_hold;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
2005-11-05 07:33:55 +08:00
|
|
|
#endif /* _ASM_POWERPC_SMP_H) */
|