diff options
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r-- | arch/sparc/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/entry.S | 33 | ||||
-rw-r--r-- | arch/sparc/kernel/head_32.S | 22 | ||||
-rw-r--r-- | arch/sparc/kernel/ioport.c | 5 | ||||
-rw-r--r-- | arch/sparc/kernel/leon_kernel.c | 84 | ||||
-rw-r--r-- | arch/sparc/kernel/leon_smp.c | 468 | ||||
-rw-r--r-- | arch/sparc/kernel/smp_32.c | 10 | ||||
-rw-r--r-- | arch/sparc/kernel/trampoline_32.S | 69 |
8 files changed, 691 insertions, 2 deletions
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 5b47fab9966e..6b3b076173f4 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile | |||
@@ -72,7 +72,7 @@ obj-y += dma.o | |||
72 | obj-$(CONFIG_SPARC32_PCI) += pcic.o | 72 | obj-$(CONFIG_SPARC32_PCI) += pcic.o |
73 | 73 | ||
74 | obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o | 74 | obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o |
75 | obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o | 75 | obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o |
76 | obj-$(CONFIG_SPARC64_SMP) += hvtramp.o | 76 | obj-$(CONFIG_SPARC64_SMP) += hvtramp.o |
77 | 77 | ||
78 | obj-y += auxio_$(BITS).o | 78 | obj-y += auxio_$(BITS).o |
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index f41ecc5ac0b4..ec9c7bc67d21 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S | |||
@@ -400,6 +400,39 @@ linux_trap_ipi15_sun4d: | |||
400 | /* FIXME */ | 400 | /* FIXME */ |
401 | 1: b,a 1b | 401 | 1: b,a 1b |
402 | 402 | ||
403 | #ifdef CONFIG_SPARC_LEON | ||
404 | |||
405 | .globl smpleon_ticker | ||
406 | /* SMP per-cpu ticker interrupts are handled specially. */ | ||
407 | smpleon_ticker: | ||
408 | SAVE_ALL | ||
409 | or %l0, PSR_PIL, %g2 | ||
410 | wr %g2, 0x0, %psr | ||
411 | WRITE_PAUSE | ||
412 | wr %g2, PSR_ET, %psr | ||
413 | WRITE_PAUSE | ||
414 | call leon_percpu_timer_interrupt | ||
415 | add %sp, STACKFRAME_SZ, %o0 | ||
416 | wr %l0, PSR_ET, %psr | ||
417 | WRITE_PAUSE | ||
418 | RESTORE_ALL | ||
419 | |||
420 | .align 4 | ||
421 | .globl linux_trap_ipi15_leon | ||
422 | linux_trap_ipi15_leon: | ||
423 | SAVE_ALL | ||
424 | or %l0, PSR_PIL, %l4 | ||
425 | wr %l4, 0x0, %psr | ||
426 | WRITE_PAUSE | ||
427 | wr %l4, PSR_ET, %psr | ||
428 | WRITE_PAUSE | ||
429 | call leon_cross_call_irq | ||
430 | nop | ||
431 | b ret_trap_lockless_ipi | ||
432 | clr %l6 | ||
433 | |||
434 | #endif /* CONFIG_SPARC_LEON */ | ||
435 | |||
403 | #endif /* CONFIG_SMP */ | 436 | #endif /* CONFIG_SMP */ |
404 | 437 | ||
405 | /* This routine handles illegal instructions and privileged | 438 | /* This routine handles illegal instructions and privileged |
diff --git a/arch/sparc/kernel/head_32.S b/arch/sparc/kernel/head_32.S index 439d82a95ac9..21bb2590d4ae 100644 --- a/arch/sparc/kernel/head_32.S +++ b/arch/sparc/kernel/head_32.S | |||
@@ -811,9 +811,31 @@ found_version: | |||
811 | got_prop: | 811 | got_prop: |
812 | #ifdef CONFIG_SPARC_LEON | 812 | #ifdef CONFIG_SPARC_LEON |
813 | /* no cpu-type check is needed, it is a SPARC-LEON */ | 813 | /* no cpu-type check is needed, it is a SPARC-LEON */ |
814 | #ifdef CONFIG_SMP | ||
815 | ba leon_smp_init | ||
816 | nop | ||
817 | |||
818 | .global leon_smp_init | ||
819 | leon_smp_init: | ||
820 | sethi %hi(boot_cpu_id), %g1 ! master always 0 | ||
821 | stb %g0, [%g1 + %lo(boot_cpu_id)] | ||
822 | sethi %hi(boot_cpu_id4), %g1 ! master always 0 | ||
823 | stb %g0, [%g1 + %lo(boot_cpu_id4)] | ||
824 | |||
825 | rd %asr17,%g1 | ||
826 | srl %g1,28,%g1 | ||
827 | |||
828 | cmp %g0,%g1 | ||
829 | beq sun4c_continue_boot !continue with master | ||
830 | nop | ||
831 | |||
832 | ba leon_smp_cpu_startup | ||
833 | nop | ||
834 | #else | ||
814 | ba sun4c_continue_boot | 835 | ba sun4c_continue_boot |
815 | nop | 836 | nop |
816 | #endif | 837 | #endif |
838 | #endif | ||
817 | set cputypval, %o2 | 839 | set cputypval, %o2 |
818 | ldub [%o2 + 0x4], %l1 | 840 | ldub [%o2 + 0x4], %l1 |
819 | 841 | ||
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 9f61fd8cbb7b..3c8c44f6a41c 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -48,8 +48,13 @@ | |||
48 | #include <asm/dma.h> | 48 | #include <asm/dma.h> |
49 | #include <asm/iommu.h> | 49 | #include <asm/iommu.h> |
50 | #include <asm/io-unit.h> | 50 | #include <asm/io-unit.h> |
51 | #include <asm/leon.h> | ||
51 | 52 | ||
53 | #ifdef CONFIG_SPARC_LEON | ||
54 | #define mmu_inval_dma_area(p, l) leon_flush_dcache_all() | ||
55 | #else | ||
52 | #define mmu_inval_dma_area(p, l) /* Anton pulled it out for 2.4.0-xx */ | 56 | #define mmu_inval_dma_area(p, l) /* Anton pulled it out for 2.4.0-xx */ |
57 | #endif | ||
53 | 58 | ||
54 | static struct resource *_sparc_find_resource(struct resource *r, | 59 | static struct resource *_sparc_find_resource(struct resource *r, |
55 | unsigned long); | 60 | unsigned long); |
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c index 54d8a5bd4824..87f1760c0aa2 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c | |||
@@ -12,11 +12,14 @@ | |||
12 | #include <linux/of_platform.h> | 12 | #include <linux/of_platform.h> |
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/of_device.h> | 14 | #include <linux/of_device.h> |
15 | |||
15 | #include <asm/oplib.h> | 16 | #include <asm/oplib.h> |
16 | #include <asm/timer.h> | 17 | #include <asm/timer.h> |
17 | #include <asm/prom.h> | 18 | #include <asm/prom.h> |
18 | #include <asm/leon.h> | 19 | #include <asm/leon.h> |
19 | #include <asm/leon_amba.h> | 20 | #include <asm/leon_amba.h> |
21 | #include <asm/traps.h> | ||
22 | #include <asm/cacheflush.h> | ||
20 | 23 | ||
21 | #include "prom.h" | 24 | #include "prom.h" |
22 | #include "irq.h" | 25 | #include "irq.h" |
@@ -115,6 +118,21 @@ void __init leon_init_timers(irq_handler_t counter_fn) | |||
115 | (((1000000 / 100) - 1))); | 118 | (((1000000 / 100) - 1))); |
116 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0); | 119 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0); |
117 | 120 | ||
121 | #ifdef CONFIG_SMP | ||
122 | leon_percpu_timer_dev[0].start = (int)leon3_gptimer_regs; | ||
123 | leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1; | ||
124 | |||
125 | if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) & | ||
126 | (1<<LEON3_GPTIMER_SEPIRQ))) { | ||
127 | prom_printf("irq timer not configured with seperate irqs \n"); | ||
128 | BUG(); | ||
129 | } | ||
130 | |||
131 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0); | ||
132 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/100) - 1))); | ||
133 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0); | ||
134 | # endif | ||
135 | |||
118 | } else { | 136 | } else { |
119 | printk(KERN_ERR "No Timer/irqctrl found\n"); | 137 | printk(KERN_ERR "No Timer/irqctrl found\n"); |
120 | BUG(); | 138 | BUG(); |
@@ -130,11 +148,41 @@ void __init leon_init_timers(irq_handler_t counter_fn) | |||
130 | prom_halt(); | 148 | prom_halt(); |
131 | } | 149 | } |
132 | 150 | ||
151 | # ifdef CONFIG_SMP | ||
152 | { | ||
153 | unsigned long flags; | ||
154 | struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (leon_percpu_timer_dev[0].irq - 1)]; | ||
155 | |||
156 | /* For SMP we use the level 14 ticker, however the bootup code | ||
157 | * has copied the firmwares level 14 vector into boot cpu's | ||
158 | * trap table, we must fix this now or we get squashed. | ||
159 | */ | ||
160 | local_irq_save(flags); | ||
161 | |||
162 | patchme_maybe_smp_msg[0] = 0x01000000; /* NOP out the branch */ | ||
163 | |||
164 | /* Adjust so that we jump directly to smpleon_ticker */ | ||
165 | trap_table->inst_three += smpleon_ticker - real_irq_entry; | ||
166 | |||
167 | local_flush_cache_all(); | ||
168 | local_irq_restore(flags); | ||
169 | } | ||
170 | # endif | ||
171 | |||
133 | if (leon3_gptimer_regs) { | 172 | if (leon3_gptimer_regs) { |
134 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, | 173 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, |
135 | LEON3_GPTIMER_EN | | 174 | LEON3_GPTIMER_EN | |
136 | LEON3_GPTIMER_RL | | 175 | LEON3_GPTIMER_RL | |
137 | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN); | 176 | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN); |
177 | |||
178 | #ifdef CONFIG_SMP | ||
179 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, | ||
180 | LEON3_GPTIMER_EN | | ||
181 | LEON3_GPTIMER_RL | | ||
182 | LEON3_GPTIMER_LD | | ||
183 | LEON3_GPTIMER_IRQEN); | ||
184 | #endif | ||
185 | |||
138 | } | 186 | } |
139 | } | 187 | } |
140 | 188 | ||
@@ -175,6 +223,42 @@ void __init leon_node_init(struct device_node *dp, struct device_node ***nextp) | |||
175 | } | 223 | } |
176 | } | 224 | } |
177 | 225 | ||
226 | #ifdef CONFIG_SMP | ||
227 | |||
228 | void leon_set_cpu_int(int cpu, int level) | ||
229 | { | ||
230 | unsigned long mask; | ||
231 | mask = get_irqmask(level); | ||
232 | LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask); | ||
233 | } | ||
234 | |||
235 | static void leon_clear_ipi(int cpu, int level) | ||
236 | { | ||
237 | unsigned long mask; | ||
238 | mask = get_irqmask(level); | ||
239 | LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask<<16); | ||
240 | } | ||
241 | |||
242 | static void leon_set_udt(int cpu) | ||
243 | { | ||
244 | } | ||
245 | |||
246 | void leon_clear_profile_irq(int cpu) | ||
247 | { | ||
248 | } | ||
249 | |||
250 | void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu) | ||
251 | { | ||
252 | unsigned long mask, flags, *addr; | ||
253 | mask = get_irqmask(irq_nr); | ||
254 | local_irq_save(flags); | ||
255 | addr = (unsigned long *)&(leon3_irqctrl_regs->mask[cpu]); | ||
256 | LEON3_BYPASS_STORE_PA(addr, (LEON3_BYPASS_LOAD_PA(addr) | (mask))); | ||
257 | local_irq_restore(flags); | ||
258 | } | ||
259 | |||
260 | #endif | ||
261 | |||
178 | void __init leon_init_IRQ(void) | 262 | void __init leon_init_IRQ(void) |
179 | { | 263 | { |
180 | sparc_init_timers = leon_init_timers; | 264 | sparc_init_timers = leon_init_timers; |
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c new file mode 100644 index 000000000000..05c0dadd6371 --- /dev/null +++ b/arch/sparc/kernel/leon_smp.c | |||
@@ -0,0 +1,468 @@ | |||
1 | /* leon_smp.c: Sparc-Leon SMP support. | ||
2 | * | ||
3 | * based on sun4m_smp.c | ||
4 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
5 | * Copyright (C) 2009 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB | ||
6 | * Copyright (C) 2009 Konrad Eisele (konrad@gaisler.com) Aeroflex Gaisler AB | ||
7 | */ | ||
8 | |||
9 | #include <asm/head.h> | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/sched.h> | ||
13 | #include <linux/threads.h> | ||
14 | #include <linux/smp.h> | ||
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/kernel_stat.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <linux/mm.h> | ||
21 | #include <linux/swap.h> | ||
22 | #include <linux/profile.h> | ||
23 | #include <linux/pm.h> | ||
24 | #include <linux/delay.h> | ||
25 | |||
26 | #include <asm/cacheflush.h> | ||
27 | #include <asm/tlbflush.h> | ||
28 | |||
29 | #include <asm/ptrace.h> | ||
30 | #include <asm/atomic.h> | ||
31 | #include <asm/irq_regs.h> | ||
32 | |||
33 | #include <asm/delay.h> | ||
34 | #include <asm/irq.h> | ||
35 | #include <asm/page.h> | ||
36 | #include <asm/pgalloc.h> | ||
37 | #include <asm/pgtable.h> | ||
38 | #include <asm/oplib.h> | ||
39 | #include <asm/cpudata.h> | ||
40 | #include <asm/asi.h> | ||
41 | #include <asm/leon.h> | ||
42 | #include <asm/leon_amba.h> | ||
43 | |||
44 | #ifdef CONFIG_SPARC_LEON | ||
45 | |||
46 | #include "irq.h" | ||
47 | |||
48 | extern ctxd_t *srmmu_ctx_table_phys; | ||
49 | static int smp_processors_ready; | ||
50 | extern volatile unsigned long cpu_callin_map[NR_CPUS]; | ||
51 | extern unsigned char boot_cpu_id; | ||
52 | extern cpumask_t smp_commenced_mask; | ||
53 | void __init leon_configure_cache_smp(void); | ||
54 | |||
55 | static inline unsigned long do_swap(volatile unsigned long *ptr, | ||
56 | unsigned long val) | ||
57 | { | ||
58 | __asm__ __volatile__("swapa [%1] %2, %0\n\t" : "=&r"(val) | ||
59 | : "r"(ptr), "i"(ASI_LEON_DCACHE_MISS) | ||
60 | : "memory"); | ||
61 | return val; | ||
62 | } | ||
63 | |||
64 | static void smp_setup_percpu_timer(void); | ||
65 | |||
66 | void __cpuinit leon_callin(void) | ||
67 | { | ||
68 | int cpuid = hard_smpleon_processor_id(); | ||
69 | |||
70 | local_flush_cache_all(); | ||
71 | local_flush_tlb_all(); | ||
72 | leon_configure_cache_smp(); | ||
73 | |||
74 | /* Get our local ticker going. */ | ||
75 | smp_setup_percpu_timer(); | ||
76 | |||
77 | calibrate_delay(); | ||
78 | smp_store_cpu_info(cpuid); | ||
79 | |||
80 | local_flush_cache_all(); | ||
81 | local_flush_tlb_all(); | ||
82 | |||
83 | /* | ||
84 | * Unblock the master CPU _only_ when the scheduler state | ||
85 | * of all secondary CPUs will be up-to-date, so after | ||
86 | * the SMP initialization the master will be just allowed | ||
87 | * to call the scheduler code. | ||
88 | * Allow master to continue. | ||
89 | */ | ||
90 | do_swap(&cpu_callin_map[cpuid], 1); | ||
91 | |||
92 | local_flush_cache_all(); | ||
93 | local_flush_tlb_all(); | ||
94 | |||
95 | cpu_probe(); | ||
96 | |||
97 | /* Fix idle thread fields. */ | ||
98 | __asm__ __volatile__("ld [%0], %%g6\n\t" : : "r"(¤t_set[cpuid]) | ||
99 | : "memory" /* paranoid */); | ||
100 | |||
101 | /* Attach to the address space of init_task. */ | ||
102 | atomic_inc(&init_mm.mm_count); | ||
103 | current->active_mm = &init_mm; | ||
104 | |||
105 | while (!cpu_isset(cpuid, smp_commenced_mask)) | ||
106 | mb(); | ||
107 | |||
108 | local_irq_enable(); | ||
109 | cpu_set(cpuid, cpu_online_map); | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Cycle through the processors asking the PROM to start each one. | ||
114 | */ | ||
115 | |||
116 | extern struct linux_prom_registers smp_penguin_ctable; | ||
117 | |||
118 | void __init leon_configure_cache_smp(void) | ||
119 | { | ||
120 | unsigned long cfg = sparc_leon3_get_dcachecfg(); | ||
121 | int me = smp_processor_id(); | ||
122 | |||
123 | if (ASI_LEON3_SYSCTRL_CFG_SSIZE(cfg) > 4) { | ||
124 | printk(KERN_INFO "Note: SMP with snooping only works on 4k cache, found %dk(0x%x) on cpu %d, disabling caches\n", | ||
125 | (unsigned int)ASI_LEON3_SYSCTRL_CFG_SSIZE(cfg), | ||
126 | (unsigned int)cfg, (unsigned int)me); | ||
127 | sparc_leon3_disable_cache(); | ||
128 | } else { | ||
129 | if (cfg & ASI_LEON3_SYSCTRL_CFG_SNOOPING) { | ||
130 | sparc_leon3_enable_snooping(); | ||
131 | } else { | ||
132 | printk(KERN_INFO "Note: You have to enable snooping in the vhdl model cpu %d, disabling caches\n", | ||
133 | me); | ||
134 | sparc_leon3_disable_cache(); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | local_flush_cache_all(); | ||
139 | local_flush_tlb_all(); | ||
140 | } | ||
141 | |||
142 | void leon_smp_setbroadcast(unsigned int mask) | ||
143 | { | ||
144 | int broadcast = | ||
145 | ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >> | ||
146 | LEON3_IRQMPSTATUS_BROADCAST) & 1); | ||
147 | if (!broadcast) { | ||
148 | prom_printf("######## !!!! The irqmp-ctrl must have broadcast enabled, smp wont work !!!!! ####### nr cpus: %d\n", | ||
149 | leon_smp_nrcpus()); | ||
150 | if (leon_smp_nrcpus() > 1) { | ||
151 | BUG(); | ||
152 | } else { | ||
153 | prom_printf("continue anyway\n"); | ||
154 | return; | ||
155 | } | ||
156 | } | ||
157 | LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpbroadcast), mask); | ||
158 | } | ||
159 | |||
160 | unsigned int leon_smp_getbroadcast(void) | ||
161 | { | ||
162 | unsigned int mask; | ||
163 | mask = LEON_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpbroadcast)); | ||
164 | return mask; | ||
165 | } | ||
166 | |||
167 | int leon_smp_nrcpus(void) | ||
168 | { | ||
169 | int nrcpu = | ||
170 | ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >> | ||
171 | LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1; | ||
172 | return nrcpu; | ||
173 | } | ||
174 | |||
175 | void __init leon_boot_cpus(void) | ||
176 | { | ||
177 | int nrcpu = leon_smp_nrcpus(); | ||
178 | int me = smp_processor_id(); | ||
179 | |||
180 | printk(KERN_INFO "%d:(%d:%d) cpus mpirq at 0x%x \n", (unsigned int)me, | ||
181 | (unsigned int)nrcpu, (unsigned int)NR_CPUS, | ||
182 | (unsigned int)&(leon3_irqctrl_regs->mpstatus)); | ||
183 | |||
184 | leon_enable_irq_cpu(LEON3_IRQ_CROSS_CALL, me); | ||
185 | leon_enable_irq_cpu(LEON3_IRQ_TICKER, me); | ||
186 | leon_enable_irq_cpu(LEON3_IRQ_RESCHEDULE, me); | ||
187 | |||
188 | leon_smp_setbroadcast(1 << LEON3_IRQ_TICKER); | ||
189 | |||
190 | leon_configure_cache_smp(); | ||
191 | smp_setup_percpu_timer(); | ||
192 | local_flush_cache_all(); | ||
193 | |||
194 | } | ||
195 | |||
196 | int __cpuinit leon_boot_one_cpu(int i) | ||
197 | { | ||
198 | |||
199 | struct task_struct *p; | ||
200 | int timeout; | ||
201 | |||
202 | /* Cook up an idler for this guy. */ | ||
203 | p = fork_idle(i); | ||
204 | |||
205 | current_set[i] = task_thread_info(p); | ||
206 | |||
207 | /* See trampoline.S:leon_smp_cpu_startup for details... | ||
208 | * Initialize the contexts table | ||
209 | * Since the call to prom_startcpu() trashes the structure, | ||
210 | * we need to re-initialize it for each cpu | ||
211 | */ | ||
212 | smp_penguin_ctable.which_io = 0; | ||
213 | smp_penguin_ctable.phys_addr = (unsigned int)srmmu_ctx_table_phys; | ||
214 | smp_penguin_ctable.reg_size = 0; | ||
215 | |||
216 | /* whirrr, whirrr, whirrrrrrrrr... */ | ||
217 | printk(KERN_INFO "Starting CPU %d : (irqmp: 0x%x)\n", (unsigned int)i, | ||
218 | (unsigned int)&leon3_irqctrl_regs->mpstatus); | ||
219 | local_flush_cache_all(); | ||
220 | |||
221 | LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpstatus), 1 << i); | ||
222 | |||
223 | /* wheee... it's going... */ | ||
224 | for (timeout = 0; timeout < 10000; timeout++) { | ||
225 | if (cpu_callin_map[i]) | ||
226 | break; | ||
227 | udelay(200); | ||
228 | } | ||
229 | printk(KERN_INFO "Started CPU %d \n", (unsigned int)i); | ||
230 | |||
231 | if (!(cpu_callin_map[i])) { | ||
232 | printk(KERN_ERR "Processor %d is stuck.\n", i); | ||
233 | return -ENODEV; | ||
234 | } else { | ||
235 | leon_enable_irq_cpu(LEON3_IRQ_CROSS_CALL, i); | ||
236 | leon_enable_irq_cpu(LEON3_IRQ_TICKER, i); | ||
237 | leon_enable_irq_cpu(LEON3_IRQ_RESCHEDULE, i); | ||
238 | } | ||
239 | |||
240 | local_flush_cache_all(); | ||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | void __init leon_smp_done(void) | ||
245 | { | ||
246 | |||
247 | int i, first; | ||
248 | int *prev; | ||
249 | |||
250 | /* setup cpu list for irq rotation */ | ||
251 | first = 0; | ||
252 | prev = &first; | ||
253 | for (i = 0; i < NR_CPUS; i++) { | ||
254 | if (cpu_online(i)) { | ||
255 | *prev = i; | ||
256 | prev = &cpu_data(i).next; | ||
257 | } | ||
258 | } | ||
259 | *prev = first; | ||
260 | local_flush_cache_all(); | ||
261 | |||
262 | /* Free unneeded trap tables */ | ||
263 | if (!cpu_isset(1, cpu_present_map)) { | ||
264 | ClearPageReserved(virt_to_page(trapbase_cpu1)); | ||
265 | init_page_count(virt_to_page(trapbase_cpu1)); | ||
266 | free_page((unsigned long)trapbase_cpu1); | ||
267 | totalram_pages++; | ||
268 | num_physpages++; | ||
269 | } | ||
270 | if (!cpu_isset(2, cpu_present_map)) { | ||
271 | ClearPageReserved(virt_to_page(trapbase_cpu2)); | ||
272 | init_page_count(virt_to_page(trapbase_cpu2)); | ||
273 | free_page((unsigned long)trapbase_cpu2); | ||
274 | totalram_pages++; | ||
275 | num_physpages++; | ||
276 | } | ||
277 | if (!cpu_isset(3, cpu_present_map)) { | ||
278 | ClearPageReserved(virt_to_page(trapbase_cpu3)); | ||
279 | init_page_count(virt_to_page(trapbase_cpu3)); | ||
280 | free_page((unsigned long)trapbase_cpu3); | ||
281 | totalram_pages++; | ||
282 | num_physpages++; | ||
283 | } | ||
284 | /* Ok, they are spinning and ready to go. */ | ||
285 | smp_processors_ready = 1; | ||
286 | |||
287 | } | ||
288 | |||
289 | void leon_irq_rotate(int cpu) | ||
290 | { | ||
291 | } | ||
292 | |||
293 | static struct smp_funcall { | ||
294 | smpfunc_t func; | ||
295 | unsigned long arg1; | ||
296 | unsigned long arg2; | ||
297 | unsigned long arg3; | ||
298 | unsigned long arg4; | ||
299 | unsigned long arg5; | ||
300 | unsigned long processors_in[NR_CPUS]; /* Set when ipi entered. */ | ||
301 | unsigned long processors_out[NR_CPUS]; /* Set when ipi exited. */ | ||
302 | } ccall_info; | ||
303 | |||
304 | static DEFINE_SPINLOCK(cross_call_lock); | ||
305 | |||
306 | /* Cross calls must be serialized, at least currently. */ | ||
307 | static void leon_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1, | ||
308 | unsigned long arg2, unsigned long arg3, | ||
309 | unsigned long arg4) | ||
310 | { | ||
311 | if (smp_processors_ready) { | ||
312 | register int high = NR_CPUS - 1; | ||
313 | unsigned long flags; | ||
314 | |||
315 | spin_lock_irqsave(&cross_call_lock, flags); | ||
316 | |||
317 | { | ||
318 | /* If you make changes here, make sure gcc generates proper code... */ | ||
319 | register smpfunc_t f asm("i0") = func; | ||
320 | register unsigned long a1 asm("i1") = arg1; | ||
321 | register unsigned long a2 asm("i2") = arg2; | ||
322 | register unsigned long a3 asm("i3") = arg3; | ||
323 | register unsigned long a4 asm("i4") = arg4; | ||
324 | register unsigned long a5 asm("i5") = 0; | ||
325 | |||
326 | __asm__ __volatile__("std %0, [%6]\n\t" | ||
327 | "std %2, [%6 + 8]\n\t" | ||
328 | "std %4, [%6 + 16]\n\t" : : | ||
329 | "r"(f), "r"(a1), "r"(a2), "r"(a3), | ||
330 | "r"(a4), "r"(a5), | ||
331 | "r"(&ccall_info.func)); | ||
332 | } | ||
333 | |||
334 | /* Init receive/complete mapping, plus fire the IPI's off. */ | ||
335 | { | ||
336 | register int i; | ||
337 | |||
338 | cpu_clear(smp_processor_id(), mask); | ||
339 | cpus_and(mask, cpu_online_map, mask); | ||
340 | for (i = 0; i <= high; i++) { | ||
341 | if (cpu_isset(i, mask)) { | ||
342 | ccall_info.processors_in[i] = 0; | ||
343 | ccall_info.processors_out[i] = 0; | ||
344 | set_cpu_int(i, LEON3_IRQ_CROSS_CALL); | ||
345 | |||
346 | } | ||
347 | } | ||
348 | } | ||
349 | |||
350 | { | ||
351 | register int i; | ||
352 | |||
353 | i = 0; | ||
354 | do { | ||
355 | if (!cpu_isset(i, mask)) | ||
356 | continue; | ||
357 | |||
358 | while (!ccall_info.processors_in[i]) | ||
359 | barrier(); | ||
360 | } while (++i <= high); | ||
361 | |||
362 | i = 0; | ||
363 | do { | ||
364 | if (!cpu_isset(i, mask)) | ||
365 | continue; | ||
366 | |||
367 | while (!ccall_info.processors_out[i]) | ||
368 | barrier(); | ||
369 | } while (++i <= high); | ||
370 | } | ||
371 | |||
372 | spin_unlock_irqrestore(&cross_call_lock, flags); | ||
373 | } | ||
374 | } | ||
375 | |||
376 | /* Running cross calls. */ | ||
377 | void leon_cross_call_irq(void) | ||
378 | { | ||
379 | int i = smp_processor_id(); | ||
380 | |||
381 | ccall_info.processors_in[i] = 1; | ||
382 | ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3, | ||
383 | ccall_info.arg4, ccall_info.arg5); | ||
384 | ccall_info.processors_out[i] = 1; | ||
385 | } | ||
386 | |||
387 | void leon_percpu_timer_interrupt(struct pt_regs *regs) | ||
388 | { | ||
389 | struct pt_regs *old_regs; | ||
390 | int cpu = smp_processor_id(); | ||
391 | |||
392 | old_regs = set_irq_regs(regs); | ||
393 | |||
394 | leon_clear_profile_irq(cpu); | ||
395 | |||
396 | profile_tick(CPU_PROFILING); | ||
397 | |||
398 | if (!--prof_counter(cpu)) { | ||
399 | int user = user_mode(regs); | ||
400 | |||
401 | irq_enter(); | ||
402 | update_process_times(user); | ||
403 | irq_exit(); | ||
404 | |||
405 | prof_counter(cpu) = prof_multiplier(cpu); | ||
406 | } | ||
407 | set_irq_regs(old_regs); | ||
408 | } | ||
409 | |||
410 | static void __init smp_setup_percpu_timer(void) | ||
411 | { | ||
412 | int cpu = smp_processor_id(); | ||
413 | |||
414 | prof_counter(cpu) = prof_multiplier(cpu) = 1; | ||
415 | } | ||
416 | |||
417 | void __init leon_blackbox_id(unsigned *addr) | ||
418 | { | ||
419 | int rd = *addr & 0x3e000000; | ||
420 | int rs1 = rd >> 11; | ||
421 | |||
422 | /* patch places where ___b_hard_smp_processor_id appears */ | ||
423 | addr[0] = 0x81444000 | rd; /* rd %asr17, reg */ | ||
424 | addr[1] = 0x8130201c | rd | rs1; /* srl reg, 0x1c, reg */ | ||
425 | addr[2] = 0x01000000; /* nop */ | ||
426 | } | ||
427 | |||
428 | void __init leon_blackbox_current(unsigned *addr) | ||
429 | { | ||
430 | int rd = *addr & 0x3e000000; | ||
431 | int rs1 = rd >> 11; | ||
432 | |||
433 | /* patch LOAD_CURRENT macro where ___b_load_current appears */ | ||
434 | addr[0] = 0x81444000 | rd; /* rd %asr17, reg */ | ||
435 | addr[2] = 0x8130201c | rd | rs1; /* srl reg, 0x1c, reg */ | ||
436 | addr[4] = 0x81282002 | rd | rs1; /* sll reg, 0x2, reg */ | ||
437 | |||
438 | } | ||
439 | |||
440 | /* | ||
441 | * CPU idle callback function | ||
442 | * See .../arch/sparc/kernel/process.c | ||
443 | */ | ||
444 | void pmc_leon_idle(void) | ||
445 | { | ||
446 | __asm__ volatile ("mov %g0, %asr19"); | ||
447 | } | ||
448 | |||
449 | void __init leon_init_smp(void) | ||
450 | { | ||
451 | /* Patch ipi15 trap table */ | ||
452 | t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_leon - linux_trap_ipi15_sun4m); | ||
453 | |||
454 | BTFIXUPSET_BLACKBOX(hard_smp_processor_id, leon_blackbox_id); | ||
455 | BTFIXUPSET_BLACKBOX(load_current, leon_blackbox_current); | ||
456 | BTFIXUPSET_CALL(smp_cross_call, leon_cross_call, BTFIXUPCALL_NORM); | ||
457 | BTFIXUPSET_CALL(__hard_smp_processor_id, __leon_processor_id, | ||
458 | BTFIXUPCALL_NORM); | ||
459 | |||
460 | #ifndef PMC_NO_IDLE | ||
461 | /* Assign power management IDLE handler */ | ||
462 | pm_idle = pmc_leon_idle; | ||
463 | printk(KERN_INFO "leon: power management initialized\n"); | ||
464 | #endif | ||
465 | |||
466 | } | ||
467 | |||
468 | #endif /* CONFIG_SPARC_LEON */ | ||
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index 132d81fb2616..91c10fb70858 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <asm/cacheflush.h> | 32 | #include <asm/cacheflush.h> |
33 | #include <asm/tlbflush.h> | 33 | #include <asm/tlbflush.h> |
34 | #include <asm/cpudata.h> | 34 | #include <asm/cpudata.h> |
35 | #include <asm/leon.h> | ||
35 | 36 | ||
36 | #include "irq.h" | 37 | #include "irq.h" |
37 | 38 | ||
@@ -96,6 +97,9 @@ void __init smp_cpus_done(unsigned int max_cpus) | |||
96 | case sun4d: | 97 | case sun4d: |
97 | smp4d_smp_done(); | 98 | smp4d_smp_done(); |
98 | break; | 99 | break; |
100 | case sparc_leon: | ||
101 | leon_smp_done(); | ||
102 | break; | ||
99 | case sun4e: | 103 | case sun4e: |
100 | printk("SUN4E\n"); | 104 | printk("SUN4E\n"); |
101 | BUG(); | 105 | BUG(); |
@@ -306,6 +310,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus) | |||
306 | case sun4d: | 310 | case sun4d: |
307 | smp4d_boot_cpus(); | 311 | smp4d_boot_cpus(); |
308 | break; | 312 | break; |
313 | case sparc_leon: | ||
314 | leon_boot_cpus(); | ||
315 | break; | ||
309 | case sun4e: | 316 | case sun4e: |
310 | printk("SUN4E\n"); | 317 | printk("SUN4E\n"); |
311 | BUG(); | 318 | BUG(); |
@@ -376,6 +383,9 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
376 | case sun4d: | 383 | case sun4d: |
377 | ret = smp4d_boot_one_cpu(cpu); | 384 | ret = smp4d_boot_one_cpu(cpu); |
378 | break; | 385 | break; |
386 | case sparc_leon: | ||
387 | ret = leon_boot_one_cpu(cpu); | ||
388 | break; | ||
379 | case sun4e: | 389 | case sun4e: |
380 | printk("SUN4E\n"); | 390 | printk("SUN4E\n"); |
381 | BUG(); | 391 | BUG(); |
diff --git a/arch/sparc/kernel/trampoline_32.S b/arch/sparc/kernel/trampoline_32.S index 5e235c52d667..691f484e03b3 100644 --- a/arch/sparc/kernel/trampoline_32.S +++ b/arch/sparc/kernel/trampoline_32.S | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <asm/contregs.h> | 15 | #include <asm/contregs.h> |
16 | #include <asm/thread_info.h> | 16 | #include <asm/thread_info.h> |
17 | 17 | ||
18 | .globl sun4m_cpu_startup, __smp4m_processor_id | 18 | .globl sun4m_cpu_startup, __smp4m_processor_id, __leon_processor_id |
19 | .globl sun4d_cpu_startup, __smp4d_processor_id | 19 | .globl sun4d_cpu_startup, __smp4d_processor_id |
20 | 20 | ||
21 | __CPUINIT | 21 | __CPUINIT |
@@ -106,6 +106,12 @@ __smp4d_processor_id: | |||
106 | retl | 106 | retl |
107 | mov %g1, %o7 | 107 | mov %g1, %o7 |
108 | 108 | ||
109 | __leon_processor_id: | ||
110 | rd %asr17,%g2 | ||
111 | srl %g2,28,%g2 | ||
112 | retl | ||
113 | mov %g1, %o7 | ||
114 | |||
109 | /* CPUID in bootbus can be found at PA 0xff0140000 */ | 115 | /* CPUID in bootbus can be found at PA 0xff0140000 */ |
110 | #define SUN4D_BOOTBUS_CPUID 0xf0140000 | 116 | #define SUN4D_BOOTBUS_CPUID 0xf0140000 |
111 | 117 | ||
@@ -160,3 +166,64 @@ sun4d_cpu_startup: | |||
160 | nop | 166 | nop |
161 | 167 | ||
162 | b,a smp_do_cpu_idle | 168 | b,a smp_do_cpu_idle |
169 | |||
170 | #ifdef CONFIG_SPARC_LEON | ||
171 | |||
172 | __CPUINIT | ||
173 | .align 4 | ||
174 | .global leon_smp_cpu_startup, smp_penguin_ctable | ||
175 | |||
176 | leon_smp_cpu_startup: | ||
177 | |||
178 | set smp_penguin_ctable,%g1 | ||
179 | ld [%g1+4],%g1 | ||
180 | srl %g1,4,%g1 | ||
181 | set 0x00000100,%g5 /* SRMMU_CTXTBL_PTR */ | ||
182 | sta %g1, [%g5] ASI_M_MMUREGS | ||
183 | |||
184 | /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */ | ||
185 | set (PSR_PIL | PSR_S | PSR_PS), %g1 | ||
186 | wr %g1, 0x0, %psr ! traps off though | ||
187 | WRITE_PAUSE | ||
188 | |||
189 | /* Our %wim is one behind CWP */ | ||
190 | mov 2, %g1 | ||
191 | wr %g1, 0x0, %wim | ||
192 | WRITE_PAUSE | ||
193 | |||
194 | /* Set tbr - we use just one trap table. */ | ||
195 | set trapbase, %g1 | ||
196 | wr %g1, 0x0, %tbr | ||
197 | WRITE_PAUSE | ||
198 | |||
199 | /* Get our CPU id */ | ||
200 | rd %asr17,%g3 | ||
201 | |||
202 | /* Give ourselves a stack and curptr. */ | ||
203 | set current_set, %g5 | ||
204 | srl %g3, 28, %g4 | ||
205 | sll %g4, 2, %g4 | ||
206 | ld [%g5 + %g4], %g6 | ||
207 | |||
208 | sethi %hi(THREAD_SIZE - STACKFRAME_SZ), %sp | ||
209 | or %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp | ||
210 | add %g6, %sp, %sp | ||
211 | |||
212 | /* Turn on traps (PSR_ET). */ | ||
213 | rd %psr, %g1 | ||
214 | wr %g1, PSR_ET, %psr ! traps on | ||
215 | WRITE_PAUSE | ||
216 | |||
217 | /* Init our caches, etc. */ | ||
218 | set poke_srmmu, %g5 | ||
219 | ld [%g5], %g5 | ||
220 | call %g5 | ||
221 | nop | ||
222 | |||
223 | /* Start this processor. */ | ||
224 | call leon_callin | ||
225 | nop | ||
226 | |||
227 | b,a smp_do_cpu_idle | ||
228 | |||
229 | #endif | ||