Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/sched.h> |
| 20 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #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 Daly | 1da4403 | 2005-11-01 16:59:20 +1100 | [diff] [blame] | 39 | #include <asm/iseries/hv_call.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <asm/time.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <asm/machdep.h> |
| 42 | #include <asm/cputable.h> |
| 43 | #include <asm/system.h> |
| 44 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 45 | static void smp_iSeries_cause_ipi(int cpu, unsigned long data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | HvCall_sendIPI(&(paca[cpu])); |
| 48 | } |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | static int smp_iSeries_probe(void) |
| 51 | { |
Anton Blanchard | 1157313 | 2010-04-26 15:32:36 +0000 | [diff] [blame] | 52 | return cpumask_weight(cpu_possible_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Michael Ellerman | de30097 | 2011-04-11 21:46:19 +0000 | [diff] [blame] | 55 | static int smp_iSeries_kick_cpu(int nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Stephen Rothwell | b6b8681 | 2005-09-28 03:07:14 +1000 | [diff] [blame] | 57 | BUG_ON((nr < 0) || (nr >= NR_CPUS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* Verify that our partition has a processor nr */ |
Paul Mackerras | 8154c5d | 2010-08-12 20:18:15 +0000 | [diff] [blame] | 60 | if (lppaca_of(nr).dyn_proc_status >= 2) |
Michael Ellerman | de30097 | 2011-04-11 21:46:19 +0000 | [diff] [blame] | 61 | return -ENOENT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* The processor is currently spinning, waiting |
| 64 | * for the cpu_start field to become non-zero |
| 65 | * After we set cpu_start, the processor will |
| 66 | * continue on to secondary_start in iSeries_head.S |
| 67 | */ |
| 68 | paca[nr].cpu_start = 1; |
Michael Ellerman | de30097 | 2011-04-11 21:46:19 +0000 | [diff] [blame] | 69 | |
| 70 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static void __devinit smp_iSeries_setup_cpu(int nr) |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | static struct smp_ops_t iSeries_smp_ops = { |
Paul Mackerras | 9ca980d | 2011-05-25 23:34:12 +0000 | [diff] [blame] | 78 | .message_pass = NULL, /* Use smp_muxed_ipi_message_pass */ |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 79 | .cause_ipi = smp_iSeries_cause_ipi, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | .probe = smp_iSeries_probe, |
| 81 | .kick_cpu = smp_iSeries_kick_cpu, |
| 82 | .setup_cpu = smp_iSeries_setup_cpu, |
| 83 | }; |
| 84 | |
| 85 | /* This is called very early. */ |
| 86 | void __init smp_init_iSeries(void) |
| 87 | { |
| 88 | smp_ops = &iSeries_smp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |