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>
41 #include <asm/iSeries/HvCall.h>
43 #include <asm/ppcdebug.h>
44 #include <asm/machdep.h>
45 #include <asm/cputable.h>
46 #include <asm/system.h>
48 static unsigned long iSeries_smp_message
[NR_CPUS
];
50 void iSeries_smp_message_recv( struct pt_regs
* regs
)
52 int cpu
= smp_processor_id();
55 if ( num_online_cpus() < 2 )
58 for ( msg
= 0; msg
< 4; ++msg
)
59 if ( test_and_clear_bit( msg
, &iSeries_smp_message
[cpu
] ) )
60 smp_message_recv( msg
, regs
);
63 static inline void smp_iSeries_do_message(int cpu
, int msg
)
65 set_bit(msg
, &iSeries_smp_message
[cpu
]);
66 HvCall_sendIPI(&(paca
[cpu
]));
69 static void smp_iSeries_message_pass(int target
, int msg
)
74 smp_iSeries_do_message(target
, msg
);
76 for_each_online_cpu(i
) {
77 if (target
== MSG_ALL_BUT_SELF
78 && i
== smp_processor_id())
80 smp_iSeries_do_message(i
, msg
);
85 static int smp_iSeries_numProcs(void)
90 for (i
=0; i
< NR_CPUS
; ++i
) {
91 if (paca
[i
].lppaca
.dyn_proc_status
< 2) {
92 cpu_set(i
, cpu_possible_map
);
93 cpu_set(i
, cpu_present_map
);
94 cpu_set(i
, cpu_sibling_map
[i
]);
101 static int smp_iSeries_probe(void)
106 for (i
=0; i
< NR_CPUS
; ++i
) {
107 if (paca
[i
].lppaca
.dyn_proc_status
< 2) {
108 /*paca[i].active = 1;*/
116 static void smp_iSeries_kick_cpu(int nr
)
118 BUG_ON(nr
< 0 || nr
>= NR_CPUS
);
120 /* Verify that our partition has a processor nr */
121 if (paca
[nr
].lppaca
.dyn_proc_status
>= 2)
124 /* The processor is currently spinning, waiting
125 * for the cpu_start field to become non-zero
126 * After we set cpu_start, the processor will
127 * continue on to secondary_start in iSeries_head.S
129 paca
[nr
].cpu_start
= 1;
132 static void __devinit
smp_iSeries_setup_cpu(int nr
)
136 static struct smp_ops_t iSeries_smp_ops
= {
137 .message_pass
= smp_iSeries_message_pass
,
138 .probe
= smp_iSeries_probe
,
139 .kick_cpu
= smp_iSeries_kick_cpu
,
140 .setup_cpu
= smp_iSeries_setup_cpu
,
143 /* This is called very early. */
144 void __init
smp_init_iSeries(void)
146 smp_ops
= &iSeries_smp_ops
;
147 systemcfg
->processorCount
= smp_iSeries_numProcs();