Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* smp.c: Sparc SMP support. |
| 2 | * |
| 3 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 4 | * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 5 | * Copyright (C) 2004 Keith M Wesolowski (wesolows@foobazco.org) |
| 6 | */ |
| 7 | |
| 8 | #include <asm/head.h> |
| 9 | |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/threads.h> |
| 13 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/kernel_stat.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/spinlock.h> |
| 18 | #include <linux/mm.h> |
| 19 | #include <linux/fs.h> |
| 20 | #include <linux/seq_file.h> |
| 21 | #include <linux/cache.h> |
| 22 | #include <linux/delay.h> |
| 23 | |
| 24 | #include <asm/ptrace.h> |
| 25 | #include <asm/atomic.h> |
| 26 | |
| 27 | #include <asm/irq.h> |
| 28 | #include <asm/page.h> |
| 29 | #include <asm/pgalloc.h> |
| 30 | #include <asm/pgtable.h> |
| 31 | #include <asm/oplib.h> |
| 32 | #include <asm/cacheflush.h> |
| 33 | #include <asm/tlbflush.h> |
| 34 | #include <asm/cpudata.h> |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 35 | #include <asm/leon.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 37 | #include "irq.h" |
| 38 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 39 | volatile unsigned long cpu_callin_map[NR_CPUS] __cpuinitdata = {0,}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 41 | cpumask_t smp_commenced_mask = CPU_MASK_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | /* The only guaranteed locking primitive available on all Sparc |
| 44 | * processors is 'ldstub [%reg + immediate], %dest_reg' which atomically |
| 45 | * places the current byte at the effective address into dest_reg and |
| 46 | * places 0xff there afterwards. Pretty lame locking primitive |
| 47 | * compared to the Alpha and the Intel no? Most Sparcs have 'swap' |
| 48 | * instruction which is much better... |
| 49 | */ |
| 50 | |
Bob Breuer | 92d452f | 2006-06-20 00:36:10 -0700 | [diff] [blame] | 51 | void __cpuinit smp_store_cpu_info(int id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | { |
| 53 | int cpu_node; |
| 54 | |
| 55 | cpu_data(id).udelay_val = loops_per_jiffy; |
| 56 | |
| 57 | cpu_find_by_mid(id, &cpu_node); |
| 58 | cpu_data(id).clock_tick = prom_getintdefault(cpu_node, |
| 59 | "clock-frequency", 0); |
| 60 | cpu_data(id).prom_node = cpu_node; |
| 61 | cpu_data(id).mid = cpu_get_hwmid(cpu_node); |
Krzysztof Helt | 650fb83 | 2006-06-10 22:03:43 -0700 | [diff] [blame] | 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | if (cpu_data(id).mid < 0) |
| 64 | panic("No MID found for CPU%d at node 0x%08d", id, cpu_node); |
| 65 | } |
| 66 | |
| 67 | void __init smp_cpus_done(unsigned int max_cpus) |
| 68 | { |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 69 | extern void smp4m_smp_done(void); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 70 | extern void smp4d_smp_done(void); |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 71 | unsigned long bogosum = 0; |
Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 72 | int cpu, num = 0; |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 73 | |
Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 74 | for_each_online_cpu(cpu) { |
| 75 | num++; |
| 76 | bogosum += cpu_data(cpu).udelay_val; |
| 77 | } |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 78 | |
| 79 | printk("Total of %d processors activated (%lu.%02lu BogoMIPS).\n", |
| 80 | num, bogosum/(500000/HZ), |
| 81 | (bogosum/(5000/HZ))%100); |
| 82 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 83 | switch(sparc_cpu_model) { |
| 84 | case sun4: |
| 85 | printk("SUN4\n"); |
| 86 | BUG(); |
| 87 | break; |
| 88 | case sun4c: |
| 89 | printk("SUN4C\n"); |
| 90 | BUG(); |
| 91 | break; |
| 92 | case sun4m: |
| 93 | smp4m_smp_done(); |
| 94 | break; |
| 95 | case sun4d: |
| 96 | smp4d_smp_done(); |
| 97 | break; |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 98 | case sparc_leon: |
| 99 | leon_smp_done(); |
| 100 | break; |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 101 | case sun4e: |
| 102 | printk("SUN4E\n"); |
| 103 | BUG(); |
| 104 | break; |
| 105 | case sun4u: |
| 106 | printk("SUN4U\n"); |
| 107 | BUG(); |
| 108 | break; |
| 109 | default: |
| 110 | printk("UNKNOWN!\n"); |
| 111 | BUG(); |
| 112 | break; |
| 113 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | void cpu_panic(void) |
| 117 | { |
| 118 | printk("CPU[%d]: Returns from cpu_idle!\n", smp_processor_id()); |
| 119 | panic("SMP bolixed\n"); |
| 120 | } |
| 121 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 122 | struct linux_prom_registers smp_penguin_ctable __cpuinitdata = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | void smp_send_reschedule(int cpu) |
| 125 | { |
Daniel Hellstrom | d6d0481 | 2011-05-02 00:08:51 +0000 | [diff] [blame^] | 126 | /* |
| 127 | * CPU model dependent way of implementing IPI generation targeting |
| 128 | * a single CPU. The trap handler needs only to do trap entry/return |
| 129 | * to call schedule. |
| 130 | */ |
| 131 | BTFIXUP_CALL(smp_ipi_resched)(cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void smp_send_stop(void) |
| 135 | { |
| 136 | } |
| 137 | |
Daniel Hellstrom | d6d0481 | 2011-05-02 00:08:51 +0000 | [diff] [blame^] | 138 | void arch_send_call_function_single_ipi(int cpu) |
| 139 | { |
| 140 | /* trigger one IPI single call on one CPU */ |
| 141 | BTFIXUP_CALL(smp_ipi_single)(cpu); |
| 142 | } |
| 143 | |
| 144 | void arch_send_call_function_ipi_mask(const struct cpumask *mask) |
| 145 | { |
| 146 | int cpu; |
| 147 | |
| 148 | /* trigger IPI mask call on each CPU */ |
| 149 | for_each_cpu(cpu, mask) |
| 150 | BTFIXUP_CALL(smp_ipi_mask_one)(cpu); |
| 151 | } |
| 152 | |
| 153 | void smp_resched_interrupt(void) |
| 154 | { |
| 155 | local_cpu_data().irq_resched_count++; |
| 156 | /* |
| 157 | * do nothing, since it all was about calling re-schedule |
| 158 | * routine called by interrupt return code. |
| 159 | */ |
| 160 | } |
| 161 | |
| 162 | void smp_call_function_single_interrupt(void) |
| 163 | { |
| 164 | irq_enter(); |
| 165 | generic_smp_call_function_single_interrupt(); |
| 166 | local_cpu_data().irq_call_count++; |
| 167 | irq_exit(); |
| 168 | } |
| 169 | |
| 170 | void smp_call_function_interrupt(void) |
| 171 | { |
| 172 | irq_enter(); |
| 173 | generic_smp_call_function_interrupt(); |
| 174 | local_cpu_data().irq_call_count++; |
| 175 | irq_exit(); |
| 176 | } |
| 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | void smp_flush_cache_all(void) |
| 179 | { |
| 180 | xc0((smpfunc_t) BTFIXUP_CALL(local_flush_cache_all)); |
| 181 | local_flush_cache_all(); |
| 182 | } |
| 183 | |
| 184 | void smp_flush_tlb_all(void) |
| 185 | { |
| 186 | xc0((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_all)); |
| 187 | local_flush_tlb_all(); |
| 188 | } |
| 189 | |
| 190 | void smp_flush_cache_mm(struct mm_struct *mm) |
| 191 | { |
| 192 | if(mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 193 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | cpu_clear(smp_processor_id(), cpu_mask); |
| 195 | if (!cpus_empty(cpu_mask)) |
| 196 | xc1((smpfunc_t) BTFIXUP_CALL(local_flush_cache_mm), (unsigned long) mm); |
| 197 | local_flush_cache_mm(mm); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void smp_flush_tlb_mm(struct mm_struct *mm) |
| 202 | { |
| 203 | if(mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 204 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | cpu_clear(smp_processor_id(), cpu_mask); |
| 206 | if (!cpus_empty(cpu_mask)) { |
| 207 | xc1((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_mm), (unsigned long) mm); |
| 208 | if(atomic_read(&mm->mm_users) == 1 && current->active_mm == mm) |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 209 | cpumask_copy(mm_cpumask(mm), |
| 210 | cpumask_of(smp_processor_id())); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | local_flush_tlb_mm(mm); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | void smp_flush_cache_range(struct vm_area_struct *vma, unsigned long start, |
| 217 | unsigned long end) |
| 218 | { |
| 219 | struct mm_struct *mm = vma->vm_mm; |
| 220 | |
| 221 | if (mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 222 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | cpu_clear(smp_processor_id(), cpu_mask); |
| 224 | if (!cpus_empty(cpu_mask)) |
| 225 | xc3((smpfunc_t) BTFIXUP_CALL(local_flush_cache_range), (unsigned long) vma, start, end); |
| 226 | local_flush_cache_range(vma, start, end); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | void smp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
| 231 | unsigned long end) |
| 232 | { |
| 233 | struct mm_struct *mm = vma->vm_mm; |
| 234 | |
| 235 | if (mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 236 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | cpu_clear(smp_processor_id(), cpu_mask); |
| 238 | if (!cpus_empty(cpu_mask)) |
| 239 | xc3((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_range), (unsigned long) vma, start, end); |
| 240 | local_flush_tlb_range(vma, start, end); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | void smp_flush_cache_page(struct vm_area_struct *vma, unsigned long page) |
| 245 | { |
| 246 | struct mm_struct *mm = vma->vm_mm; |
| 247 | |
| 248 | if(mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 249 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | cpu_clear(smp_processor_id(), cpu_mask); |
| 251 | if (!cpus_empty(cpu_mask)) |
| 252 | xc2((smpfunc_t) BTFIXUP_CALL(local_flush_cache_page), (unsigned long) vma, page); |
| 253 | local_flush_cache_page(vma, page); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) |
| 258 | { |
| 259 | struct mm_struct *mm = vma->vm_mm; |
| 260 | |
| 261 | if(mm->context != NO_CONTEXT) { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 262 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | cpu_clear(smp_processor_id(), cpu_mask); |
| 264 | if (!cpus_empty(cpu_mask)) |
| 265 | xc2((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_page), (unsigned long) vma, page); |
| 266 | local_flush_tlb_page(vma, page); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | void smp_reschedule_irq(void) |
| 271 | { |
| 272 | set_need_resched(); |
| 273 | } |
| 274 | |
| 275 | void smp_flush_page_to_ram(unsigned long page) |
| 276 | { |
| 277 | /* Current theory is that those who call this are the one's |
| 278 | * who have just dirtied their cache with the pages contents |
| 279 | * in kernel space, therefore we only run this on local cpu. |
| 280 | * |
| 281 | * XXX This experiment failed, research further... -DaveM |
| 282 | */ |
| 283 | #if 1 |
| 284 | xc1((smpfunc_t) BTFIXUP_CALL(local_flush_page_to_ram), page); |
| 285 | #endif |
| 286 | local_flush_page_to_ram(page); |
| 287 | } |
| 288 | |
| 289 | void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) |
| 290 | { |
Rusty Russell | 81f1adf0 | 2009-03-16 14:40:39 +1030 | [diff] [blame] | 291 | cpumask_t cpu_mask = *mm_cpumask(mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | cpu_clear(smp_processor_id(), cpu_mask); |
| 293 | if (!cpus_empty(cpu_mask)) |
| 294 | xc2((smpfunc_t) BTFIXUP_CALL(local_flush_sig_insns), (unsigned long) mm, insn_addr); |
| 295 | local_flush_sig_insns(mm, insn_addr); |
| 296 | } |
| 297 | |
| 298 | extern unsigned int lvl14_resolution; |
| 299 | |
| 300 | /* /proc/profile writes can call this, don't __init it please. */ |
| 301 | static DEFINE_SPINLOCK(prof_setup_lock); |
| 302 | |
| 303 | int setup_profiling_timer(unsigned int multiplier) |
| 304 | { |
| 305 | int i; |
| 306 | unsigned long flags; |
| 307 | |
| 308 | /* Prevent level14 ticker IRQ flooding. */ |
| 309 | if((!multiplier) || (lvl14_resolution / multiplier) < 500) |
| 310 | return -EINVAL; |
| 311 | |
| 312 | spin_lock_irqsave(&prof_setup_lock, flags); |
KAMEZAWA Hiroyuki | fff8efe | 2006-04-10 22:52:51 -0700 | [diff] [blame] | 313 | for_each_possible_cpu(i) { |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 314 | load_profile_irq(i, lvl14_resolution / multiplier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | prof_multiplier(i) = multiplier; |
| 316 | } |
| 317 | spin_unlock_irqrestore(&prof_setup_lock, flags); |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 322 | void __init smp_prepare_cpus(unsigned int max_cpus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
Al Viro | b4cff84 | 2007-02-01 13:52:33 +0000 | [diff] [blame] | 324 | extern void __init smp4m_boot_cpus(void); |
| 325 | extern void __init smp4d_boot_cpus(void); |
Bob Breuer | 7202fb4 | 2006-06-20 00:30:31 -0700 | [diff] [blame] | 326 | int i, cpuid, extra; |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 327 | |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 328 | printk("Entering SMP Mode...\n"); |
| 329 | |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 330 | extra = 0; |
| 331 | for (i = 0; !cpu_find_by_instance(i, NULL, &cpuid); i++) { |
Bob Breuer | 7202fb4 | 2006-06-20 00:30:31 -0700 | [diff] [blame] | 332 | if (cpuid >= NR_CPUS) |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 333 | extra++; |
| 334 | } |
Bob Breuer | 7202fb4 | 2006-06-20 00:30:31 -0700 | [diff] [blame] | 335 | /* i = number of cpus */ |
| 336 | if (extra && max_cpus > i - extra) |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 337 | printk("Warning: NR_CPUS is too low to start all cpus\n"); |
| 338 | |
| 339 | smp_store_cpu_info(boot_cpu_id); |
| 340 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 341 | switch(sparc_cpu_model) { |
| 342 | case sun4: |
| 343 | printk("SUN4\n"); |
| 344 | BUG(); |
| 345 | break; |
| 346 | case sun4c: |
| 347 | printk("SUN4C\n"); |
| 348 | BUG(); |
| 349 | break; |
| 350 | case sun4m: |
| 351 | smp4m_boot_cpus(); |
| 352 | break; |
| 353 | case sun4d: |
| 354 | smp4d_boot_cpus(); |
| 355 | break; |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 356 | case sparc_leon: |
| 357 | leon_boot_cpus(); |
| 358 | break; |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 359 | case sun4e: |
| 360 | printk("SUN4E\n"); |
| 361 | BUG(); |
| 362 | break; |
| 363 | case sun4u: |
| 364 | printk("SUN4U\n"); |
| 365 | BUG(); |
| 366 | break; |
| 367 | default: |
| 368 | printk("UNKNOWN!\n"); |
| 369 | BUG(); |
| 370 | break; |
| 371 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | } |
| 373 | |
Bob Breuer | 7202fb4 | 2006-06-20 00:30:31 -0700 | [diff] [blame] | 374 | /* Set this up early so that things like the scheduler can init |
| 375 | * properly. We use the same cpu mask for both the present and |
| 376 | * possible cpu map. |
| 377 | */ |
| 378 | void __init smp_setup_cpu_possible_map(void) |
| 379 | { |
| 380 | int instance, mid; |
| 381 | |
| 382 | instance = 0; |
| 383 | while (!cpu_find_by_instance(instance, NULL, &mid)) { |
| 384 | if (mid < NR_CPUS) { |
Rusty Russell | fe73971 | 2009-03-16 14:40:22 +1030 | [diff] [blame] | 385 | set_cpu_possible(mid, true); |
| 386 | set_cpu_present(mid, true); |
Bob Breuer | 7202fb4 | 2006-06-20 00:30:31 -0700 | [diff] [blame] | 387 | } |
| 388 | instance++; |
| 389 | } |
| 390 | } |
| 391 | |
Bob Breuer | 92d452f | 2006-06-20 00:36:10 -0700 | [diff] [blame] | 392 | void __init smp_prepare_boot_cpu(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 394 | int cpuid = hard_smp_processor_id(); |
| 395 | |
| 396 | if (cpuid >= NR_CPUS) { |
| 397 | prom_printf("Serious problem, boot cpu id >= NR_CPUS\n"); |
| 398 | prom_halt(); |
| 399 | } |
| 400 | if (cpuid != 0) |
| 401 | printk("boot cpu id != 0, this could work but is untested\n"); |
| 402 | |
| 403 | current_thread_info()->cpu = cpuid; |
Rusty Russell | fe73971 | 2009-03-16 14:40:22 +1030 | [diff] [blame] | 404 | set_cpu_online(cpuid, true); |
| 405 | set_cpu_possible(cpuid, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Bob Breuer | 92d452f | 2006-06-20 00:36:10 -0700 | [diff] [blame] | 408 | int __cpuinit __cpu_up(unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | { |
Al Viro | b4cff84 | 2007-02-01 13:52:33 +0000 | [diff] [blame] | 410 | extern int __cpuinit smp4m_boot_one_cpu(int); |
| 411 | extern int __cpuinit smp4d_boot_one_cpu(int); |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 412 | int ret=0; |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 413 | |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 414 | switch(sparc_cpu_model) { |
| 415 | case sun4: |
| 416 | printk("SUN4\n"); |
| 417 | BUG(); |
| 418 | break; |
| 419 | case sun4c: |
| 420 | printk("SUN4C\n"); |
| 421 | BUG(); |
| 422 | break; |
| 423 | case sun4m: |
| 424 | ret = smp4m_boot_one_cpu(cpu); |
| 425 | break; |
| 426 | case sun4d: |
| 427 | ret = smp4d_boot_one_cpu(cpu); |
| 428 | break; |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 429 | case sparc_leon: |
| 430 | ret = leon_boot_one_cpu(cpu); |
| 431 | break; |
Raymond Burns | 8b3c848 | 2006-07-17 21:57:09 -0700 | [diff] [blame] | 432 | case sun4e: |
| 433 | printk("SUN4E\n"); |
| 434 | BUG(); |
| 435 | break; |
| 436 | case sun4u: |
| 437 | printk("SUN4U\n"); |
| 438 | BUG(); |
| 439 | break; |
| 440 | default: |
| 441 | printk("UNKNOWN!\n"); |
| 442 | BUG(); |
| 443 | break; |
| 444 | }; |
Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 445 | |
| 446 | if (!ret) { |
| 447 | cpu_set(cpu, smp_commenced_mask); |
| 448 | while (!cpu_online(cpu)) |
| 449 | mb(); |
| 450 | } |
| 451 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | void smp_bogo(struct seq_file *m) |
| 455 | { |
| 456 | int i; |
| 457 | |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 458 | for_each_online_cpu(i) { |
| 459 | seq_printf(m, |
| 460 | "Cpu%dBogo\t: %lu.%02lu\n", |
| 461 | i, |
| 462 | cpu_data(i).udelay_val/(500000/HZ), |
| 463 | (cpu_data(i).udelay_val/(5000/HZ))%100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
| 467 | void smp_info(struct seq_file *m) |
| 468 | { |
| 469 | int i; |
| 470 | |
| 471 | seq_printf(m, "State:\n"); |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 472 | for_each_online_cpu(i) |
| 473 | seq_printf(m, "CPU%d\t\t: online\n", i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |