Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 2 | /* Sparc SS1000/SC2000 SMP support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 5 | * |
| 6 | * Based on sun4m's smp.c, which is: |
| 7 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 8 | */ |
| 9 | |
Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 10 | #include <linux/clockchips.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/profile.h> |
Adrian Bunk | 6c81c32 | 2008-02-06 01:37:51 -0800 | [diff] [blame] | 13 | #include <linux/delay.h> |
Ingo Molnar | 68e21be2 | 2017-02-01 19:08:20 +0100 | [diff] [blame] | 14 | #include <linux/sched/mm.h> |
Robert Reif | 4245e59 | 2008-10-12 20:52:26 -0700 | [diff] [blame] | 15 | #include <linux/cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 17 | #include <asm/cacheflush.h> |
| 18 | #include <asm/switch_to.h> |
| 19 | #include <asm/tlbflush.h> |
| 20 | #include <asm/timer.h> |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 21 | #include <asm/oplib.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <asm/sbi.h> |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 23 | #include <asm/mmu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 25 | #include "kernel.h" |
Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 26 | #include "irq.h" |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #define IRQ_CROSS_CALL 15 |
| 29 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 30 | static volatile int smp_processors_ready; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | static int smp_highest_cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 33 | 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] | 34 | { |
| 35 | __asm__ __volatile__("swap [%1], %0\n\t" : |
| 36 | "=&r" (val), "=&r" (ptr) : |
| 37 | "0" (val), "1" (ptr)); |
| 38 | return val; |
| 39 | } |
| 40 | |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 41 | static void smp4d_ipi_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
David S. Miller | 7b1af32 | 2008-09-02 01:17:41 -0700 | [diff] [blame] | 43 | static unsigned char cpu_leds[32]; |
| 44 | |
| 45 | static inline void show_leds(int cpuid) |
| 46 | { |
| 47 | cpuid &= 0x1e; |
| 48 | __asm__ __volatile__ ("stba %0, [%1] %2" : : |
| 49 | "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]), |
| 50 | "r" (ECSR_BASE(cpuid) | BB_LEDS), |
| 51 | "i" (ASI_M_CTL)); |
| 52 | } |
| 53 | |
Paul Gortmaker | 2066aad | 2013-06-17 15:43:14 -0400 | [diff] [blame] | 54 | void sun4d_cpu_pre_starting(void *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
David S. Miller | c68e5d3 | 2012-05-13 23:09:04 -0700 | [diff] [blame] | 56 | int cpuid = hard_smp_processor_id(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /* Show we are alive */ |
| 59 | cpu_leds[cpuid] = 0x6; |
| 60 | show_leds(cpuid); |
| 61 | |
| 62 | /* Enable level15 interrupt, disable level14 interrupt for now */ |
| 63 | cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000); |
Sam Ravnborg | f9fd348 | 2013-02-15 15:52:06 +0100 | [diff] [blame] | 64 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Paul Gortmaker | 2066aad | 2013-06-17 15:43:14 -0400 | [diff] [blame] | 66 | void sun4d_cpu_pre_online(void *arg) |
Sam Ravnborg | f9fd348 | 2013-02-15 15:52:06 +0100 | [diff] [blame] | 67 | { |
| 68 | unsigned long flags; |
| 69 | int cpuid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Sam Ravnborg | f9fd348 | 2013-02-15 15:52:06 +0100 | [diff] [blame] | 71 | cpuid = hard_smp_processor_id(); |
| 72 | |
| 73 | /* Unblock the master CPU _only_ when the scheduler state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | * of all secondary CPUs will be up-to-date, so after |
| 75 | * the SMP initialization the master will be just allowed |
| 76 | * to call the scheduler code. |
| 77 | */ |
David S. Miller | a638f25 | 2009-01-08 16:47:17 -0800 | [diff] [blame] | 78 | sun4d_swap((unsigned long *)&cpu_callin_map[cpuid], 1); |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 79 | local_ops->cache_all(); |
| 80 | local_ops->tlb_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 81 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 82 | while ((unsigned long)current_set[cpuid] < PAGE_OFFSET) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 84 | |
| 85 | while (current_set[cpuid]->cpu != cpuid) |
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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | /* Fix idle thread fields. */ |
| 89 | __asm__ __volatile__("ld [%0], %%g6\n\t" |
| 90 | : : "r" (¤t_set[cpuid]) |
| 91 | : "memory" /* paranoid */); |
| 92 | |
| 93 | cpu_leds[cpuid] = 0x9; |
| 94 | show_leds(cpuid); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | /* Attach to the address space of init_task. */ |
Vegard Nossum | f1f1007 | 2017-02-27 14:30:07 -0800 | [diff] [blame] | 97 | mmgrab(&init_mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | current->active_mm = &init_mm; |
| 99 | |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 100 | local_ops->cache_all(); |
| 101 | local_ops->tlb_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 102 | |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 103 | while (!cpumask_test_cpu(cpuid, &smp_commenced_mask)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | barrier(); |
| 105 | |
| 106 | spin_lock_irqsave(&sun4d_imsk_lock, flags); |
| 107 | cc_set_imsk(cc_get_imsk() & ~0x4000); /* Allow PIL 14 as well */ |
| 108 | spin_unlock_irqrestore(&sun4d_imsk_lock, flags); |
| 109 | } |
| 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | /* |
| 112 | * Cycle through the processors asking the PROM to start each one. |
| 113 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | void __init smp4d_boot_cpus(void) |
| 115 | { |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 116 | smp4d_ipi_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | if (boot_cpu_id) |
| 118 | current_set[0] = NULL; |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 119 | local_ops->cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 120 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Paul Gortmaker | 2066aad | 2013-06-17 15:43:14 -0400 | [diff] [blame] | 122 | int smp4d_boot_one_cpu(int i, struct task_struct *idle) |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 123 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 124 | unsigned long *entry = &sun4d_cpu_startup; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 125 | int timeout; |
| 126 | int cpu_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 128 | cpu_find_by_instance(i, &cpu_node, NULL); |
Thomas Gleixner | f0a2bc7 | 2012-04-20 13:05:56 +0000 | [diff] [blame] | 129 | current_set[i] = task_thread_info(idle); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 130 | /* |
| 131 | * Initialize the contexts table |
| 132 | * Since the call to prom_startcpu() trashes the structure, |
| 133 | * we need to re-initialize it for each cpu |
| 134 | */ |
| 135 | smp_penguin_ctable.which_io = 0; |
| 136 | smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys; |
| 137 | smp_penguin_ctable.reg_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 139 | /* whirrr, whirrr, whirrrrrrrrr... */ |
| 140 | printk(KERN_INFO "Starting CPU %d at %p\n", i, entry); |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 141 | local_ops->cache_all(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 142 | prom_startcpu(cpu_node, |
| 143 | &smp_penguin_ctable, 0, (char *)entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 145 | printk(KERN_INFO "prom_startcpu returned :)\n"); |
| 146 | |
| 147 | /* wheee... it's going... */ |
| 148 | for (timeout = 0; timeout < 10000; timeout++) { |
| 149 | if (cpu_callin_map[i]) |
| 150 | break; |
| 151 | udelay(200); |
| 152 | } |
| 153 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 154 | if (!(cpu_callin_map[i])) { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 155 | printk(KERN_ERR "Processor %d is stuck.\n", i); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 156 | return -ENODEV; |
| 157 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 159 | local_ops->cache_all(); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | void __init smp4d_smp_done(void) |
| 164 | { |
| 165 | int i, first; |
| 166 | int *prev; |
| 167 | |
| 168 | /* setup cpu list for irq rotation */ |
| 169 | first = 0; |
| 170 | prev = &first; |
Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 171 | for_each_online_cpu(i) { |
| 172 | *prev = i; |
| 173 | prev = &cpu_data(i).next; |
| 174 | } |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 175 | *prev = first; |
David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 176 | local_ops->cache_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /* Ok, they are spinning and ready to go. */ |
| 179 | smp_processors_ready = 1; |
| 180 | sun4d_distribute_irqs(); |
| 181 | } |
| 182 | |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 183 | /* Memory structure giving interrupt handler information about IPI generated */ |
| 184 | struct sun4d_ipi_work { |
| 185 | int single; |
| 186 | int msk; |
| 187 | int resched; |
| 188 | }; |
| 189 | |
| 190 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct sun4d_ipi_work, sun4d_ipi_work); |
| 191 | |
| 192 | /* Initialize IPIs on the SUN4D SMP machine */ |
| 193 | static void __init smp4d_ipi_init(void) |
| 194 | { |
| 195 | int cpu; |
| 196 | struct sun4d_ipi_work *work; |
| 197 | |
| 198 | printk(KERN_INFO "smp4d: setup IPI at IRQ %d\n", SUN4D_IPI_IRQ); |
| 199 | |
| 200 | for_each_possible_cpu(cpu) { |
| 201 | work = &per_cpu(sun4d_ipi_work, cpu); |
| 202 | work->single = work->msk = work->resched = 0; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void sun4d_ipi_interrupt(void) |
| 207 | { |
Christoph Lameter | 494fc42 | 2014-08-17 12:30:54 -0500 | [diff] [blame] | 208 | struct sun4d_ipi_work *work = this_cpu_ptr(&sun4d_ipi_work); |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 209 | |
| 210 | if (work->single) { |
| 211 | work->single = 0; |
| 212 | smp_call_function_single_interrupt(); |
| 213 | } |
| 214 | if (work->msk) { |
| 215 | work->msk = 0; |
| 216 | smp_call_function_interrupt(); |
| 217 | } |
| 218 | if (work->resched) { |
| 219 | work->resched = 0; |
| 220 | smp_resched_interrupt(); |
| 221 | } |
| 222 | } |
| 223 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 224 | /* +-------+-------------+-----------+------------------------------------+ |
| 225 | * | bcast | devid | sid | levels mask | |
| 226 | * +-------+-------------+-----------+------------------------------------+ |
| 227 | * 31 30 23 22 15 14 0 |
| 228 | */ |
| 229 | #define IGEN_MESSAGE(bcast, devid, sid, levels) \ |
| 230 | (((bcast) << 31) | ((devid) << 23) | ((sid) << 15) | (levels)) |
| 231 | |
| 232 | static void sun4d_send_ipi(int cpu, int level) |
| 233 | { |
| 234 | cc_set_igen(IGEN_MESSAGE(0, cpu << 3, 6 + ((level >> 1) & 7), 1 << (level - 1))); |
| 235 | } |
| 236 | |
| 237 | static void sun4d_ipi_single(int cpu) |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 238 | { |
| 239 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 240 | |
| 241 | /* Mark work */ |
| 242 | work->single = 1; |
| 243 | |
| 244 | /* Generate IRQ on the CPU */ |
| 245 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 246 | } |
| 247 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 248 | static void sun4d_ipi_mask_one(int cpu) |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 249 | { |
| 250 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 251 | |
| 252 | /* Mark work */ |
| 253 | work->msk = 1; |
| 254 | |
| 255 | /* Generate IRQ on the CPU */ |
| 256 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 257 | } |
| 258 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 259 | static void sun4d_ipi_resched(int cpu) |
Daniel Hellstrom | 55dd23e | 2011-05-02 00:08:54 +0000 | [diff] [blame] | 260 | { |
| 261 | struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu); |
| 262 | |
| 263 | /* Mark work */ |
| 264 | work->resched = 1; |
| 265 | |
| 266 | /* Generate IRQ on the CPU (any IRQ will cause resched) */ |
| 267 | sun4d_send_ipi(cpu, SUN4D_IPI_IRQ); |
| 268 | } |
| 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | static struct smp_funcall { |
| 271 | smpfunc_t func; |
| 272 | unsigned long arg1; |
| 273 | unsigned long arg2; |
| 274 | unsigned long arg3; |
| 275 | unsigned long arg4; |
| 276 | unsigned long arg5; |
| 277 | unsigned char processors_in[NR_CPUS]; /* Set when ipi entered. */ |
| 278 | unsigned char processors_out[NR_CPUS]; /* Set when ipi exited. */ |
| 279 | } ccall_info __attribute__((aligned(8))); |
| 280 | |
| 281 | static DEFINE_SPINLOCK(cross_call_lock); |
| 282 | |
| 283 | /* Cross calls must be serialized, at least currently. */ |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 284 | static void sun4d_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1, |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 285 | unsigned long arg2, unsigned long arg3, |
| 286 | unsigned long arg4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 288 | if (smp_processors_ready) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | register int high = smp_highest_cpu; |
| 290 | unsigned long flags; |
| 291 | |
| 292 | spin_lock_irqsave(&cross_call_lock, flags); |
| 293 | |
| 294 | { |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 295 | /* |
| 296 | * If you make changes here, make sure |
| 297 | * gcc generates proper code... |
| 298 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | register smpfunc_t f asm("i0") = func; |
| 300 | register unsigned long a1 asm("i1") = arg1; |
| 301 | register unsigned long a2 asm("i2") = arg2; |
| 302 | register unsigned long a3 asm("i3") = arg3; |
| 303 | register unsigned long a4 asm("i4") = arg4; |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 304 | register unsigned long a5 asm("i5") = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
| 306 | __asm__ __volatile__( |
| 307 | "std %0, [%6]\n\t" |
| 308 | "std %2, [%6 + 8]\n\t" |
| 309 | "std %4, [%6 + 16]\n\t" : : |
| 310 | "r"(f), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), |
| 311 | "r" (&ccall_info.func)); |
| 312 | } |
| 313 | |
| 314 | /* Init receive/complete mapping, plus fire the IPI's off. */ |
| 315 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | register int i; |
| 317 | |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 318 | cpumask_clear_cpu(smp_processor_id(), &mask); |
| 319 | cpumask_and(&mask, cpu_online_mask, &mask); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 320 | for (i = 0; i <= high; i++) { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 321 | if (cpumask_test_cpu(i, &mask)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | ccall_info.processors_in[i] = 0; |
| 323 | ccall_info.processors_out[i] = 0; |
| 324 | sun4d_send_ipi(i, IRQ_CROSS_CALL); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | { |
| 330 | register int i; |
| 331 | |
| 332 | i = 0; |
| 333 | do { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 334 | if (!cpumask_test_cpu(i, &mask)) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 335 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 336 | while (!ccall_info.processors_in[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 338 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | i = 0; |
| 341 | do { |
KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 342 | if (!cpumask_test_cpu(i, &mask)) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 343 | continue; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 344 | while (!ccall_info.processors_out[i]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | barrier(); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 346 | } while (++i <= high); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | spin_unlock_irqrestore(&cross_call_lock, flags); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /* Running cross calls. */ |
| 354 | void smp4d_cross_call_irq(void) |
| 355 | { |
David S. Miller | c68e5d3 | 2012-05-13 23:09:04 -0700 | [diff] [blame] | 356 | int i = hard_smp_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
| 358 | ccall_info.processors_in[i] = 1; |
| 359 | ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3, |
| 360 | ccall_info.arg4, ccall_info.arg5); |
| 361 | ccall_info.processors_out[i] = 1; |
| 362 | } |
| 363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | void smp4d_percpu_timer_interrupt(struct pt_regs *regs) |
| 365 | { |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 366 | struct pt_regs *old_regs; |
David S. Miller | c68e5d3 | 2012-05-13 23:09:04 -0700 | [diff] [blame] | 367 | int cpu = hard_smp_processor_id(); |
Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 368 | struct clock_event_device *ce; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | static int cpu_tick[NR_CPUS]; |
| 370 | static char led_mask[] = { 0xe, 0xd, 0xb, 0x7, 0xb, 0xd }; |
| 371 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 372 | old_regs = set_irq_regs(regs); |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 373 | bw_get_prof_limit(cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | bw_clear_intr_mask(0, 1); /* INTR_TABLE[0] & 1 is Profile IRQ */ |
| 375 | |
| 376 | cpu_tick[cpu]++; |
| 377 | if (!(cpu_tick[cpu] & 15)) { |
| 378 | if (cpu_tick[cpu] == 0x60) |
| 379 | cpu_tick[cpu] = 0; |
| 380 | cpu_leds[cpu] = led_mask[cpu_tick[cpu] >> 4]; |
| 381 | show_leds(cpu); |
| 382 | } |
| 383 | |
Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 384 | ce = &per_cpu(sparc32_clockevent, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 386 | irq_enter(); |
| 387 | ce->event_handler(ce); |
| 388 | irq_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 390 | set_irq_regs(old_regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 393 | static const struct sparc32_ipi_ops sun4d_ipi_ops = { |
| 394 | .cross_call = sun4d_cross_call, |
| 395 | .resched = sun4d_ipi_resched, |
| 396 | .single = sun4d_ipi_single, |
| 397 | .mask_one = sun4d_ipi_mask_one, |
| 398 | }; |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | void __init sun4d_init_smp(void) |
| 401 | { |
| 402 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
| 404 | /* Patch ipi15 trap table */ |
| 405 | 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] | 406 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 407 | sparc32_ipi_ops = &sun4d_ipi_ops; |
Sam Ravnborg | e54f854 | 2011-01-28 22:08:21 +0000 | [diff] [blame] | 408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | for (i = 0; i < NR_CPUS; i++) { |
| 410 | ccall_info.processors_in[i] = 1; |
| 411 | ccall_info.processors_out[i] = 1; |
| 412 | } |
| 413 | } |