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> |
Sam Ravnborg | bde4d8b | 2012-03-30 15:53:50 +0200 | [diff] [blame] | 17 | #include <asm/switch_to.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/cacheflush.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 20 | #include "kernel.h" |
Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 21 | #include "irq.h" |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #define IRQ_CROSS_CALL 15 |
| 24 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 25 | static volatile int smp_processors_ready; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | static int smp_highest_cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 28 | 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] | 29 | { |
| 30 | __asm__ __volatile__("swap [%1], %0\n\t" : |
| 31 | "=&r" (val), "=&r" (ptr) : |
| 32 | "0" (val), "1" (ptr)); |
| 33 | return val; |
| 34 | } |
| 35 | |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 36 | static void smp4d_ipi_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | static void smp_setup_percpu_timer(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
David S. Miller | 7b1af32 | 2008-09-02 01:17:41 -0700 | [diff] [blame] | 39 | static unsigned char cpu_leds[32]; |
| 40 | |
| 41 | static inline void show_leds(int cpuid) |
| 42 | { |
| 43 | cpuid &= 0x1e; |
| 44 | __asm__ __volatile__ ("stba %0, [%1] %2" : : |
| 45 | "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]), |
| 46 | "r" (ECSR_BASE(cpuid) | BB_LEDS), |
| 47 | "i" (ASI_M_CTL)); |
| 48 | } |
| 49 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 50 | void __cpuinit smp4d_callin(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
| 52 | int cpuid = hard_smp4d_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | unsigned long flags; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | /* Show we are alive */ |
| 56 | cpu_leds[cpuid] = 0x6; |
| 57 | show_leds(cpuid); |
| 58 | |
| 59 | /* Enable level15 interrupt, disable level14 interrupt for now */ |
| 60 | cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000); |
| 61 | |
| 62 | local_flush_cache_all(); |
| 63 | local_flush_tlb_all(); |
| 64 | |
Manfred Spraul | e545a61 | 2008-09-07 16:57:22 +0200 | [diff] [blame] | 65 | notify_cpu_starting(cpuid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* |
| 67 | * Unblock the master CPU _only_ when the scheduler state |
| 68 | * of all secondary CPUs will be up-to-date, so after |
| 69 | * the SMP initialization the master will be just allowed |
| 70 | * to call the scheduler code. |
| 71 | */ |
| 72 | /* Get our local ticker going. */ |
| 73 | smp_setup_percpu_timer(); |
| 74 | |
| 75 | calibrate_delay(); |
| 76 | smp_store_cpu_info(cpuid); |
| 77 | local_flush_cache_all(); |
| 78 | local_flush_tlb_all(); |
| 79 | |
| 80 | /* Allow master to continue. */ |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 81 | sun4d_swap((unsigned long *)&cpu_callin_map[cpuid], 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | local_flush_cache_all(); |
| 83 | local_flush_tlb_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 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 | |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 108 | while (!cpumask_test_cpu(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 | { |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 123 | smp4d_ipi_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | if (boot_cpu_id) |
| 125 | current_set[0] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | smp_setup_percpu_timer(); |
| 127 | local_flush_cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 128 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Thomas Gleixner | f0a2bc7 | 2012-04-20 13:05:56 +0000 | [diff] [blame^] | 130 | int __cpuinit smp4d_boot_one_cpu(int i, struct task_struct *idle) |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 131 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 132 | unsigned long *entry = &sun4d_cpu_startup; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 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); |
Thomas Gleixner | f0a2bc7 | 2012-04-20 13:05:56 +0000 | [diff] [blame^] | 137 | current_set[i] = task_thread_info(idle); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 138 | /* |
| 139 | * Initialize the contexts table |
| 140 | * Since the call to prom_startcpu() trashes the structure, |
| 141 | * we need to re-initialize it for each cpu |
| 142 | */ |
| 143 | smp_penguin_ctable.which_io = 0; |
| 144 | smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys; |
| 145 | smp_penguin_ctable.reg_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 147 | /* whirrr, whirrr, whirrrrrrrrr... */ |
| 148 | printk(KERN_INFO "Starting CPU %d at %p\n", i, entry); |
| 149 | local_flush_cache_all(); |
| 150 | prom_startcpu(cpu_node, |
| 151 | &smp_penguin_ctable, 0, (char *)entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 153 | printk(KERN_INFO "prom_startcpu returned :)\n"); |
| 154 | |
| 155 | /* wheee... it's going... */ |
| 156 | for (timeout = 0; timeout < 10000; timeout++) { |
| 157 | if (cpu_callin_map[i]) |
| 158 | break; |
| 159 | udelay(200); |
| 160 | } |
| 161 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 162 | if (!(cpu_callin_map[i])) { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 163 | printk(KERN_ERR "Processor %d is stuck.\n", i); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 164 | return -ENODEV; |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | local_flush_cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | void __init smp4d_smp_done(void) |
| 172 | { |
| 173 | int i, first; |
| 174 | int *prev; |
| 175 | |
| 176 | /* setup cpu list for irq rotation */ |
| 177 | first = 0; |
| 178 | prev = &first; |
Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 179 | for_each_online_cpu(i) { |
| 180 | *prev = i; |
| 181 | prev = &cpu_data(i).next; |
| 182 | } |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 183 | *prev = first; |
| 184 | local_flush_cache_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | /* Ok, they are spinning and ready to go. */ |
| 187 | smp_processors_ready = 1; |
| 188 | sun4d_distribute_irqs(); |
| 189 | } |
| 190 | |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 191 | /* Memory structure giving interrupt handler information about IPI generated */ |
| 192 | struct sun4d_ipi_work { |
| 193 | int single; |
| 194 | int msk; |
| 195 | int resched; |
| 196 | }; |
| 197 | |
| 198 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct sun4d_ipi_work, sun4d_ipi_work); |
| 199 | |
| 200 | /* Initialize IPIs on the SUN4D SMP machine */ |
| 201 | static void __init smp4d_ipi_init(void) |
| 202 | { |
| 203 | int cpu; |
| 204 | struct sun4d_ipi_work *work; |
| 205 | |
| 206 | printk(KERN_INFO "smp4d: setup IPI at IRQ %d\n", SUN4D_IPI_IRQ); |
| 207 | |
| 208 | for_each_possible_cpu(cpu) { |
| 209 | work = &per_cpu(sun4d_ipi_work, cpu); |
| 210 | work->single = work->msk = work->resched = 0; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | void sun4d_ipi_interrupt(void) |
| 215 | { |
| 216 | struct sun4d_ipi_work *work = &__get_cpu_var(sun4d_ipi_work); |
| 217 | |
| 218 | if (work->single) { |
| 219 | work->single = 0; |
| 220 | smp_call_function_single_interrupt(); |
| 221 | } |
| 222 | if (work->msk) { |
| 223 | work->msk = 0; |
| 224 | smp_call_function_interrupt(); |
| 225 | } |
| 226 | if (work->resched) { |
| 227 | work->resched = 0; |
| 228 | smp_resched_interrupt(); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | static void smp4d_ipi_single(int cpu) |
| 233 | { |
| 234 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 235 | |
| 236 | /* Mark work */ |
| 237 | work->single = 1; |
| 238 | |
| 239 | /* Generate IRQ on the CPU */ |
| 240 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 241 | } |
| 242 | |
| 243 | static void smp4d_ipi_mask_one(int cpu) |
| 244 | { |
| 245 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 246 | |
| 247 | /* Mark work */ |
| 248 | work->msk = 1; |
| 249 | |
| 250 | /* Generate IRQ on the CPU */ |
| 251 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 252 | } |
| 253 | |
| 254 | static void smp4d_ipi_resched(int cpu) |
| 255 | { |
| 256 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 257 | |
| 258 | /* Mark work */ |
| 259 | work->resched = 1; |
| 260 | |
| 261 | /* Generate IRQ on the CPU (any IRQ will cause resched) */ |
| 262 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 263 | } |
| 264 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | static struct smp_funcall { |
| 266 | smpfunc_t func; |
| 267 | unsigned long arg1; |
| 268 | unsigned long arg2; |
| 269 | unsigned long arg3; |
| 270 | unsigned long arg4; |
| 271 | unsigned long arg5; |
| 272 | unsigned char processors_in[NR_CPUS]; /* Set when ipi entered. */ |
| 273 | unsigned char processors_out[NR_CPUS]; /* Set when ipi exited. */ |
| 274 | } ccall_info __attribute__((aligned(8))); |
| 275 | |
| 276 | static DEFINE_SPINLOCK(cross_call_lock); |
| 277 | |
| 278 | /* Cross calls must be serialized, at least currently. */ |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 279 | static void smp4d_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1, |
| 280 | unsigned long arg2, unsigned long arg3, |
| 281 | unsigned long arg4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 283 | if (smp_processors_ready) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | register int high = smp_highest_cpu; |
| 285 | unsigned long flags; |
| 286 | |
| 287 | spin_lock_irqsave(&cross_call_lock, flags); |
| 288 | |
| 289 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 290 | /* |
| 291 | * If you make changes here, make sure |
| 292 | * gcc generates proper code... |
| 293 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | register smpfunc_t f asm("i0") = func; |
| 295 | register unsigned long a1 asm("i1") = arg1; |
| 296 | register unsigned long a2 asm("i2") = arg2; |
| 297 | register unsigned long a3 asm("i3") = arg3; |
| 298 | register unsigned long a4 asm("i4") = arg4; |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 299 | register unsigned long a5 asm("i5") = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | __asm__ __volatile__( |
| 302 | "std %0, [%6]\n\t" |
| 303 | "std %2, [%6 + 8]\n\t" |
| 304 | "std %4, [%6 + 16]\n\t" : : |
| 305 | "r"(f), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), |
| 306 | "r" (&ccall_info.func)); |
| 307 | } |
| 308 | |
| 309 | /* Init receive/complete mapping, plus fire the IPI's off. */ |
| 310 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | register int i; |
| 312 | |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 313 | cpumask_clear_cpu(smp_processor_id(), &mask); |
| 314 | cpumask_and(&mask, cpu_online_mask, &mask); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 315 | for (i = 0; i <= high; i++) { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 316 | if (cpumask_test_cpu(i, &mask)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | ccall_info.processors_in[i] = 0; |
| 318 | ccall_info.processors_out[i] = 0; |
| 319 | sun4d_send_ipi(i, IRQ_CROSS_CALL); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | { |
| 325 | register int i; |
| 326 | |
| 327 | i = 0; |
| 328 | do { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 329 | if (!cpumask_test_cpu(i, &mask)) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 330 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 331 | while (!ccall_info.processors_in[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 333 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
| 335 | i = 0; |
| 336 | do { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 337 | if (!cpumask_test_cpu(i, &mask)) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 338 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 339 | while (!ccall_info.processors_out[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 341 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | spin_unlock_irqrestore(&cross_call_lock, flags); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | /* Running cross calls. */ |
| 349 | void smp4d_cross_call_irq(void) |
| 350 | { |
| 351 | int i = hard_smp4d_processor_id(); |
| 352 | |
| 353 | ccall_info.processors_in[i] = 1; |
| 354 | ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3, |
| 355 | ccall_info.arg4, ccall_info.arg5); |
| 356 | ccall_info.processors_out[i] = 1; |
| 357 | } |
| 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | void smp4d_percpu_timer_interrupt(struct pt_regs *regs) |
| 360 | { |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 361 | struct pt_regs *old_regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | int cpu = hard_smp4d_processor_id(); |
| 363 | static int cpu_tick[NR_CPUS]; |
| 364 | static char led_mask[] = { 0xe, 0xd, 0xb, 0x7, 0xb, 0xd }; |
| 365 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 366 | old_regs = set_irq_regs(regs); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 367 | bw_get_prof_limit(cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | bw_clear_intr_mask(0, 1); /* INTR_TABLE[0] & 1 is Profile IRQ */ |
| 369 | |
| 370 | cpu_tick[cpu]++; |
| 371 | if (!(cpu_tick[cpu] & 15)) { |
| 372 | if (cpu_tick[cpu] == 0x60) |
| 373 | cpu_tick[cpu] = 0; |
| 374 | cpu_leds[cpu] = led_mask[cpu_tick[cpu] >> 4]; |
| 375 | show_leds(cpu); |
| 376 | } |
| 377 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 378 | profile_tick(CPU_PROFILING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 380 | if (!--prof_counter(cpu)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | int user = user_mode(regs); |
| 382 | |
| 383 | irq_enter(); |
| 384 | update_process_times(user); |
| 385 | irq_exit(); |
| 386 | |
| 387 | prof_counter(cpu) = prof_multiplier(cpu); |
| 388 | } |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 389 | set_irq_regs(old_regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 392 | static void __cpuinit smp_setup_percpu_timer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
| 394 | int cpu = hard_smp4d_processor_id(); |
| 395 | |
| 396 | prof_counter(cpu) = prof_multiplier(cpu) = 1; |
| 397 | load_profile_irq(cpu, lvl14_resolution); |
| 398 | } |
| 399 | |
| 400 | void __init smp4d_blackbox_id(unsigned *addr) |
| 401 | { |
| 402 | int rd = *addr & 0x3e000000; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */ |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 405 | addr[1] = 0x01000000; /* nop */ |
| 406 | addr[2] = 0x01000000; /* nop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | void __init smp4d_blackbox_current(unsigned *addr) |
| 410 | { |
| 411 | int rd = *addr & 0x3e000000; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | addr[0] = 0xc0800800 | rd; /* lda [%g0] ASI_M_VIKING_TMP1, reg */ |
| 414 | addr[2] = 0x81282002 | rd | (rd >> 11); /* sll reg, 2, reg */ |
| 415 | addr[4] = 0x01000000; /* nop */ |
| 416 | } |
| 417 | |
| 418 | void __init sun4d_init_smp(void) |
| 419 | { |
| 420 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | /* Patch ipi15 trap table */ |
| 423 | 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] | 424 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | /* And set btfixup... */ |
| 426 | BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id); |
| 427 | BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current); |
| 428 | BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM); |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 430 | BTFIXUPSET_CALL(smp_ipi_resched, smp4d_ipi_resched, BTFIXUPCALL_NORM); |
| 431 | BTFIXUPSET_CALL(smp_ipi_single, smp4d_ipi_single, BTFIXUPCALL_NORM); |
| 432 | BTFIXUPSET_CALL(smp_ipi_mask_one, smp4d_ipi_mask_one, BTFIXUPCALL_NORM); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 433 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | for (i = 0; i < NR_CPUS; i++) { |
| 435 | ccall_info.processors_in[i] = 1; |
| 436 | ccall_info.processors_out[i] = 1; |
| 437 | } |
| 438 | } |