Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 1 | /* Sparc SS1000/SC2000 SMP support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 4 | * |
| 5 | * Based on sun4m's smp.c, which is: |
| 6 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 7 | */ |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/profile.h> |
Adrian Bunk | 6c81c32 | 2008-02-06 01:37:51 -0800 | [diff] [blame] | 11 | #include <linux/delay.h> |
Robert Reif | 4245e59 | 2008-10-12 20:52:26 -0700 | [diff] [blame] | 12 | #include <linux/cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/sbi.h> |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 15 | #include <asm/mmu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/tlbflush.h> |
| 17 | #include <asm/cacheflush.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 19 | #include "kernel.h" |
Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 20 | #include "irq.h" |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #define IRQ_CROSS_CALL 15 |
| 23 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 24 | static volatile int smp_processors_ready; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | static int smp_highest_cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 27 | static inline unsigned long sun4d_swap(volatile unsigned long *ptr, unsigned long val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | { |
| 29 | __asm__ __volatile__("swap [%1], %0\n\t" : |
| 30 | "=&r" (val), "=&r" (ptr) : |
| 31 | "0" (val), "1" (ptr)); |
| 32 | return val; |
| 33 | } |
| 34 | |
| 35 | static void smp_setup_percpu_timer(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
David S. Miller | 7b1af32 | 2008-09-02 01:17:41 -0700 | [diff] [blame] | 37 | static unsigned char cpu_leds[32]; |
| 38 | |
| 39 | static inline void show_leds(int cpuid) |
| 40 | { |
| 41 | cpuid &= 0x1e; |
| 42 | __asm__ __volatile__ ("stba %0, [%1] %2" : : |
| 43 | "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]), |
| 44 | "r" (ECSR_BASE(cpuid) | BB_LEDS), |
| 45 | "i" (ASI_M_CTL)); |
| 46 | } |
| 47 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 48 | void __cpuinit smp4d_callin(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
| 50 | int cpuid = hard_smp4d_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | unsigned long flags; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* Show we are alive */ |
| 54 | cpu_leds[cpuid] = 0x6; |
| 55 | show_leds(cpuid); |
| 56 | |
| 57 | /* Enable level15 interrupt, disable level14 interrupt for now */ |
| 58 | cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000); |
| 59 | |
| 60 | local_flush_cache_all(); |
| 61 | local_flush_tlb_all(); |
| 62 | |
Manfred Spraul | e545a61 | 2008-09-07 16:57:22 +0200 | [diff] [blame] | 63 | notify_cpu_starting(cpuid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | /* |
| 65 | * Unblock the master CPU _only_ when the scheduler state |
| 66 | * of all secondary CPUs will be up-to-date, so after |
| 67 | * the SMP initialization the master will be just allowed |
| 68 | * to call the scheduler code. |
| 69 | */ |
| 70 | /* Get our local ticker going. */ |
| 71 | smp_setup_percpu_timer(); |
| 72 | |
| 73 | calibrate_delay(); |
| 74 | smp_store_cpu_info(cpuid); |
| 75 | local_flush_cache_all(); |
| 76 | local_flush_tlb_all(); |
| 77 | |
| 78 | /* Allow master to continue. */ |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 79 | sun4d_swap((unsigned long *)&cpu_callin_map[cpuid], 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | local_flush_cache_all(); |
| 81 | local_flush_tlb_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | cpu_probe(); |
| 84 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 85 | while ((unsigned long)current_set[cpuid] < PAGE_OFFSET) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 87 | |
| 88 | while (current_set[cpuid]->cpu != cpuid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 90 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | /* Fix idle thread fields. */ |
| 92 | __asm__ __volatile__("ld [%0], %%g6\n\t" |
| 93 | : : "r" (¤t_set[cpuid]) |
| 94 | : "memory" /* paranoid */); |
| 95 | |
| 96 | cpu_leds[cpuid] = 0x9; |
| 97 | show_leds(cpuid); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* Attach to the address space of init_task. */ |
| 100 | atomic_inc(&init_mm.mm_count); |
| 101 | current->active_mm = &init_mm; |
| 102 | |
| 103 | local_flush_cache_all(); |
| 104 | local_flush_tlb_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | local_irq_enable(); /* We don't allow PIL 14 yet */ |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 107 | |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 108 | while (!cpu_isset(cpuid, smp_commenced_mask)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | barrier(); |
| 110 | |
| 111 | spin_lock_irqsave(&sun4d_imsk_lock, flags); |
| 112 | cc_set_imsk(cc_get_imsk() & ~0x4000); /* Allow PIL 14 as well */ |
| 113 | spin_unlock_irqrestore(&sun4d_imsk_lock, flags); |
Rusty Russell | fe73971 | 2009-03-16 14:40:22 +1030 | [diff] [blame] | 114 | set_cpu_online(cpuid, true); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | /* |
| 119 | * Cycle through the processors asking the PROM to start each one. |
| 120 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | void __init smp4d_boot_cpus(void) |
| 122 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | if (boot_cpu_id) |
| 124 | current_set[0] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | smp_setup_percpu_timer(); |
| 126 | local_flush_cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 127 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Al Viro | b4cff84 | 2007-02-01 13:52:33 +0000 | [diff] [blame] | 129 | int __cpuinit smp4d_boot_one_cpu(int i) |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 130 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 131 | unsigned long *entry = &sun4d_cpu_startup; |
| 132 | struct task_struct *p; |
| 133 | int timeout; |
| 134 | int cpu_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 136 | cpu_find_by_instance(i, &cpu_node, NULL); |
| 137 | /* Cook up an idler for this guy. */ |
| 138 | p = fork_idle(i); |
| 139 | current_set[i] = task_thread_info(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 141 | /* |
| 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 |
| 145 | */ |
| 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 156 | printk(KERN_INFO "prom_startcpu returned :)\n"); |
| 157 | |
| 158 | /* wheee... it's going... */ |
| 159 | for (timeout = 0; timeout < 10000; timeout++) { |
| 160 | if (cpu_callin_map[i]) |
| 161 | break; |
| 162 | udelay(200); |
| 163 | } |
| 164 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 165 | if (!(cpu_callin_map[i])) { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 166 | printk(KERN_ERR "Processor %d is stuck.\n", i); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 167 | return -ENODEV; |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | local_flush_cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | void __init smp4d_smp_done(void) |
| 175 | { |
| 176 | int i, first; |
| 177 | int *prev; |
| 178 | |
| 179 | /* setup cpu list for irq rotation */ |
| 180 | first = 0; |
| 181 | prev = &first; |
Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 182 | for_each_online_cpu(i) { |
| 183 | *prev = i; |
| 184 | prev = &cpu_data(i).next; |
| 185 | } |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 186 | *prev = first; |
| 187 | local_flush_cache_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | /* Ok, they are spinning and ready to go. */ |
| 190 | smp_processors_ready = 1; |
| 191 | sun4d_distribute_irqs(); |
| 192 | } |
| 193 | |
| 194 | static struct smp_funcall { |
| 195 | smpfunc_t func; |
| 196 | unsigned long arg1; |
| 197 | unsigned long arg2; |
| 198 | unsigned long arg3; |
| 199 | unsigned long arg4; |
| 200 | unsigned long arg5; |
| 201 | unsigned char processors_in[NR_CPUS]; /* Set when ipi entered. */ |
| 202 | unsigned char processors_out[NR_CPUS]; /* Set when ipi exited. */ |
| 203 | } ccall_info __attribute__((aligned(8))); |
| 204 | |
| 205 | static DEFINE_SPINLOCK(cross_call_lock); |
| 206 | |
| 207 | /* Cross calls must be serialized, at least currently. */ |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 208 | static void smp4d_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1, |
| 209 | unsigned long arg2, unsigned long arg3, |
| 210 | unsigned long arg4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 212 | if (smp_processors_ready) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | register int high = smp_highest_cpu; |
| 214 | unsigned long flags; |
| 215 | |
| 216 | spin_lock_irqsave(&cross_call_lock, flags); |
| 217 | |
| 218 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 219 | /* |
| 220 | * If you make changes here, make sure |
| 221 | * gcc generates proper code... |
| 222 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | register smpfunc_t f asm("i0") = func; |
| 224 | register unsigned long a1 asm("i1") = arg1; |
| 225 | register unsigned long a2 asm("i2") = arg2; |
| 226 | register unsigned long a3 asm("i3") = arg3; |
| 227 | register unsigned long a4 asm("i4") = arg4; |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 228 | register unsigned long a5 asm("i5") = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | |
| 230 | __asm__ __volatile__( |
| 231 | "std %0, [%6]\n\t" |
| 232 | "std %2, [%6 + 8]\n\t" |
| 233 | "std %4, [%6 + 16]\n\t" : : |
| 234 | "r"(f), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), |
| 235 | "r" (&ccall_info.func)); |
| 236 | } |
| 237 | |
| 238 | /* Init receive/complete mapping, plus fire the IPI's off. */ |
| 239 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | register int i; |
| 241 | |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 242 | cpu_clear(smp_processor_id(), mask); |
| 243 | cpus_and(mask, cpu_online_map, mask); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 244 | for (i = 0; i <= high; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | if (cpu_isset(i, mask)) { |
| 246 | ccall_info.processors_in[i] = 0; |
| 247 | ccall_info.processors_out[i] = 0; |
| 248 | sun4d_send_ipi(i, IRQ_CROSS_CALL); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | { |
| 254 | register int i; |
| 255 | |
| 256 | i = 0; |
| 257 | do { |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 258 | if (!cpu_isset(i, mask)) |
| 259 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 260 | while (!ccall_info.processors_in[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 262 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | i = 0; |
| 265 | do { |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 266 | if (!cpu_isset(i, mask)) |
| 267 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 268 | while (!ccall_info.processors_out[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 270 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | spin_unlock_irqrestore(&cross_call_lock, flags); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | /* Running cross calls. */ |
| 278 | void smp4d_cross_call_irq(void) |
| 279 | { |
| 280 | int i = hard_smp4d_processor_id(); |
| 281 | |
| 282 | ccall_info.processors_in[i] = 1; |
| 283 | ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3, |
| 284 | ccall_info.arg4, ccall_info.arg5); |
| 285 | ccall_info.processors_out[i] = 1; |
| 286 | } |
| 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | void smp4d_percpu_timer_interrupt(struct pt_regs *regs) |
| 289 | { |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 290 | struct pt_regs *old_regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | int cpu = hard_smp4d_processor_id(); |
| 292 | static int cpu_tick[NR_CPUS]; |
| 293 | static char led_mask[] = { 0xe, 0xd, 0xb, 0x7, 0xb, 0xd }; |
| 294 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 295 | old_regs = set_irq_regs(regs); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 296 | bw_get_prof_limit(cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | bw_clear_intr_mask(0, 1); /* INTR_TABLE[0] & 1 is Profile IRQ */ |
| 298 | |
| 299 | cpu_tick[cpu]++; |
| 300 | if (!(cpu_tick[cpu] & 15)) { |
| 301 | if (cpu_tick[cpu] == 0x60) |
| 302 | cpu_tick[cpu] = 0; |
| 303 | cpu_leds[cpu] = led_mask[cpu_tick[cpu] >> 4]; |
| 304 | show_leds(cpu); |
| 305 | } |
| 306 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 307 | profile_tick(CPU_PROFILING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 309 | if (!--prof_counter(cpu)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | int user = user_mode(regs); |
| 311 | |
| 312 | irq_enter(); |
| 313 | update_process_times(user); |
| 314 | irq_exit(); |
| 315 | |
| 316 | prof_counter(cpu) = prof_multiplier(cpu); |
| 317 | } |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 318 | set_irq_regs(old_regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 321 | static void __cpuinit smp_setup_percpu_timer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | { |
| 323 | int cpu = hard_smp4d_processor_id(); |
| 324 | |
| 325 | prof_counter(cpu) = prof_multiplier(cpu) = 1; |
| 326 | load_profile_irq(cpu, lvl14_resolution); |
| 327 | } |
| 328 | |
| 329 | void __init smp4d_blackbox_id(unsigned *addr) |
| 330 | { |
| 331 | int rd = *addr & 0x3e000000; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */ |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 334 | addr[1] = 0x01000000; /* nop */ |
| 335 | addr[2] = 0x01000000; /* nop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | void __init smp4d_blackbox_current(unsigned *addr) |
| 339 | { |
| 340 | int rd = *addr & 0x3e000000; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 341 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */ |
| 343 | addr[2] = 0x81282002 | rd | (rd >> 11); /* sll reg, 2, reg */ |
| 344 | addr[4] = 0x01000000; /* nop */ |
| 345 | } |
| 346 | |
| 347 | void __init sun4d_init_smp(void) |
| 348 | { |
| 349 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | /* Patch ipi15 trap table */ |
| 352 | t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_sun4d - linux_trap_ipi15_sun4m); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | /* And set btfixup... */ |
| 355 | BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id); |
| 356 | BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current); |
| 357 | BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame^] | 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | for (i = 0; i < NR_CPUS; i++) { |
| 361 | ccall_info.processors_in[i] = 1; |
| 362 | ccall_info.processors_out[i] = 1; |
| 363 | } |
| 364 | } |