2 * SMP support for iSeries machines.
4 * Dave Engebretsen, Peter Bergner, and
5 * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
7 * Plus various changes from other IBM teams...
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
17 #include <linux/config.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/sched.h>
21 #include <linux/smp.h>
22 #include <linux/smp_lock.h>
23 #include <linux/interrupt.h>
24 #include <linux/kernel_stat.h>
25 #include <linux/delay.h>
26 #include <linux/init.h>
27 #include <linux/spinlock.h>
28 #include <linux/cache.h>
29 #include <linux/err.h>
30 #include <linux/sysdev.h>
31 #include <linux/cpu.h>
33 #include <asm/ptrace.h>
34 #include <asm/atomic.h>
37 #include <asm/pgtable.h>
42 #include <asm/iSeries/LparData.h>
43 #include <asm/iSeries/HvCall.h>
44 #include <asm/iSeries/HvCallCfg.h>
46 #include <asm/ppcdebug.h>
47 #include <asm/machdep.h>
48 #include <asm/cputable.h>
49 #include <asm/system.h>
51 static unsigned long iSeries_smp_message[NR_CPUS];
53 void iSeries_smp_message_recv( struct pt_regs * regs )
55 int cpu = smp_processor_id();
58 if ( num_online_cpus() < 2 )
61 for ( msg = 0; msg < 4; ++msg )
62 if ( test_and_clear_bit( msg, &iSeries_smp_message[cpu] ) )
63 smp_message_recv( msg, regs );
66 static inline void smp_iSeries_do_message(int cpu, int msg)
68 set_bit(msg, &iSeries_smp_message[cpu]);
69 HvCall_sendIPI(&(paca[cpu]));
72 static void smp_iSeries_message_pass(int target, int msg)
77 smp_iSeries_do_message(target, msg);
79 for_each_online_cpu(i) {
80 if (target == MSG_ALL_BUT_SELF
81 && i == smp_processor_id())
83 smp_iSeries_do_message(i, msg);
88 static int smp_iSeries_numProcs(void)
93 for (i=0; i < NR_CPUS; ++i) {
94 if (paca[i].lppaca.xDynProcStatus < 2) {
95 cpu_set(i, cpu_possible_map);
96 cpu_set(i, cpu_present_map);
97 cpu_set(i, cpu_sibling_map[i]);
104 static int smp_iSeries_probe(void)
109 for (i=0; i < NR_CPUS; ++i) {
110 if (paca[i].lppaca.xDynProcStatus < 2) {
111 /*paca[i].active = 1;*/
119 static void smp_iSeries_kick_cpu(int nr)
121 BUG_ON(nr < 0 || nr >= NR_CPUS);
123 /* Verify that our partition has a processor nr */
124 if (paca[nr].lppaca.xDynProcStatus >= 2)
127 /* The processor is currently spinning, waiting
128 * for the cpu_start field to become non-zero
129 * After we set cpu_start, the processor will
130 * continue on to secondary_start in iSeries_head.S
132 paca[nr].cpu_start = 1;
135 static void __devinit smp_iSeries_setup_cpu(int nr)
139 static struct smp_ops_t iSeries_smp_ops = {
140 .message_pass = smp_iSeries_message_pass,
141 .probe = smp_iSeries_probe,
142 .kick_cpu = smp_iSeries_kick_cpu,
143 .setup_cpu = smp_iSeries_setup_cpu,
146 /* This is called very early. */
147 void __init smp_init_iSeries(void)
149 smp_ops = &iSeries_smp_ops;
150 systemcfg->processorCount = smp_iSeries_numProcs();