-static void __devinit smp_openpic_setup_cpu(int cpu)
-{
- do_openpic_setup_cpu();
-}
-
-#endif /* CONFIG_PPC_MULTIPLATFORM */
-
-#ifdef CONFIG_PPC_PSERIES
-
-/* Get state of physical CPU.
- * Return codes:
- * 0 - The processor is in the RTAS stopped state
- * 1 - stop-self is in progress
- * 2 - The processor is not in the RTAS stopped state
- * -1 - Hardware Error
- * -2 - Hardware Busy, Try again later.
- */
-int query_cpu_stopped(unsigned int pcpu)
-{
- int cpu_status;
- int status, qcss_tok;
-
- DBG(" -> query_cpu_stopped(%d)\n", pcpu);
- qcss_tok = rtas_token("query-cpu-stopped-state");
- if (qcss_tok == RTAS_UNKNOWN_SERVICE)
- return -1;
- status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
- if (status != 0) {
- printk(KERN_ERR
- "RTAS query-cpu-stopped-state failed: %i\n", status);
- return status;
- }
-
- DBG(" <- query_cpu_stopped(), status: %d\n", cpu_status);
-
- return cpu_status;
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-
-int __cpu_disable(void)
-{
- /* FIXME: go put this in a header somewhere */
- extern void xics_migrate_irqs_away(void);
-
- systemcfg->processorCount--;
-
- /*fix boot_cpuid here*/
- if (smp_processor_id() == boot_cpuid)
- boot_cpuid = any_online_cpu(cpu_online_map);
-
- /* FIXME: abstract this to not be platform specific later on */
- xics_migrate_irqs_away();
- return 0;
-}
-
-void __cpu_die(unsigned int cpu)
-{
- int tries;
- int cpu_status;
- unsigned int pcpu = get_hard_smp_processor_id(cpu);
-
- for (tries = 0; tries < 25; tries++) {
- cpu_status = query_cpu_stopped(pcpu);
- if (cpu_status == 0 || cpu_status == -1)
- break;
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(HZ/5);
- }
- if (cpu_status != 0) {
- printk("Querying DEAD? cpu %i (%i) shows %i\n",
- cpu, pcpu, cpu_status);
- }
-
- /* Isolation and deallocation are definatly done by
- * drslot_chrp_cpu. If they were not they would be
- * done here. Change isolate state to Isolate and
- * change allocation-state to Unusable.
- */
- paca[cpu].cpu_start = 0;
-
- /* So we can recognize if it fails to come up next time. */
- cpu_callin_map[cpu] = 0;
-}
-
-/* Kill this cpu */
-void cpu_die(void)
-{
- local_irq_disable();
- /* Some hardware requires clearing the CPPR, while other hardware does not
- * it is safe either way
- */
- pSeriesLP_cppr_info(0, 0);
- rtas_stop_self();
- /* Should never get here... */
- BUG();
- for(;;);
-}
-
-/* Search all cpu device nodes for an offline logical cpu. If a
- * device node has a "ibm,my-drc-index" property (meaning this is an
- * LPAR), paranoid-check whether we own the cpu. For each "thread"
- * of a cpu, if it is offline and has the same hw index as before,
- * grab that in preference.
- */
-static unsigned int find_physical_cpu_to_start(unsigned int old_hwindex)
-{
- struct device_node *np = NULL;
- unsigned int best = -1U;
-
- while ((np = of_find_node_by_type(np, "cpu"))) {
- int nr_threads, len;
- u32 *index = (u32 *)get_property(np, "ibm,my-drc-index", NULL);
- u32 *tid = (u32 *)
- get_property(np, "ibm,ppc-interrupt-server#s", &len);
-
- if (!tid)
- tid = (u32 *)get_property(np, "reg", &len);
-
- if (!tid)
- continue;
-
- /* If there is a drc-index, make sure that we own
- * the cpu.
- */
- if (index) {
- int state;
- int rc = rtas_get_sensor(9003, *index, &state);
- if (rc != 0 || state != 1)
- continue;
- }
-
- nr_threads = len / sizeof(u32);
-
- while (nr_threads--) {
- if (0 == query_cpu_stopped(tid[nr_threads])) {
- best = tid[nr_threads];
- if (best == old_hwindex)
- goto out;
- }
- }
- }
-out:
- of_node_put(np);
- return best;
-}
-
-/**
- * smp_startup_cpu() - start the given cpu
- *
- * At boot time, there is nothing to do. At run-time, call RTAS with
- * the appropriate start location, if the cpu is in the RTAS stopped
- * state.
- *
- * Returns:
- * 0 - failure
- * 1 - success
- */
-static inline int __devinit smp_startup_cpu(unsigned int lcpu)
-{
- int status;
- unsigned long start_here = __pa((u32)*((unsigned long *)
- pseries_secondary_smp_init));
- unsigned int pcpu;
-
- /* At boot time the cpus are already spinning in hold
- * loops, so nothing to do. */
- if (system_state < SYSTEM_RUNNING)
- return 1;
-
- pcpu = find_physical_cpu_to_start(get_hard_smp_processor_id(lcpu));
- if (pcpu == -1U) {
- printk(KERN_INFO "No more cpus available, failing\n");
- return 0;
- }
-
- /* Fixup atomic count: it exited inside IRQ handler. */
- paca[lcpu].__current->thread_info->preempt_count = 0;
-
- /* At boot this is done in prom.c. */
- paca[lcpu].hw_cpu_id = pcpu;
-
- status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL,
- pcpu, start_here, lcpu);
- if (status != 0) {
- printk(KERN_ERR "start-cpu failed: %i\n", status);
- return 0;
- }
- return 1;
-}
-#else /* ... CONFIG_HOTPLUG_CPU */
-static inline int __devinit smp_startup_cpu(unsigned int lcpu)