6
6
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
11
#include <linux/kernel.h>
12
#include <linux/sched.h>
13
#include <linux/threads.h>
14
#include <linux/smp.h>
15
9
#include <linux/interrupt.h>
16
#include <linux/kernel_stat.h>
17
#include <linux/init.h>
18
#include <linux/spinlock.h>
20
#include <linux/swap.h>
21
10
#include <linux/profile.h>
22
11
#include <linux/delay.h>
23
12
#include <linux/cpu.h>
25
#include <asm/ptrace.h>
26
#include <asm/atomic.h>
27
#include <asm/irq_regs.h>
31
#include <asm/pgalloc.h>
32
#include <asm/pgtable.h>
33
#include <asm/oplib.h>
34
14
#include <asm/sbi.h>
35
16
#include <asm/tlbflush.h>
36
17
#include <asm/cacheflush.h>
37
#include <asm/cpudata.h>
40
22
#define IRQ_CROSS_CALL 15
42
extern ctxd_t *srmmu_ctx_table_phys;
44
static volatile int smp_processors_ready = 0;
24
static volatile int smp_processors_ready;
45
25
static int smp_highest_cpu;
46
extern volatile unsigned long cpu_callin_map[NR_CPUS];
47
extern cpuinfo_sparc cpu_data[NR_CPUS];
48
extern unsigned char boot_cpu_id;
49
extern volatile int smp_process_available;
51
extern cpumask_t smp_commenced_mask;
53
extern int __smp4d_processor_id(void);
55
/* #define SMP_DEBUG */
58
#define SMP_PRINTK(x) printk x
63
27
static inline unsigned long sun4d_swap(volatile unsigned long *ptr, unsigned long val)
118
79
sun4d_swap((unsigned long *)&cpu_callin_map[cpuid], 1);
119
80
local_flush_cache_all();
120
81
local_flush_tlb_all();
124
while((unsigned long)current_set[cpuid] < PAGE_OFFSET)
127
while(current_set[cpuid]->cpu != cpuid)
85
while ((unsigned long)current_set[cpuid] < PAGE_OFFSET)
88
while (current_set[cpuid]->cpu != cpuid)
130
91
/* Fix idle thread fields. */
131
92
__asm__ __volatile__("ld [%0], %%g6\n\t"
132
93
: : "r" (¤t_set[cpuid])
174
129
int __cpuinit smp4d_boot_one_cpu(int i)
176
extern unsigned long sun4d_cpu_startup;
177
unsigned long *entry = &sun4d_cpu_startup;
178
struct task_struct *p;
182
cpu_find_by_instance(i, &cpu_node,NULL);
183
/* Cook up an idler for this guy. */
185
current_set[i] = task_thread_info(p);
188
* Initialize the contexts table
189
* Since the call to prom_startcpu() trashes the structure,
190
* we need to re-initialize it for each cpu
192
smp_penguin_ctable.which_io = 0;
193
smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
194
smp_penguin_ctable.reg_size = 0;
196
/* whirrr, whirrr, whirrrrrrrrr... */
197
SMP_PRINTK(("Starting CPU %d at %p\n", i, entry));
198
local_flush_cache_all();
199
prom_startcpu(cpu_node,
200
&smp_penguin_ctable, 0, (char *)entry);
202
SMP_PRINTK(("prom_startcpu returned :)\n"));
204
/* wheee... it's going... */
205
for(timeout = 0; timeout < 10000; timeout++) {
206
if(cpu_callin_map[i])
131
unsigned long *entry = &sun4d_cpu_startup;
132
struct task_struct *p;
136
cpu_find_by_instance(i, &cpu_node, NULL);
137
/* Cook up an idler for this guy. */
139
current_set[i] = task_thread_info(p);
142
* Initialize the contexts table
143
* Since the call to prom_startcpu() trashes the structure,
144
* we need to re-initialize it for each cpu
146
smp_penguin_ctable.which_io = 0;
147
smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
148
smp_penguin_ctable.reg_size = 0;
150
/* whirrr, whirrr, whirrrrrrrrr... */
151
printk(KERN_INFO "Starting CPU %d at %p\n", i, entry);
152
local_flush_cache_all();
153
prom_startcpu(cpu_node,
154
&smp_penguin_ctable, 0, (char *)entry);
156
printk(KERN_INFO "prom_startcpu returned :)\n");
158
/* wheee... it's going... */
159
for (timeout = 0; timeout < 10000; timeout++) {
160
if (cpu_callin_map[i])
211
165
if (!(cpu_callin_map[i])) {
212
printk("Processor %d is stuck.\n", i);
166
printk(KERN_ERR "Processor %d is stuck.\n", i);
255
209
unsigned long arg2, unsigned long arg3,
256
210
unsigned long arg4)
258
if(smp_processors_ready) {
212
if (smp_processors_ready) {
259
213
register int high = smp_highest_cpu;
260
214
unsigned long flags;
262
216
spin_lock_irqsave(&cross_call_lock, flags);
265
/* If you make changes here, make sure gcc generates proper code... */
220
* If you make changes here, make sure
221
* gcc generates proper code...
266
223
register smpfunc_t f asm("i0") = func;
267
224
register unsigned long a1 asm("i1") = arg1;
268
225
register unsigned long a2 asm("i2") = arg2;
285
242
cpu_clear(smp_processor_id(), mask);
286
243
cpus_and(mask, cpu_online_map, mask);
287
for(i = 0; i <= high; i++) {
244
for (i = 0; i <= high; i++) {
288
245
if (cpu_isset(i, mask)) {
289
246
ccall_info.processors_in[i] = 0;
290
247
ccall_info.processors_out[i] = 0;
374
329
void __init smp4d_blackbox_id(unsigned *addr)
376
331
int rd = *addr & 0x3e000000;
378
333
addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */
379
addr[1] = 0x01000000; /* nop */
380
addr[2] = 0x01000000; /* nop */
334
addr[1] = 0x01000000; /* nop */
335
addr[2] = 0x01000000; /* nop */
383
338
void __init smp4d_blackbox_current(unsigned *addr)
385
340
int rd = *addr & 0x3e000000;
387
342
addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */
388
343
addr[2] = 0x81282002 | rd | (rd >> 11); /* sll reg, 2, reg */
389
344
addr[4] = 0x01000000; /* nop */
392
347
void __init sun4d_init_smp(void)
395
extern unsigned int t_nmi[], linux_trap_ipi15_sun4d[], linux_trap_ipi15_sun4m[];
397
351
/* Patch ipi15 trap table */
398
352
t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_sun4d - linux_trap_ipi15_sun4m);
400
354
/* And set btfixup... */
401
355
BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id);
402
356
BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current);
403
357
BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM);
404
358
BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM);
406
360
for (i = 0; i < NR_CPUS; i++) {
407
361
ccall_info.processors_in[i] = 1;
408
362
ccall_info.processors_out[i] = 1;