1 /* 2 * arch/s390/kernel/smp.c 3 * 4 * Copyright (C) IBM Corp. 1999,2006 5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 6 * Martin Schwidefsky (schwidefsky@de.ibm.com) 7 * Heiko Carstens (heiko.carstens@de.ibm.com) 8 * 9 * based on other smp stuff by 10 * (c) 1995 Alan Cox, CymruNET Ltd <alan@cymru.net> 11 * (c) 1998 Ingo Molnar 12 * 13 * We work with logical cpu numbering everywhere we can. The only 14 * functions using the real cpu address (got from STAP) are the sigp 15 * functions. For all other functions we use the identity mapping. 16 * That means that cpu_number_map[i] == i for every cpu. cpu_number_map is 17 * used e.g. to find the idle task belonging to a logical cpu. Every array 18 * in the kernel is sorted by the logical cpu number and not by the physical 19 * one which is causing all the confusion with __cpu_logical_map and 20 * cpu_number_map in other architectures. 21 */ 22 23 #include <linux/module.h> 24 #include <linux/init.h> 25 #include <linux/mm.h> 26 #include <linux/spinlock.h> 27 #include <linux/kernel_stat.h> 28 #include <linux/smp_lock.h> 29 #include <linux/delay.h> 30 #include <linux/cache.h> 31 #include <linux/interrupt.h> 32 #include <linux/cpu.h> 33 #include <linux/timex.h> 34 #include <asm/setup.h> 35 #include <asm/sigp.h> 36 #include <asm/pgalloc.h> 37 #include <asm/irq.h> 38 #include <asm/s390_ext.h> 39 #include <asm/cpcmd.h> 40 #include <asm/tlbflush.h> 41 #include <asm/timer.h> 42 43 extern volatile int __cpu_logical_map[]; 44 45 /* 46 * An array with a pointer the lowcore of every CPU. 47 */ 48 49 struct _lowcore *lowcore_ptr[NR_CPUS]; 50 51 cpumask_t cpu_online_map = CPU_MASK_NONE; 52 cpumask_t cpu_possible_map = CPU_MASK_NONE; 53 54 static struct task_struct *current_set[NR_CPUS]; 55 56 static void smp_ext_bitcall(int, ec_bit_sig); 57 static void smp_ext_bitcall_others(ec_bit_sig); 58 59 /* 60 5B * Structure and data for smp_call_function(). This is designed to minimise 61 * static memory requirements. It also looks cleaner. 62 */ 63 static DEFINE_SPINLOCK(call_lock); 64 65 struct call_data_struct { 66 void (*func) (void *info); 67 void *info; 68 atomic_t started; 69 atomic_t finished; 70 int wait; 71 }; 72 73 static struct call_data_struct * call_data; 74 75 /* 76 * 'Call function' interrupt callback 77 */ 78 static void do_call_function(void) 79 { 80 void (*func) (void *info) = call_data->func; 81 void *info = call_data->info; 82 int wait = call_data->wait; 83 84 atomic_inc(&call_data->started); 85 (*func)(info); 86 if (wait) 87 atomic_inc(&call_data->finished); 88 } 89 90 /* 91 * this function sends a 'generic call function' IPI to all other CPUs 92 * in the system. 93 */ 94 95 int smp_call_function (void (*func) (void *info), void *info, int nonatomic, 96 int wait) 97 /* 98 * [SUMMARY] Run a function on all other CPUs. 99 * <func> The function to run. This must be fast and non-blocking. 100 * <info> An arbitrary pointer to pass to the function. 101 * <nonatomic> currently unused. 102 * <wait> If true, wait (atomically) until function has completed on other CPUs. 103 * [RETURNS] 0 on success, else a negative status code. Does not return until 104 * remote CPUs are nearly ready to execute <<func>> or are or have executed. 105 * 106 * You must not call this function with disabled interrupts or from a 107 * hardware interrupt handler or from a bottom half handler. 108 */ 109 { 110 struct call_data_struct data; 111 int cpus = num_online_cpus()-1; 112 113 if (cpus <= 0) 114 return 0; 115 116 /* Can deadlock when called with interrupts disabled */ 117 WARN_ON(irqs_disabled()); 118 119 data.func = func; 120 data.info = info; 121 atomic_set(&data.started, 0); 122 data.wait = wait; 123 if (wait) 124 atomic_set(&data.finished, 0); 125 126 spin_lock(&call_lock); 127 call_data = &data; 128 /* Send a message to all other CPUs and wait for them to respond */ 129 smp_ext_bitcall_others(ec_call_function); 130 131 /* Wait for response */ 132 while (atomic_read(&data.started) != cpus) 133 cpu_relax(); 134 135 if (wait) 136 while (atomic_read(&data.finished) != cpus) 137 cpu_relax(); 138 spin_unlock(&call_lock); 139 140 return 0; 141 } 142 143 /* 144 * Call a function on one CPU 145 * cpu : the CPU the function should be executed on 146 * 147 * You must not call this function with disabled interrupts or from a 148 * hardware interrupt handler. You may call it from a bottom half. 149 * 150 * It is guaranteed that the called function runs on the specified CPU, 151 * preemption is disabled. 152 */ 153 int smp_call_function_on(void (*func) (void *info), void *info, 154 int nonatomic, int wait, int cpu) 155 { 156 struct call_data_struct data; 157 int curr_cpu; 158 159 if (!cpu_online(cpu)) 160 return -EINVAL; 161 162 /* disable preemption for local function call */ 163 curr_cpu = get_cpu(); 164 165 if (curr_cpu == cpu) { 166 /* direct call to function */ 167 func(info); 168 put_cpu(); 169 return 0; 170 } 171 172 data.func = func; 173 data.info = info; 174 atomic_set(&data.started, 0); 175 data.wait = wait; 176 if (wait) 177 atomic_set(&data.finished, 0); 178 179 spin_lock_bh(&call_lock); 180 call_data = &data; 181 smp_ext_bitcall(cpu, ec_call_function); 182 183 /* Wait for response */ 184 while (atomic_read(&data.started) != 1) 185 cpu_relax(); 186 187 if (wait) 188 while (atomic_read(&data.finished) != 1) 189 cpu_relax(); 190 191 spin_unlock_bh(&call_lock); 192 put_cpu(); 193 return 0; 194 } 195 EXPORT_SYMBOL(smp_call_function_on); 196 197 static void do_send_stop(void) 198 { 199 int cpu, rc; 200 201 /* stop all processors */ 202 for_each_online_cpu(cpu) { 203 if (cpu == smp_processor_id()) 204 continue; 205 do { 206 rc = signal_processor(cpu, sigp_stop); 207 } while (rc == sigp_busy); 208 } 209 } 210 211 static void do_store_status(void) 212 { 213 int cpu, rc; 214 215 /* store status of all processors in their lowcores (real 0) */ 216 for_each_online_cpu(cpu) { 217 if (cpu == smp_processor_id()) 218 continue; 219 do { 220 rc = signal_processor_p( 221 (__u32)(unsigned long) lowcore_ptr[cpu], cpu, 222 sigp_store_status_at_address); 223 } while(rc == sigp_busy); 224 } 225 } 226 227 static void do_wait_for_stop(void) 228 { 229 int cpu; 230 231 /* Wait for all other cpus to enter stopped state */ 232 for_each_online_cpu(cpu) { 233 if (cpu == smp_processor_id()) 234 continue; 235 while(!smp_cpu_not_running(cpu)) 236 cpu_relax(); 237 } 238 } 239 240 /* 241 * this function sends a 'stop' sigp to all other CPUs in the system. 242 * it goes straight through. 243 */ 244 void smp_send_stop(void) 245 { 246 /* Disable all interrupts/machine checks */ 247 __load_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK); 248 249 /* write magic number to zero page (absolute 0) */ 250 lowcore_ptr[smp_processor_id()]->panic_magic = __PANIC_MAGIC; 251 252 /* stop other processors. */ 253 do_send_stop(); 254 255 /* wait until other processors are stopped */ 256 do_wait_for_stop(); 257 258 /* store status of other processors. */ 259 do_store_status(); 260 } 261 262 /* 263 * Reboot, halt and power_off routines for SMP. 264 */ 265 266 void machine_restart_smp(char * __unused) 267 { 268 smp_send_stop(); 269 do_reipl(); 270 } 271 272 void machine_halt_smp(void) 273 { 274 smp_send_stop(); 275 if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0) 276 __cpcmd(vmhalt_cmd, NULL, 0, NULL); 277 signal_processor(smp_processor_id(), sigp_stop_and_store_status); 278 for (;;); 279 } 280 281 void machine_power_off_smp(void) 282 { 283 smp_send_stop(); 284 if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0) 285 __cpcmd(vmpoff_cmd, NULL, 0, NULL); 286 signal_processor(smp_processor_id(), sigp_stop_and_store_status); 287 for (;;); 288 } 289 290 /* 291 * This is the main routine where commands issued by other 292 * cpus are handled. 293 */ 294 295 static void do_ext_call_interrupt(__u16 code) 296 { 297 unsigned long bits; 298 299 /* 300 * handle bit signal external calls 301 * 302 * For the ec_schedule signal we have to do nothing. All the work 303 * is done automatically when we return from the interrupt. 304 */ 305 bits = xchg(&S390_lowcore.ext_call_fast, 0); 306 307 if (test_bit(ec_call_function, &bits)) 308 do_call_function(); 309 } 310 311 /* 312 * Send an external call sigp to another cpu and return without waiting 313 * for its completion. 314 */ 315 static void smp_ext_bitcall(int cpu, ec_bit_sig sig) 316 { 317 /* 318 * Set signaling bit in lowcore of target cpu and kick it 319 */ 320 set_bit(sig, (unsigned long *) &lowcore_ptr[cpu]->ext_call_fast); 321 while(signal_processor(cpu, sigp_emergency_signal) == sigp_busy) 322 udelay(10); 323 } 324 325 /* 326 * Send an external call sigp to every other cpu in the system and 327 * return without waiting for its completion. 328 */ 329 static void smp_ext_bitcall_others(ec_bit_sig sig) 330 { 331 int cpu; 332 333 for_each_online_cpu(cpu) { 334 if (cpu == smp_processor_id()) 335 continue; 336 /* 337 * Set signaling bit in lowcore of target cpu and kick it 338 */ 339 set_bit(sig, (unsigned long *) &lowcore_ptr[cpu]->ext_call_fast); 340 while (signal_processor(cpu, sigp_emergency_signal) == sigp_busy) 341 udelay(10); 342 } 343 } 344 345 #ifndef CONFIG_64BIT 346 /* 347 * this function sends a 'purge tlb' signal to another CPU. 348 */ 349 void smp_ptlb_callback(void *info) 350 { 351 local_flush_tlb(); 352 } 353 354 void smp_ptlb_all(void) 355 { 356 on_each_cpu(smp_ptlb_callback, NULL, 0, 1); 357 } 358 EXPORT_SYMBOL(smp_ptlb_all); 359 #endif /* ! CONFIG_64BIT */ 360 361 /* 362 * this function sends a 'reschedule' IPI to another CPU. 363 * it goes straight through and wastes no time serializing 364 * anything. Worst case is that we lose a reschedule ... 365 */ 366 void smp_send_reschedule(int cpu) 367 { 368 smp_ext_bitcall(cpu, ec_schedule); 369 } 370 371 /* 372 * parameter area for the set/clear control bit callbacks 373 */ 374 struct ec_creg_mask_parms { 375 unsigned long orvals[16]; 376 unsigned long andvals[16]; 377 }; 378 379 /* 380 * callback for setting/clearing control bits 381 */ 382 static void smp_ctl_bit_callback(void *info) { 383 struct ec_creg_mask_parms *pp = info; 384 unsigned long cregs[16]; 385 int i; 386 387 __ctl_store(cregs, 0, 15); 388 for (i = 0; i <= 15; i++) 389 cregs[i] = (cregs[i] & pp->andvals[i]) | pp->orvals[i]; 390 __ctl_load(cregs, 0, 15); 391 } 392 393 /* 394 * Set a bit in a control register of all cpus 395 */ 396 void smp_ctl_set_bit(int cr, int bit) 397 { 398 struct ec_creg_mask_parms parms; 399 400 memset(&parms.orvals, 0, sizeof(parms.orvals)); 401 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 402 parms.orvals[cr] = 1 << bit; 403 on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); 404 } 405 406 /* 407 * Clear a bit in a control register of all cpus 408 */ 409 void smp_ctl_clear_bit(int cr, int bit) 410 { 411 struct ec_creg_mask_parms parms; 412 413 memset(&parms.orvals, 0, sizeof(parms.orvals)); 414 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 415 parms.andvals[cr] = ~(1L << bit); 416 on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); 417 } 418 419 /* 420 * Lets check how many CPUs we have. 421 */ 422 423 static unsigned int 424 __init smp_count_cpus(void) 425 { 426 unsigned int cpu, num_cpus; 427 __u16 boot_cpu_addr; 428 429 /* 430 * cpu 0 is the boot cpu. See smp_prepare_boot_cpu. 431 */ 432 433 boot_cpu_addr = S390_lowcore.cpu_data.cpu_addr; 434 current_thread_info()->cpu = 0; 435 num_cpus = 1; 436 for (cpu = 0; cpu <= 65535; cpu++) { 437 if ((__u16) cpu == boot_cpu_addr) 438 continue; 439 __cpu_logical_map[1] = (__u16) cpu; 440 if (signal_processor(1, sigp_sense) == 441 sigp_not_operational) 442 continue; 443 num_cpus++; 444 } 445 446 printk("Detected %d CPU's\n",(int) num_cpus); 447 printk("Boot cpu address %2X\n", boot_cpu_addr); 448 449 return num_cpus; 450 } 451 452 /* 453 * Activate a secondary processor. 454 */ 455 int __devinit start_secondary(void *cpuvoid) 456 { 457 /* Setup the cpu */ 458 cpu_init(); 459 preempt_disable(); 460 /* Enable TOD clock interrupts on the secondary cpu. */ 461 init_cpu_timer(); 462 #ifdef CONFIG_VIRT_TIMER 463 /* Enable cpu timer interrupts on the secondary cpu. */ 464 init_cpu_vtimer(); 465 #endif 466 /* Enable pfault pseudo page faults on this cpu. */ 467 pfault_init(); 468 469 /* Mark this cpu as online */ 470 cpu_set(smp_processor_id(), cpu_online_map); 471 /* Switch on interrupts */ 472 local_irq_enable(); 473 /* Print info about this processor */ 474 print_cpu_info(&S390_lowcore.cpu_data); 475 /* cpu_idle will call schedule for us */ 476 cpu_idle(); 477 return 0; 478 } 479 480 static void __init smp_create_idle(unsigned int cpu) 481 { 482 struct task_struct *p; 483 484 /* 485 * don't care about the psw and regs settings since we'll never 486 * reschedule the forked task. 487 */ 488 p = fork_idle(cpu); 489 if (IS_ERR(p)) 490 panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); 491 current_set[cpu] = p; 492 } 493 494 /* Reserving and releasing of CPUs */ 495 496 static DEFINE_SPINLOCK(smp_reserve_lock); 497 static int smp_cpu_reserved[NR_CPUS]; 498 499 int 500 smp_get_cpu(cpumask_t cpu_mask) 501 { 502 unsigned long flags; 503 int cpu; 504 505 spin_lock_irqsave(&smp_reserve_lock, flags); 506 /* Try to find an already reserved cpu. */ 507 for_each_cpu_mask(cpu, cpu_mask) { 508 if (smp_cpu_reserved[cpu] != 0) { 509 smp_cpu_reserved[cpu]++; 510 /* Found one. */ 511 goto out; 512 } 513 } 514 /* Reserve a new cpu from cpu_mask. */ 515 for_each_cpu_mask(cpu, cpu_mask) { 516 if (cpu_online(cpu)) { 517 smp_cpu_reserved[cpu]++; 518 goto out; 519 } 520 } 521 cpu = -ENODEV; 522 out: 523 spin_unlock_irqrestore(&smp_reserve_lock, flags); 524 return cpu; 525 } 526 527 void 528 smp_put_cpu(int cpu) 529 { 530 unsigned long flags; 531 532 spin_lock_irqsave(&smp_reserve_lock, flags); 533 smp_cpu_reserved[cpu]--; 534 spin_unlock_irqrestore(&smp_reserve_lock, flags); 535 } 536 537 static int 538 cpu_stopped(int cpu) 539 { 540 __u32 status; 541 542 /* Check for stopped state */ 543 if (signal_processor_ps(&status, 0, cpu, sigp_sense) == sigp_status_stored) { 544 if (status & 0x40) 545 return 1; 546 } 547 return 0; 548 } 549 550 /* Upping and downing of CPUs */ 551 552 int 553 __cpu_up(unsigned int cpu) 554 { 555 struct task_struct *idle; 556 struct _lowcore *cpu_lowcore; 557 struct stack_frame *sf; 558 sigp_ccode ccode; 559 int curr_cpu; 560 561 for (curr_cpu = 0; curr_cpu <= 65535; curr_cpu++) { 562 __cpu_logical_map[cpu] = (__u16) curr_cpu; 563 if (cpu_stopped(cpu)) 564 break; 565 } 566 567 if (!cpu_stopped(cpu)) 568 return -ENODEV; 569 570 ccode = signal_processor_p((__u32)(unsigned long)(lowcore_ptr[cpu]), 571 cpu, sigp_set_prefix); 572 if (ccode){ 573 printk("sigp_set_prefix failed for cpu %d " 574 "with condition code %d\n", 575 (int) cpu, (int) ccode); 576 return -EIO; 577 } 578 579 idle = current_set[cpu]; 580 cpu_lowcore = lowcore_ptr[cpu]; 581 cpu_lowcore->kernel_stack = (unsigned long) 582 task_stack_page(idle) + (THREAD_SIZE); 583 sf = (struct stack_frame *) (cpu_lowcore->kernel_stack 584 - sizeof(struct pt_regs) 585 - sizeof(struct stack_frame)); 586 memset(sf, 0, sizeof(struct stack_frame)); 587 sf->gprs[9] = (unsigned long) sf; 588 cpu_lowcore->save_area[15] = (unsigned long) sf; 589 __ctl_store(cpu_lowcore->cregs_save_area[0], 0, 15); 590 asm volatile( 591 " stam 0,15,0(%0)" 592 : : "a" (&cpu_lowcore->access_regs_save_area) : "memory"); 593 cpu_lowcore->percpu_offset = __per_cpu_offset[cpu]; 594 cpu_lowcore->current_task = (unsigned long) idle; 595 cpu_lowcore->cpu_data.cpu_nr = cpu; 596 eieio(); 597 598 while (signal_processor(cpu,sigp_restart) == sigp_busy) 599 udelay(10); 600 601 while (!cpu_online(cpu)) 602 cpu_relax(); 603 return 0; 604 } 605 606 static unsigned int __initdata additional_cpus; 607 static unsigned int __initdata possible_cpus; 608 609 void __init smp_setup_cpu_possible_map(void) 610 { 611 unsigned int phy_cpus, pos_cpus, cpu; 612 613 phy_cpus = smp_count_cpus(); 614 pos_cpus = min(phy_cpus + additional_cpus, (unsigned int) NR_CPUS); 615 616 if (possible_cpus) 617 pos_cpus = min(possible_cpus, (unsigned int) NR_CPUS); 618 619 for (cpu = 0; cpu < pos_cpus; cpu++) 620 cpu_set(cpu, cpu_possible_map); 621 622 phy_cpus = min(phy_cpus, pos_cpus); 623 624 for (cpu = 0; cpu < phy_cpus; cpu++) 625 cpu_set(cpu, cpu_present_map); 626 } 627 628 #ifdef CONFIG_HOTPLUG_CPU 629 630 static int __init setup_additional_cpus(char *s) 631 { 632 additional_cpus = simple_strtoul(s, NULL, 0); 633 return 0; 634 } 635 early_param("additional_cpus", setup_additional_cpus); 636 637 static int __init setup_possible_cpus(char *s) 638 { 639 possible_cpus = simple_strtoul(s, NULL, 0); 640 return 0; 641 } 642 early_param("possible_cpus", setup_possible_cpus); 643 644 int 645 __cpu_disable(void) 646 { 647 unsigned long flags; 648 struct ec_creg_mask_parms cr_parms; 649 int cpu = smp_processor_id(); 650 651 spin_lock_irqsave(&smp_reserve_lock, flags); 652 if (smp_cpu_reserved[cpu] != 0) { 653 spin_unlock_irqrestore(&smp_reserve_lock, flags); 654 return -EBUSY; 655 } 656 cpu_clear(cpu, cpu_online_map); 657 658 /* Disable pfault pseudo page faults on this cpu. */ 659 pfault_fini(); 660 661 memset(&cr_parms.orvals, 0, sizeof(cr_parms.orvals)); 662 memset(&cr_parms.andvals, 0xff, sizeof(cr_parms.andvals)); 663 664 /* disable all external interrupts */ 665 cr_parms.orvals[0] = 0; 666 cr_parms.andvals[0] = ~(1<<15 | 1<<14 | 1<<13 | 1<<12 | 667 1<<11 | 1<<10 | 1<< 6 | 1<< 4); 668 /* disable all I/O interrupts */ 669 cr_parms.orvals[6] = 0; 670 cr_parms.andvals[6] = ~(1<<31 | 1<<30 | 1<<29 | 1<<28 | 671 1<<27 | 1<<26 | 1<<25 | 1<<24); 672 /* disable most machine checks */ 673 cr_parms.orvals[14] = 0; 674 cr_parms.andvals[14] = ~(1<<28 | 1<<27 | 1<<26 | 1<<25 | 1<<24); 675 676 smp_ctl_bit_callback(&cr_parms); 677 678 spin_unlock_irqrestore(&smp_reserve_lock, flags); 679 return 0; 680 } 681 682 void 683 __cpu_die(unsigned int cpu) 684 { 685 /* Wait until target cpu is down */ 686 while (!smp_cpu_not_running(cpu)) 687 cpu_relax(); 688 printk("Processor %d spun down\n", cpu); 689 } 690 691 void 692 cpu_die(void) 693 { 694 idle_task_exit(); 695 signal_processor(smp_processor_id(), sigp_stop); 696 BUG(); 697 for(;;); 698 } 699 700 #endif /* CONFIG_HOTPLUG_CPU */ 701 702 /* 703 * Cycle through the processors and setup structures. 704 */ 705 706 void __init smp_prepare_cpus(unsigned int max_cpus) 707 { 708 unsigned long stack; 709 unsigned int cpu; 710 int i; 711 712 /* request the 0x1201 emergency signal external interrupt */ 713 if (register_external_interrupt(0x1201, do_ext_call_interrupt) != 0) 714 panic("Couldn't request external interrupt 0x1201"); 715 memset(lowcore_ptr,0,sizeof(lowcore_ptr)); 716 /* 717 * Initialize prefix pages and stacks for all possible cpus 718 */ 719 print_cpu_info(&S390_lowcore.cpu_data); 720 721 for_each_possible_cpu(i) { 722 lowcore_ptr[i] = (struct _lowcore *) 723 __get_free_pages(GFP_KERNEL|GFP_DMA, 724 sizeof(void*) == 8 ? 1 : 0); 725 stack = __get_free_pages(GFP_KERNEL,ASYNC_ORDER); 726 if (lowcore_ptr[i] == NULL || stack == 0ULL) 727 panic("smp_boot_cpus failed to allocate memory\n"); 728 729 *(lowcore_ptr[i]) = S390_lowcore; 730 lowcore_ptr[i]->async_stack = stack + (ASYNC_SIZE); 731 stack = __get_free_pages(GFP_KERNEL,0); 732 if (stack == 0ULL) 733 panic("smp_boot_cpus failed to allocate memory\n"); 734 lowcore_ptr[i]->panic_stack = stack + (PAGE_SIZE); 735 #ifndef CONFIG_64BIT 736 if (MACHINE_HAS_IEEE) { 737 lowcore_ptr[i]->extended_save_area_addr = 738 (__u32) __get_free_pages(GFP_KERNEL,0); 739 if (lowcore_ptr[i]->extended_save_area_addr == 0) 740 panic("smp_boot_cpus failed to " 741 "allocate memory\n"); 742 } 743 #endif 744 } 745 #ifndef CONFIG_64BIT 746 if (MACHINE_HAS_IEEE) 747 ctl_set_bit(14, 29); /* enable extended save area */ 748 #endif 749 set_prefix((u32)(unsigned long) lowcore_ptr[smp_processor_id()]); 750 751 for_each_possible_cpu(cpu) 752 if (cpu != smp_processor_id()) 753 smp_create_idle(cpu); 754 } 755 756 void __devinit smp_prepare_boot_cpu(void) 757 { 758 BUG_ON(smp_processor_id() != 0); 759 760 cpu_set(0, cpu_online_map); 761 S390_lowcore.percpu_offset = __per_cpu_offset[0]; 762 current_set[0] = current; 763 } 764 765 void smp_cpus_done(unsigned int max_cpus) 766 { 767 cpu_present_map = cpu_possible_map; 768 } 769 770 /* 771 * the frequency of the profiling timer can be changed 772 * by writing a multiplier value into /proc/profile. 773 * 774 * usually you want to run this on all CPUs ;) 775 */ 776 int setup_profiling_timer(unsigned int multiplier) 777 { 778 return 0; 779 } 780 781 static DEFINE_PER_CPU(struct cpu, cpu_devices); 782 783 static int __init topology_init(void) 784 { 785 int cpu; 786 int ret; 787 788 for_each_possible_cpu(cpu) { 789 struct cpu *c = &per_cpu(cpu_devices, cpu); 790 791 c->hotpluggable = 1; 792 ret = register_cpu(c, cpu); 793 if (ret) 794 printk(KERN_WARNING "topology_init: register_cpu %d " 795 "failed (%d)\n", cpu, ret); 796 } 797 return 0; 798 } 799 800 subsys_initcall(topology_init); 801 802 EXPORT_SYMBOL(cpu_online_map); 803 EXPORT_SYMBOL(cpu_possible_map); 804 EXPORT_SYMBOL(lowcore_ptr); 805 EXPORT_SYMBOL(smp_ctl_set_bit); 806 EXPORT_SYMBOL(smp_ctl_clear_bit); 807 EXPORT_SYMBOL(smp_call_function); 808 EXPORT_SYMBOL(smp_get_cpu); 809 EXPORT_SYMBOL(smp_put_cpu); 810