diff options
-rw-r--r-- | arch/sh/Kconfig | 7 | ||||
-rw-r--r-- | arch/sh/boards/board-urquell.c | 3 | ||||
-rw-r--r-- | arch/sh/boards/mach-sdk7786/setup.c | 3 | ||||
-rw-r--r-- | arch/sh/boards/mach-x3proto/setup.c | 7 | ||||
-rw-r--r-- | arch/sh/include/asm/irq.h | 3 | ||||
-rw-r--r-- | arch/sh/include/asm/processor.h | 4 | ||||
-rw-r--r-- | arch/sh/include/asm/smp-ops.h | 51 | ||||
-rw-r--r-- | arch/sh/include/asm/smp.h | 40 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/smp-shx3.c | 70 | ||||
-rw-r--r-- | arch/sh/kernel/idle.c | 8 | ||||
-rw-r--r-- | arch/sh/kernel/irq.c | 42 | ||||
-rw-r--r-- | arch/sh/kernel/localtimer.c | 6 | ||||
-rw-r--r-- | arch/sh/kernel/setup.c | 3 | ||||
-rw-r--r-- | arch/sh/kernel/smp.c | 160 | ||||
-rw-r--r-- | arch/sh/kernel/topology.c | 6 |
15 files changed, 373 insertions, 40 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ba86bfba95ac..d73bd4db5e84 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
@@ -706,6 +706,13 @@ config NR_CPUS | |||
706 | This is purely to save memory - each supported CPU adds | 706 | This is purely to save memory - each supported CPU adds |
707 | approximately eight kilobytes to the kernel image. | 707 | approximately eight kilobytes to the kernel image. |
708 | 708 | ||
709 | config HOTPLUG_CPU | ||
710 | bool "Support for hot-pluggable CPUs (EXPERIMENTAL)" | ||
711 | depends on SMP && HOTPLUG && EXPERIMENTAL | ||
712 | help | ||
713 | Say Y here to experiment with turning CPUs off and on. CPUs | ||
714 | can be controlled through /sys/devices/system/cpu. | ||
715 | |||
709 | source "kernel/Kconfig.preempt" | 716 | source "kernel/Kconfig.preempt" |
710 | 717 | ||
711 | config GUSA | 718 | config GUSA |
diff --git a/arch/sh/boards/board-urquell.c b/arch/sh/boards/board-urquell.c index a9bd6e3ee10b..d81c609decc7 100644 --- a/arch/sh/boards/board-urquell.c +++ b/arch/sh/boards/board-urquell.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <cpu/sh7786.h> | 24 | #include <cpu/sh7786.h> |
25 | #include <asm/heartbeat.h> | 25 | #include <asm/heartbeat.h> |
26 | #include <asm/sizes.h> | 26 | #include <asm/sizes.h> |
27 | #include <asm/smp-ops.h> | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * bit 1234 5678 | 30 | * bit 1234 5678 |
@@ -203,6 +204,8 @@ static void __init urquell_setup(char **cmdline_p) | |||
203 | printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n"); | 204 | printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n"); |
204 | 205 | ||
205 | pm_power_off = urquell_power_off; | 206 | pm_power_off = urquell_power_off; |
207 | |||
208 | register_smp_ops(&shx3_smp_ops); | ||
206 | } | 209 | } |
207 | 210 | ||
208 | /* | 211 | /* |
diff --git a/arch/sh/boards/mach-sdk7786/setup.c b/arch/sh/boards/mach-sdk7786/setup.c index 0c057a93fe29..2ec1ea5cf8ef 100644 --- a/arch/sh/boards/mach-sdk7786/setup.c +++ b/arch/sh/boards/mach-sdk7786/setup.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/heartbeat.h> | 21 | #include <asm/heartbeat.h> |
22 | #include <asm/sizes.h> | 22 | #include <asm/sizes.h> |
23 | #include <asm/reboot.h> | 23 | #include <asm/reboot.h> |
24 | #include <asm/smp-ops.h> | ||
24 | 25 | ||
25 | static struct resource heartbeat_resource = { | 26 | static struct resource heartbeat_resource = { |
26 | .start = 0x07fff8b0, | 27 | .start = 0x07fff8b0, |
@@ -189,6 +190,8 @@ static void __init sdk7786_setup(char **cmdline_p) | |||
189 | 190 | ||
190 | machine_ops.restart = sdk7786_restart; | 191 | machine_ops.restart = sdk7786_restart; |
191 | pm_power_off = sdk7786_power_off; | 192 | pm_power_off = sdk7786_power_off; |
193 | |||
194 | register_smp_ops(&shx3_smp_ops); | ||
192 | } | 195 | } |
193 | 196 | ||
194 | /* | 197 | /* |
diff --git a/arch/sh/boards/mach-x3proto/setup.c b/arch/sh/boards/mach-x3proto/setup.c index e284592fd42a..102bf56befb4 100644 --- a/arch/sh/boards/mach-x3proto/setup.c +++ b/arch/sh/boards/mach-x3proto/setup.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/usb/r8a66597.h> | 19 | #include <linux/usb/r8a66597.h> |
20 | #include <linux/usb/m66592.h> | 20 | #include <linux/usb/m66592.h> |
21 | #include <asm/ilsel.h> | 21 | #include <asm/ilsel.h> |
22 | #include <asm/smp-ops.h> | ||
22 | 23 | ||
23 | static struct resource heartbeat_resources[] = { | 24 | static struct resource heartbeat_resources[] = { |
24 | [0] = { | 25 | [0] = { |
@@ -152,7 +153,13 @@ static void __init x3proto_init_irq(void) | |||
152 | __raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000); | 153 | __raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000); |
153 | } | 154 | } |
154 | 155 | ||
156 | static void __init x3proto_setup(char **cmdline_p) | ||
157 | { | ||
158 | register_smp_ops(&shx3_smp_ops); | ||
159 | } | ||
160 | |||
155 | static struct sh_machine_vector mv_x3proto __initmv = { | 161 | static struct sh_machine_vector mv_x3proto __initmv = { |
156 | .mv_name = "x3proto", | 162 | .mv_name = "x3proto", |
163 | .mv_setup = x3proto_setup, | ||
157 | .mv_init_irq = x3proto_init_irq, | 164 | .mv_init_irq = x3proto_init_irq, |
158 | }; | 165 | }; |
diff --git a/arch/sh/include/asm/irq.h b/arch/sh/include/asm/irq.h index 99c593b3a827..02c2f0102cfa 100644 --- a/arch/sh/include/asm/irq.h +++ b/arch/sh/include/asm/irq.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __ASM_SH_IRQ_H | 1 | #ifndef __ASM_SH_IRQ_H |
2 | #define __ASM_SH_IRQ_H | 2 | #define __ASM_SH_IRQ_H |
3 | 3 | ||
4 | #include <linux/cpumask.h> | ||
4 | #include <asm/machvec.h> | 5 | #include <asm/machvec.h> |
5 | 6 | ||
6 | /* | 7 | /* |
@@ -50,6 +51,8 @@ static inline int generic_irq_demux(int irq) | |||
50 | #define irq_demux(irq) sh_mv.mv_irq_demux(irq) | 51 | #define irq_demux(irq) sh_mv.mv_irq_demux(irq) |
51 | 52 | ||
52 | void init_IRQ(void); | 53 | void init_IRQ(void); |
54 | void migrate_irqs(void); | ||
55 | |||
53 | asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs); | 56 | asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs); |
54 | 57 | ||
55 | #ifdef CONFIG_IRQSTACKS | 58 | #ifdef CONFIG_IRQSTACKS |
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h index 26b3f026eec9..0a58cb25a658 100644 --- a/arch/sh/include/asm/processor.h +++ b/arch/sh/include/asm/processor.h | |||
@@ -85,6 +85,10 @@ struct sh_cpuinfo { | |||
85 | struct tlb_info itlb; | 85 | struct tlb_info itlb; |
86 | struct tlb_info dtlb; | 86 | struct tlb_info dtlb; |
87 | 87 | ||
88 | #ifdef CONFIG_SMP | ||
89 | struct task_struct *idle; | ||
90 | #endif | ||
91 | |||
88 | unsigned long flags; | 92 | unsigned long flags; |
89 | } __attribute__ ((aligned(L1_CACHE_BYTES))); | 93 | } __attribute__ ((aligned(L1_CACHE_BYTES))); |
90 | 94 | ||
diff --git a/arch/sh/include/asm/smp-ops.h b/arch/sh/include/asm/smp-ops.h new file mode 100644 index 000000000000..c590f76856f1 --- /dev/null +++ b/arch/sh/include/asm/smp-ops.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef __ASM_SH_SMP_OPS_H | ||
2 | #define __ASM_SH_SMP_OPS_H | ||
3 | |||
4 | struct plat_smp_ops { | ||
5 | void (*smp_setup)(void); | ||
6 | unsigned int (*smp_processor_id)(void); | ||
7 | void (*prepare_cpus)(unsigned int max_cpus); | ||
8 | void (*start_cpu)(unsigned int cpu, unsigned long entry_point); | ||
9 | void (*send_ipi)(unsigned int cpu, unsigned int message); | ||
10 | int (*cpu_disable)(unsigned int cpu); | ||
11 | void (*cpu_die)(unsigned int cpu); | ||
12 | void (*play_dead)(void); | ||
13 | }; | ||
14 | |||
15 | extern struct plat_smp_ops *mp_ops; | ||
16 | extern struct plat_smp_ops shx3_smp_ops; | ||
17 | |||
18 | #ifdef CONFIG_SMP | ||
19 | |||
20 | static inline void plat_smp_setup(void) | ||
21 | { | ||
22 | BUG_ON(!mp_ops); | ||
23 | mp_ops->smp_setup(); | ||
24 | } | ||
25 | |||
26 | static inline void play_dead(void) | ||
27 | { | ||
28 | mp_ops->play_dead(); | ||
29 | } | ||
30 | |||
31 | extern void register_smp_ops(struct plat_smp_ops *ops); | ||
32 | |||
33 | #else | ||
34 | |||
35 | static inline void plat_smp_setup(void) | ||
36 | { | ||
37 | /* UP, nothing to do ... */ | ||
38 | } | ||
39 | |||
40 | static inline void register_smp_ops(struct plat_smp_ops *ops) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | static inline void play_dead(void) | ||
45 | { | ||
46 | BUG(); | ||
47 | } | ||
48 | |||
49 | #endif /* CONFIG_SMP */ | ||
50 | |||
51 | #endif /* __ASM_SH_SMP_OPS_H */ | ||
diff --git a/arch/sh/include/asm/smp.h b/arch/sh/include/asm/smp.h index 53ef26ced75f..9070d943ddde 100644 --- a/arch/sh/include/asm/smp.h +++ b/arch/sh/include/asm/smp.h | |||
@@ -3,15 +3,16 @@ | |||
3 | 3 | ||
4 | #include <linux/bitops.h> | 4 | #include <linux/bitops.h> |
5 | #include <linux/cpumask.h> | 5 | #include <linux/cpumask.h> |
6 | #include <asm/smp-ops.h> | ||
6 | 7 | ||
7 | #ifdef CONFIG_SMP | 8 | #ifdef CONFIG_SMP |
8 | 9 | ||
9 | #include <linux/spinlock.h> | 10 | #include <linux/spinlock.h> |
10 | #include <asm/atomic.h> | 11 | #include <asm/atomic.h> |
11 | #include <asm/current.h> | 12 | #include <asm/current.h> |
13 | #include <asm/percpu.h> | ||
12 | 14 | ||
13 | #define raw_smp_processor_id() (current_thread_info()->cpu) | 15 | #define raw_smp_processor_id() (current_thread_info()->cpu) |
14 | #define hard_smp_processor_id() plat_smp_processor_id() | ||
15 | 16 | ||
16 | /* Map from cpu id to sequential logical cpu number. */ | 17 | /* Map from cpu id to sequential logical cpu number. */ |
17 | extern int __cpu_number_map[NR_CPUS]; | 18 | extern int __cpu_number_map[NR_CPUS]; |
@@ -30,20 +31,43 @@ enum { | |||
30 | SMP_MSG_NR, /* must be last */ | 31 | SMP_MSG_NR, /* must be last */ |
31 | }; | 32 | }; |
32 | 33 | ||
34 | DECLARE_PER_CPU(int, cpu_state); | ||
35 | |||
33 | void smp_message_recv(unsigned int msg); | 36 | void smp_message_recv(unsigned int msg); |
34 | void smp_timer_broadcast(const struct cpumask *mask); | 37 | void smp_timer_broadcast(const struct cpumask *mask); |
35 | 38 | ||
36 | void local_timer_interrupt(void); | 39 | void local_timer_interrupt(void); |
37 | void local_timer_setup(unsigned int cpu); | 40 | void local_timer_setup(unsigned int cpu); |
38 | 41 | void local_timer_stop(unsigned int cpu); | |
39 | void plat_smp_setup(void); | ||
40 | void plat_prepare_cpus(unsigned int max_cpus); | ||
41 | int plat_smp_processor_id(void); | ||
42 | void plat_start_cpu(unsigned int cpu, unsigned long entry_point); | ||
43 | void plat_send_ipi(unsigned int cpu, unsigned int message); | ||
44 | 42 | ||
45 | void arch_send_call_function_single_ipi(int cpu); | 43 | void arch_send_call_function_single_ipi(int cpu); |
46 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); | 44 | void arch_send_call_function_ipi_mask(const struct cpumask *mask); |
45 | |||
46 | void native_play_dead(void); | ||
47 | void native_cpu_die(unsigned int cpu); | ||
48 | int native_cpu_disable(unsigned int cpu); | ||
49 | |||
50 | #ifdef CONFIG_HOTPLUG_CPU | ||
51 | void play_dead_common(void); | ||
52 | extern int __cpu_disable(void); | ||
53 | |||
54 | static inline void __cpu_die(unsigned int cpu) | ||
55 | { | ||
56 | extern struct plat_smp_ops *mp_ops; /* private */ | ||
57 | |||
58 | mp_ops->cpu_die(cpu); | ||
59 | } | ||
60 | #endif | ||
61 | |||
62 | static inline int hard_smp_processor_id(void) | ||
63 | { | ||
64 | extern struct plat_smp_ops *mp_ops; /* private */ | ||
65 | |||
66 | if (!mp_ops) | ||
67 | return 0; /* boot CPU */ | ||
68 | |||
69 | return mp_ops->smp_processor_id(); | ||
70 | } | ||
47 | 71 | ||
48 | #else | 72 | #else |
49 | 73 | ||
diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c index c98b4574c44e..de865cac02ee 100644 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SH-X3 SMP | 2 | * SH-X3 SMP |
3 | * | 3 | * |
4 | * Copyright (C) 2007 - 2008 Paul Mundt | 4 | * Copyright (C) 2007 - 2010 Paul Mundt |
5 | * Copyright (C) 2007 Magnus Damm | 5 | * Copyright (C) 2007 Magnus Damm |
6 | * | 6 | * |
7 | * This file is subject to the terms and conditions of the GNU General Public | 7 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -9,16 +9,22 @@ | |||
9 | * for more details. | 9 | * for more details. |
10 | */ | 10 | */ |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/kernel.h> | ||
12 | #include <linux/cpumask.h> | 13 | #include <linux/cpumask.h> |
13 | #include <linux/smp.h> | 14 | #include <linux/smp.h> |
14 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
15 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/cpu.h> | ||
20 | #include <asm/sections.h> | ||
16 | 21 | ||
17 | #define STBCR_REG(phys_id) (0xfe400004 | (phys_id << 12)) | 22 | #define STBCR_REG(phys_id) (0xfe400004 | (phys_id << 12)) |
18 | #define RESET_REG(phys_id) (0xfe400008 | (phys_id << 12)) | 23 | #define RESET_REG(phys_id) (0xfe400008 | (phys_id << 12)) |
19 | 24 | ||
20 | #define STBCR_MSTP 0x00000001 | 25 | #define STBCR_MSTP 0x00000001 |
21 | #define STBCR_RESET 0x00000002 | 26 | #define STBCR_RESET 0x00000002 |
27 | #define STBCR_SLEEP 0x00000004 | ||
22 | #define STBCR_LTSLP 0x80000000 | 28 | #define STBCR_LTSLP 0x80000000 |
23 | 29 | ||
24 | static irqreturn_t ipi_interrupt_handler(int irq, void *arg) | 30 | static irqreturn_t ipi_interrupt_handler(int irq, void *arg) |
@@ -37,7 +43,7 @@ static irqreturn_t ipi_interrupt_handler(int irq, void *arg) | |||
37 | return IRQ_HANDLED; | 43 | return IRQ_HANDLED; |
38 | } | 44 | } |
39 | 45 | ||
40 | void __init plat_smp_setup(void) | 46 | static void shx3_smp_setup(void) |
41 | { | 47 | { |
42 | unsigned int cpu = 0; | 48 | unsigned int cpu = 0; |
43 | int i, num; | 49 | int i, num; |
@@ -63,7 +69,7 @@ void __init plat_smp_setup(void) | |||
63 | printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num); | 69 | printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num); |
64 | } | 70 | } |
65 | 71 | ||
66 | void __init plat_prepare_cpus(unsigned int max_cpus) | 72 | static void shx3_prepare_cpus(unsigned int max_cpus) |
67 | { | 73 | { |
68 | int i; | 74 | int i; |
69 | 75 | ||
@@ -74,9 +80,12 @@ void __init plat_prepare_cpus(unsigned int max_cpus) | |||
74 | for (i = 0; i < SMP_MSG_NR; i++) | 80 | for (i = 0; i < SMP_MSG_NR; i++) |
75 | request_irq(104 + i, ipi_interrupt_handler, | 81 | request_irq(104 + i, ipi_interrupt_handler, |
76 | IRQF_DISABLED | IRQF_PERCPU, "IPI", (void *)(long)i); | 82 | IRQF_DISABLED | IRQF_PERCPU, "IPI", (void *)(long)i); |
83 | |||
84 | for (i = 0; i < max_cpus; i++) | ||
85 | set_cpu_present(i, true); | ||
77 | } | 86 | } |
78 | 87 | ||
79 | void plat_start_cpu(unsigned int cpu, unsigned long entry_point) | 88 | static void shx3_start_cpu(unsigned int cpu, unsigned long entry_point) |
80 | { | 89 | { |
81 | if (__in_29bit_mode()) | 90 | if (__in_29bit_mode()) |
82 | __raw_writel(entry_point, RESET_REG(cpu)); | 91 | __raw_writel(entry_point, RESET_REG(cpu)); |
@@ -93,12 +102,12 @@ void plat_start_cpu(unsigned int cpu, unsigned long entry_point) | |||
93 | __raw_writel(STBCR_RESET | STBCR_LTSLP, STBCR_REG(cpu)); | 102 | __raw_writel(STBCR_RESET | STBCR_LTSLP, STBCR_REG(cpu)); |
94 | } | 103 | } |
95 | 104 | ||
96 | int plat_smp_processor_id(void) | 105 | static unsigned int shx3_smp_processor_id(void) |
97 | { | 106 | { |
98 | return __raw_readl(0xff000048); /* CPIDR */ | 107 | return __raw_readl(0xff000048); /* CPIDR */ |
99 | } | 108 | } |
100 | 109 | ||
101 | void plat_send_ipi(unsigned int cpu, unsigned int message) | 110 | static void shx3_send_ipi(unsigned int cpu, unsigned int message) |
102 | { | 111 | { |
103 | unsigned long addr = 0xfe410070 + (cpu * 4); | 112 | unsigned long addr = 0xfe410070 + (cpu * 4); |
104 | 113 | ||
@@ -106,3 +115,52 @@ void plat_send_ipi(unsigned int cpu, unsigned int message) | |||
106 | 115 | ||
107 | __raw_writel(1 << (message << 2), addr); /* C0INTICI..CnINTICI */ | 116 | __raw_writel(1 << (message << 2), addr); /* C0INTICI..CnINTICI */ |
108 | } | 117 | } |
118 | |||
119 | static void shx3_update_boot_vector(unsigned int cpu) | ||
120 | { | ||
121 | __raw_writel(STBCR_MSTP, STBCR_REG(cpu)); | ||
122 | while (!(__raw_readl(STBCR_REG(cpu)) & STBCR_MSTP)) | ||
123 | cpu_relax(); | ||
124 | __raw_writel(STBCR_RESET, STBCR_REG(cpu)); | ||
125 | } | ||
126 | |||
127 | static int __cpuinit | ||
128 | shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | ||
129 | { | ||
130 | unsigned int cpu = (unsigned int)hcpu; | ||
131 | |||
132 | switch (action) { | ||
133 | case CPU_UP_PREPARE: | ||
134 | shx3_update_boot_vector(cpu); | ||
135 | break; | ||
136 | case CPU_ONLINE: | ||
137 | pr_info("CPU %u is now online\n", cpu); | ||
138 | break; | ||
139 | case CPU_DEAD: | ||
140 | break; | ||
141 | } | ||
142 | |||
143 | return NOTIFY_OK; | ||
144 | } | ||
145 | |||
146 | static struct notifier_block __cpuinitdata shx3_cpu_notifier = { | ||
147 | .notifier_call = shx3_cpu_callback, | ||
148 | }; | ||
149 | |||
150 | static int __cpuinit register_shx3_cpu_notifier(void) | ||
151 | { | ||
152 | register_hotcpu_notifier(&shx3_cpu_notifier); | ||
153 | return 0; | ||
154 | } | ||
155 | late_initcall(register_shx3_cpu_notifier); | ||
156 | |||
157 | struct plat_smp_ops shx3_smp_ops = { | ||
158 | .smp_setup = shx3_smp_setup, | ||
159 | .prepare_cpus = shx3_prepare_cpus, | ||
160 | .start_cpu = shx3_start_cpu, | ||
161 | .smp_processor_id = shx3_smp_processor_id, | ||
162 | .send_ipi = shx3_send_ipi, | ||
163 | .cpu_die = native_cpu_die, | ||
164 | .cpu_disable = native_cpu_disable, | ||
165 | .play_dead = native_play_dead, | ||
166 | }; | ||
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c index 273f890b17ae..425d604e3a28 100644 --- a/arch/sh/kernel/idle.c +++ b/arch/sh/kernel/idle.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/pgalloc.h> | 19 | #include <asm/pgalloc.h> |
20 | #include <asm/system.h> | 20 | #include <asm/system.h> |
21 | #include <asm/atomic.h> | 21 | #include <asm/atomic.h> |
22 | #include <asm/smp.h> | ||
22 | 23 | ||
23 | void (*pm_idle)(void) = NULL; | 24 | void (*pm_idle)(void) = NULL; |
24 | 25 | ||
@@ -89,10 +90,13 @@ void cpu_idle(void) | |||
89 | while (1) { | 90 | while (1) { |
90 | tick_nohz_stop_sched_tick(1); | 91 | tick_nohz_stop_sched_tick(1); |
91 | 92 | ||
92 | while (!need_resched() && cpu_online(cpu)) { | 93 | while (!need_resched()) { |
93 | check_pgt_cache(); | 94 | check_pgt_cache(); |
94 | rmb(); | 95 | rmb(); |
95 | 96 | ||
97 | if (cpu_is_offline(cpu)) | ||
98 | play_dead(); | ||
99 | |||
96 | local_irq_disable(); | 100 | local_irq_disable(); |
97 | /* Don't trace irqs off for idle */ | 101 | /* Don't trace irqs off for idle */ |
98 | stop_critical_timings(); | 102 | stop_critical_timings(); |
@@ -133,7 +137,7 @@ static void do_nothing(void *unused) | |||
133 | void stop_this_cpu(void *unused) | 137 | void stop_this_cpu(void *unused) |
134 | { | 138 | { |
135 | local_irq_disable(); | 139 | local_irq_disable(); |
136 | cpu_clear(smp_processor_id(), cpu_online_map); | 140 | set_cpu_online(smp_processor_id(), false); |
137 | 141 | ||
138 | for (;;) | 142 | for (;;) |
139 | cpu_sleep(); | 143 | cpu_sleep(); |
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c index f6a9319c28e2..257de1f0692b 100644 --- a/arch/sh/kernel/irq.c +++ b/arch/sh/kernel/irq.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel_stat.h> | 12 | #include <linux/kernel_stat.h> |
13 | #include <linux/seq_file.h> | 13 | #include <linux/seq_file.h> |
14 | #include <linux/ftrace.h> | 14 | #include <linux/ftrace.h> |
15 | #include <linux/delay.h> | ||
15 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
16 | #include <asm/machvec.h> | 17 | #include <asm/machvec.h> |
17 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
@@ -292,3 +293,44 @@ int __init arch_probe_nr_irqs(void) | |||
292 | return 0; | 293 | return 0; |
293 | } | 294 | } |
294 | #endif | 295 | #endif |
296 | |||
297 | #ifdef CONFIG_HOTPLUG_CPU | ||
298 | static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu) | ||
299 | { | ||
300 | printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n", | ||
301 | irq, desc->node, cpu); | ||
302 | |||
303 | raw_spin_lock_irq(&desc->lock); | ||
304 | desc->chip->set_affinity(irq, cpumask_of(cpu)); | ||
305 | raw_spin_unlock_irq(&desc->lock); | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * The CPU has been marked offline. Migrate IRQs off this CPU. If | ||
310 | * the affinity settings do not allow other CPUs, force them onto any | ||
311 | * available CPU. | ||
312 | */ | ||
313 | void migrate_irqs(void) | ||
314 | { | ||
315 | struct irq_desc *desc; | ||
316 | unsigned int irq, cpu = smp_processor_id(); | ||
317 | |||
318 | for_each_irq_desc(irq, desc) { | ||
319 | if (desc->node == cpu) { | ||
320 | unsigned int newcpu = cpumask_any_and(desc->affinity, | ||
321 | cpu_online_mask); | ||
322 | if (newcpu >= nr_cpu_ids) { | ||
323 | if (printk_ratelimit()) | ||
324 | printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n", | ||
325 | irq, cpu); | ||
326 | |||
327 | cpumask_setall(desc->affinity); | ||
328 | newcpu = cpumask_any_and(desc->affinity, | ||
329 | cpu_online_mask); | ||
330 | } | ||
331 | |||
332 | route_irq(desc, irq, newcpu); | ||
333 | } | ||
334 | } | ||
335 | } | ||
336 | #endif | ||
diff --git a/arch/sh/kernel/localtimer.c b/arch/sh/kernel/localtimer.c index 0b04e7d4a9b9..8bfc6dfa8b94 100644 --- a/arch/sh/kernel/localtimer.c +++ b/arch/sh/kernel/localtimer.c | |||
@@ -44,7 +44,7 @@ static void dummy_timer_set_mode(enum clock_event_mode mode, | |||
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | void __cpuinit local_timer_setup(unsigned int cpu) | 47 | void local_timer_setup(unsigned int cpu) |
48 | { | 48 | { |
49 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); | 49 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); |
50 | 50 | ||
@@ -60,3 +60,7 @@ void __cpuinit local_timer_setup(unsigned int cpu) | |||
60 | 60 | ||
61 | clockevents_register_device(clk); | 61 | clockevents_register_device(clk); |
62 | } | 62 | } |
63 | |||
64 | void local_timer_stop(unsigned int cpu) | ||
65 | { | ||
66 | } | ||
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 8870d6ba64bf..14735d5ede52 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
40 | #include <asm/setup.h> | 40 | #include <asm/setup.h> |
41 | #include <asm/clock.h> | 41 | #include <asm/clock.h> |
42 | #include <asm/smp.h> | ||
42 | #include <asm/mmu_context.h> | 43 | #include <asm/mmu_context.h> |
43 | 44 | ||
44 | /* | 45 | /* |
@@ -459,9 +460,7 @@ void __init setup_arch(char **cmdline_p) | |||
459 | if (likely(sh_mv.mv_setup)) | 460 | if (likely(sh_mv.mv_setup)) |
460 | sh_mv.mv_setup(cmdline_p); | 461 | sh_mv.mv_setup(cmdline_p); |
461 | 462 | ||
462 | #ifdef CONFIG_SMP | ||
463 | plat_smp_setup(); | 463 | plat_smp_setup(); |
464 | #endif | ||
465 | } | 464 | } |
466 | 465 | ||
467 | /* processor boot mode configuration */ | 466 | /* processor boot mode configuration */ |
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 002cc612deef..86cd6f94b53b 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * SMP support for the SuperH processors. | 4 | * SMP support for the SuperH processors. |
5 | * | 5 | * |
6 | * Copyright (C) 2002 - 2008 Paul Mundt | 6 | * Copyright (C) 2002 - 2010 Paul Mundt |
7 | * Copyright (C) 2006 - 2007 Akio Idehara | 7 | * Copyright (C) 2006 - 2007 Akio Idehara |
8 | * | 8 | * |
9 | * This file is subject to the terms and conditions of the GNU General Public | 9 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -31,7 +31,20 @@ | |||
31 | int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ | 31 | int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ |
32 | int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ | 32 | int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ |
33 | 33 | ||
34 | static inline void __init smp_store_cpu_info(unsigned int cpu) | 34 | struct plat_smp_ops *mp_ops = NULL; |
35 | |||
36 | /* State of each CPU */ | ||
37 | DEFINE_PER_CPU(int, cpu_state) = { 0 }; | ||
38 | |||
39 | void __cpuinit register_smp_ops(struct plat_smp_ops *ops) | ||
40 | { | ||
41 | if (mp_ops) | ||
42 | printk(KERN_WARNING "Overriding previously set SMP ops\n"); | ||
43 | |||
44 | mp_ops = ops; | ||
45 | } | ||
46 | |||
47 | static inline void __cpuinit smp_store_cpu_info(unsigned int cpu) | ||
35 | { | 48 | { |
36 | struct sh_cpuinfo *c = cpu_data + cpu; | 49 | struct sh_cpuinfo *c = cpu_data + cpu; |
37 | 50 | ||
@@ -46,14 +59,14 @@ void __init smp_prepare_cpus(unsigned int max_cpus) | |||
46 | 59 | ||
47 | init_new_context(current, &init_mm); | 60 | init_new_context(current, &init_mm); |
48 | current_thread_info()->cpu = cpu; | 61 | current_thread_info()->cpu = cpu; |
49 | plat_prepare_cpus(max_cpus); | 62 | mp_ops->prepare_cpus(max_cpus); |
50 | 63 | ||
51 | #ifndef CONFIG_HOTPLUG_CPU | 64 | #ifndef CONFIG_HOTPLUG_CPU |
52 | init_cpu_present(&cpu_possible_map); | 65 | init_cpu_present(&cpu_possible_map); |
53 | #endif | 66 | #endif |
54 | } | 67 | } |
55 | 68 | ||
56 | void __devinit smp_prepare_boot_cpu(void) | 69 | void __init smp_prepare_boot_cpu(void) |
57 | { | 70 | { |
58 | unsigned int cpu = smp_processor_id(); | 71 | unsigned int cpu = smp_processor_id(); |
59 | 72 | ||
@@ -62,37 +75,137 @@ void __devinit smp_prepare_boot_cpu(void) | |||
62 | 75 | ||
63 | set_cpu_online(cpu, true); | 76 | set_cpu_online(cpu, true); |
64 | set_cpu_possible(cpu, true); | 77 | set_cpu_possible(cpu, true); |
78 | |||
79 | per_cpu(cpu_state, cpu) = CPU_ONLINE; | ||
80 | } | ||
81 | |||
82 | #ifdef CONFIG_HOTPLUG_CPU | ||
83 | void native_cpu_die(unsigned int cpu) | ||
84 | { | ||
85 | unsigned int i; | ||
86 | |||
87 | for (i = 0; i < 10; i++) { | ||
88 | smp_rmb(); | ||
89 | if (per_cpu(cpu_state, cpu) == CPU_DEAD) { | ||
90 | if (system_state == SYSTEM_RUNNING) | ||
91 | pr_info("CPU %u is now offline\n", cpu); | ||
92 | |||
93 | return; | ||
94 | } | ||
95 | |||
96 | msleep(100); | ||
97 | } | ||
98 | |||
99 | pr_err("CPU %u didn't die...\n", cpu); | ||
100 | } | ||
101 | |||
102 | int native_cpu_disable(unsigned int cpu) | ||
103 | { | ||
104 | return cpu == 0 ? -EPERM : 0; | ||
105 | } | ||
106 | |||
107 | void play_dead_common(void) | ||
108 | { | ||
109 | idle_task_exit(); | ||
110 | irq_ctx_exit(raw_smp_processor_id()); | ||
111 | mb(); | ||
112 | |||
113 | __get_cpu_var(cpu_state) = CPU_DEAD; | ||
114 | local_irq_disable(); | ||
115 | } | ||
116 | |||
117 | void native_play_dead(void) | ||
118 | { | ||
119 | play_dead_common(); | ||
65 | } | 120 | } |
66 | 121 | ||
122 | int __cpu_disable(void) | ||
123 | { | ||
124 | unsigned int cpu = smp_processor_id(); | ||
125 | struct task_struct *p; | ||
126 | int ret; | ||
127 | |||
128 | ret = mp_ops->cpu_disable(cpu); | ||
129 | if (ret) | ||
130 | return ret; | ||
131 | |||
132 | /* | ||
133 | * Take this CPU offline. Once we clear this, we can't return, | ||
134 | * and we must not schedule until we're ready to give up the cpu. | ||
135 | */ | ||
136 | set_cpu_online(cpu, false); | ||
137 | |||
138 | /* | ||
139 | * OK - migrate IRQs away from this CPU | ||
140 | */ | ||
141 | migrate_irqs(); | ||
142 | |||
143 | /* | ||
144 | * Stop the local timer for this CPU. | ||
145 | */ | ||
146 | local_timer_stop(cpu); | ||
147 | |||
148 | /* | ||
149 | * Flush user cache and TLB mappings, and then remove this CPU | ||
150 | * from the vm mask set of all processes. | ||
151 | */ | ||
152 | flush_cache_all(); | ||
153 | local_flush_tlb_all(); | ||
154 | |||
155 | read_lock(&tasklist_lock); | ||
156 | for_each_process(p) | ||
157 | if (p->mm) | ||
158 | cpumask_clear_cpu(cpu, mm_cpumask(p->mm)); | ||
159 | read_unlock(&tasklist_lock); | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | #else /* ... !CONFIG_HOTPLUG_CPU */ | ||
164 | int native_cpu_disable(void) | ||
165 | { | ||
166 | return -ENOSYS; | ||
167 | } | ||
168 | |||
169 | void native_cpu_die(unsigned int cpu) | ||
170 | { | ||
171 | /* We said "no" in __cpu_disable */ | ||
172 | BUG(); | ||
173 | } | ||
174 | |||
175 | void native_play_dead(void) | ||
176 | { | ||
177 | BUG(); | ||
178 | } | ||
179 | #endif | ||
180 | |||
67 | asmlinkage void __cpuinit start_secondary(void) | 181 | asmlinkage void __cpuinit start_secondary(void) |
68 | { | 182 | { |
69 | unsigned int cpu; | 183 | unsigned int cpu = smp_processor_id(); |
70 | struct mm_struct *mm = &init_mm; | 184 | struct mm_struct *mm = &init_mm; |
71 | 185 | ||
72 | enable_mmu(); | 186 | enable_mmu(); |
73 | atomic_inc(&mm->mm_count); | 187 | atomic_inc(&mm->mm_count); |
74 | atomic_inc(&mm->mm_users); | 188 | atomic_inc(&mm->mm_users); |
75 | current->active_mm = mm; | 189 | current->active_mm = mm; |
76 | BUG_ON(current->mm); | ||
77 | enter_lazy_tlb(mm, current); | 190 | enter_lazy_tlb(mm, current); |
191 | local_flush_tlb_all(); | ||
78 | 192 | ||
79 | per_cpu_trap_init(); | 193 | per_cpu_trap_init(); |
80 | 194 | ||
81 | preempt_disable(); | 195 | preempt_disable(); |
82 | 196 | ||
83 | notify_cpu_starting(smp_processor_id()); | 197 | notify_cpu_starting(cpu); |
84 | 198 | ||
85 | local_irq_enable(); | 199 | local_irq_enable(); |
86 | 200 | ||
87 | cpu = smp_processor_id(); | ||
88 | |||
89 | /* Enable local timers */ | 201 | /* Enable local timers */ |
90 | local_timer_setup(cpu); | 202 | local_timer_setup(cpu); |
91 | calibrate_delay(); | 203 | calibrate_delay(); |
92 | 204 | ||
93 | smp_store_cpu_info(cpu); | 205 | smp_store_cpu_info(cpu); |
94 | 206 | ||
95 | cpu_set(cpu, cpu_online_map); | 207 | set_cpu_online(cpu, true); |
208 | per_cpu(cpu_state, cpu) = CPU_ONLINE; | ||
96 | 209 | ||
97 | cpu_idle(); | 210 | cpu_idle(); |
98 | } | 211 | } |
@@ -111,12 +224,19 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
111 | struct task_struct *tsk; | 224 | struct task_struct *tsk; |
112 | unsigned long timeout; | 225 | unsigned long timeout; |
113 | 226 | ||
114 | tsk = fork_idle(cpu); | 227 | tsk = cpu_data[cpu].idle; |
115 | if (IS_ERR(tsk)) { | 228 | if (!tsk) { |
116 | printk(KERN_ERR "Failed forking idle task for cpu %d\n", cpu); | 229 | tsk = fork_idle(cpu); |
117 | return PTR_ERR(tsk); | 230 | if (IS_ERR(tsk)) { |
231 | pr_err("Failed forking idle task for cpu %d\n", cpu); | ||
232 | return PTR_ERR(tsk); | ||
233 | } | ||
234 | |||
235 | cpu_data[cpu].idle = tsk; | ||
118 | } | 236 | } |
119 | 237 | ||
238 | per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; | ||
239 | |||
120 | /* Fill in data in head.S for secondary cpus */ | 240 | /* Fill in data in head.S for secondary cpus */ |
121 | stack_start.sp = tsk->thread.sp; | 241 | stack_start.sp = tsk->thread.sp; |
122 | stack_start.thread_info = tsk->stack; | 242 | stack_start.thread_info = tsk->stack; |
@@ -127,7 +247,7 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
127 | (unsigned long)&stack_start + sizeof(stack_start)); | 247 | (unsigned long)&stack_start + sizeof(stack_start)); |
128 | wmb(); | 248 | wmb(); |
129 | 249 | ||
130 | plat_start_cpu(cpu, (unsigned long)_stext); | 250 | mp_ops->start_cpu(cpu, (unsigned long)_stext); |
131 | 251 | ||
132 | timeout = jiffies + HZ; | 252 | timeout = jiffies + HZ; |
133 | while (time_before(jiffies, timeout)) { | 253 | while (time_before(jiffies, timeout)) { |
@@ -135,6 +255,7 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
135 | break; | 255 | break; |
136 | 256 | ||
137 | udelay(10); | 257 | udelay(10); |
258 | barrier(); | ||
138 | } | 259 | } |
139 | 260 | ||
140 | if (cpu_online(cpu)) | 261 | if (cpu_online(cpu)) |
@@ -159,7 +280,7 @@ void __init smp_cpus_done(unsigned int max_cpus) | |||
159 | 280 | ||
160 | void smp_send_reschedule(int cpu) | 281 | void smp_send_reschedule(int cpu) |
161 | { | 282 | { |
162 | plat_send_ipi(cpu, SMP_MSG_RESCHEDULE); | 283 | mp_ops->send_ipi(cpu, SMP_MSG_RESCHEDULE); |
163 | } | 284 | } |
164 | 285 | ||
165 | void smp_send_stop(void) | 286 | void smp_send_stop(void) |
@@ -172,12 +293,12 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask) | |||
172 | int cpu; | 293 | int cpu; |
173 | 294 | ||
174 | for_each_cpu(cpu, mask) | 295 | for_each_cpu(cpu, mask) |
175 | plat_send_ipi(cpu, SMP_MSG_FUNCTION); | 296 | mp_ops->send_ipi(cpu, SMP_MSG_FUNCTION); |
176 | } | 297 | } |
177 | 298 | ||
178 | void arch_send_call_function_single_ipi(int cpu) | 299 | void arch_send_call_function_single_ipi(int cpu) |
179 | { | 300 | { |
180 | plat_send_ipi(cpu, SMP_MSG_FUNCTION_SINGLE); | 301 | mp_ops->send_ipi(cpu, SMP_MSG_FUNCTION_SINGLE); |
181 | } | 302 | } |
182 | 303 | ||
183 | void smp_timer_broadcast(const struct cpumask *mask) | 304 | void smp_timer_broadcast(const struct cpumask *mask) |
@@ -185,7 +306,7 @@ void smp_timer_broadcast(const struct cpumask *mask) | |||
185 | int cpu; | 306 | int cpu; |
186 | 307 | ||
187 | for_each_cpu(cpu, mask) | 308 | for_each_cpu(cpu, mask) |
188 | plat_send_ipi(cpu, SMP_MSG_TIMER); | 309 | mp_ops->send_ipi(cpu, SMP_MSG_TIMER); |
189 | } | 310 | } |
190 | 311 | ||
191 | static void ipi_timer(void) | 312 | static void ipi_timer(void) |
@@ -249,7 +370,6 @@ static void flush_tlb_mm_ipi(void *mm) | |||
249 | * behalf of debugees, kswapd stealing pages from another process etc). | 370 | * behalf of debugees, kswapd stealing pages from another process etc). |
250 | * Kanoj 07/00. | 371 | * Kanoj 07/00. |
251 | */ | 372 | */ |
252 | |||
253 | void flush_tlb_mm(struct mm_struct *mm) | 373 | void flush_tlb_mm(struct mm_struct *mm) |
254 | { | 374 | { |
255 | preempt_disable(); | 375 | preempt_disable(); |
diff --git a/arch/sh/kernel/topology.c b/arch/sh/kernel/topology.c index 9b0b633b6c92..948fdb656933 100644 --- a/arch/sh/kernel/topology.c +++ b/arch/sh/kernel/topology.c | |||
@@ -52,7 +52,11 @@ static int __init topology_init(void) | |||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | for_each_present_cpu(i) { | 54 | for_each_present_cpu(i) { |
55 | ret = register_cpu(&per_cpu(cpu_devices, i), i); | 55 | struct cpu *c = &per_cpu(cpu_devices, i); |
56 | |||
57 | c->hotpluggable = 1; | ||
58 | |||
59 | ret = register_cpu(c, i); | ||
56 | if (unlikely(ret)) | 60 | if (unlikely(ret)) |
57 | printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n", | 61 | printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n", |
58 | __func__, i, ret); | 62 | __func__, i, ret); |