blob: 6590850045afe0c9c4d6184725cdb7d5ca29fb81 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * SMP support for iSeries machines.
3 *
4 * Dave Engebretsen, Peter Bergner, and
5 * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
6 *
7 * Plus various changes from other IBM teams...
8 *
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.
13 */
14
15#undef DEBUG
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/sched.h>
20#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/interrupt.h>
22#include <linux/kernel_stat.h>
23#include <linux/delay.h>
24#include <linux/init.h>
25#include <linux/spinlock.h>
26#include <linux/cache.h>
27#include <linux/err.h>
28#include <linux/sysdev.h>
29#include <linux/cpu.h>
30
31#include <asm/ptrace.h>
32#include <asm/atomic.h>
33#include <asm/irq.h>
34#include <asm/page.h>
35#include <asm/pgtable.h>
36#include <asm/io.h>
37#include <asm/smp.h>
38#include <asm/paca.h>
Kelly Daly1da44032005-11-01 16:59:20 +110039#include <asm/iseries/hv_call.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <asm/machdep.h>
42#include <asm/cputable.h>
43#include <asm/system.h>
44
Stephen Rothwell1224f372006-10-06 13:55:26 +100045#include "smp.h"
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047static unsigned long iSeries_smp_message[NR_CPUS];
48
Stephen Rothwell1224f372006-10-06 13:55:26 +100049void iSeries_smp_message_recv(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 int cpu = smp_processor_id();
52 int msg;
53
Stephen Rothwellb6b86812005-09-28 03:07:14 +100054 if (num_online_cpus() < 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 return;
56
Stephen Rothwellb6b86812005-09-28 03:07:14 +100057 for (msg = 0; msg < 4; msg++)
58 if (test_and_clear_bit(msg, &iSeries_smp_message[cpu]))
Stephen Rothwell1224f372006-10-06 13:55:26 +100059 smp_message_recv(msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
62static inline void smp_iSeries_do_message(int cpu, int msg)
63{
64 set_bit(msg, &iSeries_smp_message[cpu]);
65 HvCall_sendIPI(&(paca[cpu]));
66}
67
68static void smp_iSeries_message_pass(int target, int msg)
69{
70 int i;
71
72 if (target < NR_CPUS)
73 smp_iSeries_do_message(target, msg);
74 else {
75 for_each_online_cpu(i) {
Stephen Rothwellb6b86812005-09-28 03:07:14 +100076 if ((target == MSG_ALL_BUT_SELF) &&
77 (i == smp_processor_id()))
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 continue;
79 smp_iSeries_do_message(i, msg);
80 }
81 }
82}
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084static int smp_iSeries_probe(void)
85{
Anton Blanchard11573132010-04-26 15:32:36 +000086 return cpumask_weight(cpu_possible_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89static void smp_iSeries_kick_cpu(int nr)
90{
Stephen Rothwellb6b86812005-09-28 03:07:14 +100091 BUG_ON((nr < 0) || (nr >= NR_CPUS));
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 /* Verify that our partition has a processor nr */
David Gibson3356bb9f72006-01-13 10:26:42 +110094 if (lppaca[nr].dyn_proc_status >= 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 return;
96
97 /* The processor is currently spinning, waiting
98 * for the cpu_start field to become non-zero
99 * After we set cpu_start, the processor will
100 * continue on to secondary_start in iSeries_head.S
101 */
102 paca[nr].cpu_start = 1;
103}
104
105static void __devinit smp_iSeries_setup_cpu(int nr)
106{
107}
108
109static struct smp_ops_t iSeries_smp_ops = {
110 .message_pass = smp_iSeries_message_pass,
111 .probe = smp_iSeries_probe,
112 .kick_cpu = smp_iSeries_kick_cpu,
113 .setup_cpu = smp_iSeries_setup_cpu,
114};
115
116/* This is called very early. */
117void __init smp_init_iSeries(void)
118{
119 smp_ops = &iSeries_smp_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120}