/* * Cycle through the APs sending Wakeup IPIs to boot each. */ void __init smp_prepare_cpus (unsigned int max_cpus) { int boot_cpu_id = hard_smp_processor_id(); /* * Initialize the per-CPU profiling counter/multiplier */ smp_setup_percpu_timer(); cpu_set(0, cpu_callin_map); local_cpu_data->loops_per_jiffy = loops_per_jiffy; ia64_cpu_to_sapicid[0] = boot_cpu_id; printk(KERN_INFO "Boot processor id 0x%x/0x%x\n", 0, boot_cpu_id); current_thread_info()->cpu = 0; /* * If SMP should be disabled, then really disable it! */ if (!max_cpus) { printk(KERN_INFO "SMP mode deactivated.\n"); init_cpu_online(cpumask_of(0)); init_cpu_present(cpumask_of(0)); init_cpu_possible(cpumask_of(0)); return; } }
void __init platform_prepare_cpus(unsigned int max_cpus) { struct cpumask mask; bfin_relocate_coreb_l1_mem(); /* Both cores ought to be present on a bf561! */ cpumask_set_cpu(0, &mask); /* CoreA */ cpumask_set_cpu(1, &mask); /* CoreB */ init_cpu_present(&mask); }
void __init smp_prepare_cpus(unsigned int max_cpus) { unsigned int cpu = smp_processor_id(); init_new_context(current, &init_mm); current_thread_info()->cpu = cpu; mp_ops->prepare_cpus(max_cpus); #ifndef CONFIG_HOTPLUG_CPU init_cpu_present(cpu_possible_mask); #endif }
/* ** inventory.c:do_inventory() hasn't yet been run and thus we ** don't 'discover' the additional CPUs until later. */ void __init smp_prepare_cpus(unsigned int max_cpus) { int cpu; for_each_possible_cpu(cpu) spin_lock_init(&per_cpu(ipi_lock, cpu)); init_cpu_present(cpumask_of(0)); parisc_max_cpus = max_cpus; if (!max_cpus) printk(KERN_INFO "SMP mode deactivated.\n"); }
/* Update board cpu maps */ static void __init eznps_init_cpumasks(void) { struct cpumask cpumask; if (eznps_get_map("present-cpus", &cpumask)) { pr_err("Failed to get present-cpus from dtb"); return; } init_cpu_present(&cpumask); if (eznps_get_map("possible-cpus", &cpumask)) { pr_err("Failed to get possible-cpus from dtb"); return; } init_cpu_possible(&cpumask); }
/* Update board cpu maps */ static void __init eznps_set_maps(void) { struct cpumask cpumask_possible, cpumask_present; unsigned long dt_root = of_get_flat_dt_root(); if (eznps_get_map("present-cpus", &cpumask_present)) { pr_err("Failed to get present-cpus from dtb"); return; } init_cpu_present(&cpumask_present); if (eznps_get_map("possible-cpus", &cpumask_possible)) { pr_err("Failed to get possible-cpus from dtb"); return; } init_cpu_possible(&cpumask_possible); cpumask_copy(&_cpu_possible_mask, &cpumask_possible); if (of_get_flat_dt_prop(dt_root, "init-possible-as-present", NULL)) init_cpu_possible(&cpumask_present); }
/* * Initialize the logical CPU number to SAPICID mapping */ void __init smp_build_cpu_map (void) { int sapicid, cpu, i; int boot_cpu_id = hard_smp_processor_id(); for (cpu = 0; cpu < NR_CPUS; cpu++) { ia64_cpu_to_sapicid[cpu] = -1; } ia64_cpu_to_sapicid[0] = boot_cpu_id; init_cpu_present(cpumask_of(0)); set_cpu_possible(0, true); for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) { sapicid = smp_boot_data.cpu_phys_id[i]; if (sapicid == boot_cpu_id) continue; set_cpu_present(cpu, true); set_cpu_possible(cpu, true); ia64_cpu_to_sapicid[cpu] = sapicid; cpu++; } }
/*==========================================================================* * Name: smp_prepare_cpus (old smp_boot_cpus) * * Description: This routine boot up APs. * * Born on Date: 2002.02.05 * * Arguments: NONE * * Returns: void (cannot fail) * * Modification log: * Date Who Description * ---------- --- -------------------------------------------------------- * 2003-06-24 hy modify for linux-2.5.69 * *==========================================================================*/ void __init smp_prepare_cpus(unsigned int max_cpus) { int phys_id; unsigned long nr_cpu; nr_cpu = inl(M32R_FPGA_NUM_OF_CPUS_PORTL); if (nr_cpu > NR_CPUS) { printk(KERN_INFO "NUM_OF_CPUS reg. value [%ld] > NR_CPU [%d]", nr_cpu, NR_CPUS); goto smp_done; } for (phys_id = 0 ; phys_id < nr_cpu ; phys_id++) physid_set(phys_id, phys_cpu_present_map); #ifndef CONFIG_HOTPLUG_CPU init_cpu_present(cpu_possible_mask); #endif show_mp_info(nr_cpu); init_ipi_lock(); /* * Setup boot CPU information */ smp_store_cpu_info(0); /* Final full version of the data */ /* * If SMP should be disabled, then really disable it! */ if (!max_cpus) { printk(KERN_INFO "SMP mode deactivated by commandline.\n"); goto smp_done; } /* * Now scan the CPU present map and fire up the other CPUs. */ Dprintk("CPU present map : %lx\n", physids_coerce(phys_cpu_present_map)); for (phys_id = 0 ; phys_id < NR_CPUS ; phys_id++) { /* * Don't even attempt to start the boot CPU! */ if (phys_id == bsp_phys_id) continue; if (!physid_isset(phys_id, phys_cpu_present_map)) continue; if (max_cpus <= cpucount + 1) continue; do_boot_cpu(phys_id); /* * Make sure we unmap all failed CPUs */ if (physid_to_cpu(phys_id) == -1) { physid_clear(phys_id, phys_cpu_present_map); printk("phys CPU#%d not responding - " \ "cannot use it.\n", phys_id); } } smp_done: Dprintk("Boot done.\n"); }
/* * Called at the top of init() to launch all the other CPUs. * They run free to complete their initialization and then wait * until they get an IPI from the boot cpu to come online. */ void __init smp_prepare_cpus(unsigned int max_cpus) { long rc; int cpu, cpu_count; int boot_cpu = smp_processor_id(); current_thread_info()->cpu = boot_cpu; /* * Pin this task to the boot CPU while we bring up the others, * just to make sure we don't uselessly migrate as they come up. */ rc = sched_setaffinity(current->pid, cpumask_of(boot_cpu)); if (rc != 0) pr_err("Couldn't set init affinity to boot cpu (%ld)\n", rc); /* Print information about disabled and dataplane cpus. */ print_disabled_cpus(); /* * Tell the messaging subsystem how to respond to the * startup message. We use a level of indirection to avoid * confusing the linker with the fact that the messaging * subsystem is calling __init code. */ start_cpu_function_addr = (unsigned long) &online_secondary; /* Set up thread context for all new processors. */ cpu_count = 1; for (cpu = 0; cpu < NR_CPUS; ++cpu) { struct task_struct *idle; if (cpu == boot_cpu) continue; if (!cpu_possible(cpu)) { /* * Make this processor do nothing on boot. * Note that we don't give the boot_pc function * a stack, so it has to be assembly code. */ per_cpu(boot_sp, cpu) = 0; per_cpu(boot_pc, cpu) = (unsigned long) smp_nap; continue; } /* Create a new idle thread to run start_secondary() */ idle = fork_idle(cpu); if (IS_ERR(idle)) panic("failed fork for CPU %d", cpu); idle->thread.pc = (unsigned long) start_secondary; /* Make this thread the boot thread for this processor */ per_cpu(boot_sp, cpu) = task_ksp0(idle); per_cpu(boot_pc, cpu) = idle->thread.pc; ++cpu_count; } BUG_ON(cpu_count > (max_cpus ? max_cpus : 1)); /* Fire up the other tiles, if any */ init_cpu_present(cpu_possible_mask); if (cpumask_weight(cpu_present_mask) > 1) { mb(); /* make sure all data is visible to new processors */ hv_start_all_tiles(); } }