vserver 1.9.3
[linux-2.6.git] / arch / i386 / mach-voyager / voyager_smp.c
index 2bdc18f..7cb7e80 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/desc.h>
 #include <asm/voyager.h>
 #include <asm/vic.h>
-#include <asm/pgalloc.h>
 #include <asm/mtrr.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
@@ -36,7 +35,7 @@
 int reboot_smp = 0;
 
 /* TLB state -- visible externally, indexed physically */
-struct tlb_state cpu_tlbstate[NR_CPUS] __cacheline_aligned = {[0 ... NR_CPUS-1] = { &init_mm, 0 }};
+DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) ____cacheline_aligned = { &init_mm, 0 };
 
 /* CPU IRQ affinity -- set to all ones initially */
 static unsigned long cpu_irq_affinity[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1]  = ~0UL };
@@ -154,7 +153,7 @@ static inline void
 send_CPI_allbutself(__u8 cpi)
 {
        __u8 cpu = smp_processor_id();
-       __u32 mask = cpus_coerce(cpu_online_map) & ~(1 << cpu);
+       __u32 mask = cpus_addr(cpu_online_map)[0] & ~(1 << cpu);
        send_CPI(mask, cpi);
 }
 
@@ -403,11 +402,11 @@ find_smp_config(void)
        /* set up everything for just this CPU, we can alter
         * this as we start the other CPUs later */
        /* now get the CPU disposition from the extended CMOS */
-       phys_cpu_present_map = cpus_promote(voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK));
-       cpus_coerce(phys_cpu_present_map) |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 1) << 8;
-       cpus_coerce(phys_cpu_present_map) |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 2) << 16;
-       cpus_coerce(phys_cpu_present_map) |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 3) << 24;
-       printk("VOYAGER SMP: phys_cpu_present_map = 0x%lx\n", cpus_coerce(phys_cpu_present_map));
+       cpus_addr(phys_cpu_present_map)[0] = voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK);
+       cpus_addr(phys_cpu_present_map)[0] |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 1) << 8;
+       cpus_addr(phys_cpu_present_map)[0] |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 2) << 16;
+       cpus_addr(phys_cpu_present_map)[0] |= voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 3) << 24;
+       printk("VOYAGER SMP: phys_cpu_present_map = 0x%lx\n", cpus_addr(phys_cpu_present_map)[0]);
        /* Here we set up the VIC to enable SMP */
        /* enable the CPIs by writing the base vector to their register */
        outb(VIC_DEFAULT_CPI_BASE, VIC_CPI_BASE_REGISTER);
@@ -524,15 +523,6 @@ start_secondary(void *unused)
        return cpu_idle();
 }
 
-static struct task_struct * __init
-fork_by_hand(void)
-{
-       struct pt_regs regs;
-       /* don't care about the eip and regs settings since we'll
-        * never reschedule the forked task. */
-       return copy_process(CLONE_VM|CLONE_IDLETASK, 0, &regs, 0, NULL, NULL);
-}
-
 
 /* Routine to kick start the given CPU and wait for it to report ready
  * (or timeout in startup).  When this routine returns, the requested
@@ -588,16 +578,10 @@ do_boot_cpu(__u8 cpu)
        hijack_source.idt.Segment = (start_phys_address >> 4) & 0xFFFF;
 
        cpucount++;
-       idle = fork_by_hand();
+       idle = fork_idle(cpu);
        if(IS_ERR(idle))
                panic("failed fork for CPU%d", cpu);
-
-       wake_up_forked_process(idle);
-
-       init_idle(idle, cpu);
-
        idle->thread.eip = (unsigned long) start_secondary;
-       unhash_process(idle);
        /* init_tasks (in sched.c) is indexed logically */
        stack_start.esp = (void *) idle->thread.esp;
 
@@ -707,12 +691,12 @@ smp_boot_cpus(void)
                /* now that the cat has probed the Voyager System Bus, sanity
                 * check the cpu map */
                if( ((voyager_quad_processors | voyager_extended_vic_processors)
-                    & cpus_coerce(phys_cpu_present_map)) != cpus_coerce(phys_cpu_present_map)) {
+                    & cpus_addr(phys_cpu_present_map)[0]) != cpus_addr(phys_cpu_present_map)[0]) {
                        /* should panic */
                        printk("\n\n***WARNING*** Sanity check of CPU present map FAILED\n");
                }
        } else if(voyager_level == 4)
-               voyager_extended_vic_processors = cpus_coerce(phys_cpu_present_map);
+               voyager_extended_vic_processors = cpus_addr(phys_cpu_present_map)[0];
 
        /* this sets up the idle task to run on the current cpu */
        voyager_extended_cpus = 1;
@@ -861,9 +845,9 @@ static spinlock_t tlbstate_lock = SPIN_LOCK_UNLOCKED;
 static inline void
 leave_mm (unsigned long cpu)
 {
-       if (cpu_tlbstate[cpu].state == TLBSTATE_OK)
+       if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK)
                BUG();
-       cpu_clear(cpu,  cpu_tlbstate[cpu].active_mm->cpu_vm_mask);
+       cpu_clear(cpu, per_cpu(cpu_tlbstate, cpu).active_mm->cpu_vm_mask);
        load_cr3(swapper_pg_dir);
 }
 
@@ -884,8 +868,8 @@ smp_invalidate_interrupt(void)
                smp_processor_id()));
        */
 
-       if (flush_mm == cpu_tlbstate[cpu].active_mm) {
-               if (cpu_tlbstate[cpu].state == TLBSTATE_OK) {
+       if (flush_mm == per_cpu(cpu_tlbstate, cpu).active_mm) {
+               if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK) {
                        if (flush_va == FLUSH_ALL)
                                local_flush_tlb();
                        else
@@ -910,7 +894,7 @@ flush_tlb_others (unsigned long cpumask, struct mm_struct *mm,
 
        if (!cpumask)
                BUG();
-       if ((cpumask & cpus_coerce(cpu_online_map)) != cpumask)
+       if ((cpumask & cpus_addr(cpu_online_map)[0]) != cpumask)
                BUG();
        if (cpumask & (1 << smp_processor_id()))
                BUG();
@@ -953,7 +937,7 @@ flush_tlb_current_task(void)
 
        preempt_disable();
 
-       cpu_mask = cpus_coerce(mm->cpu_vm_mask) & ~(1 << smp_processor_id());
+       cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
        local_flush_tlb();
        if (cpu_mask)
                flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
@@ -969,7 +953,7 @@ flush_tlb_mm (struct mm_struct * mm)
 
        preempt_disable();
 
-       cpu_mask = cpus_coerce(mm->cpu_vm_mask) & ~(1 << smp_processor_id());
+       cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
 
        if (current->active_mm == mm) {
                if (current->mm)
@@ -990,7 +974,7 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
 
        preempt_disable();
 
-       cpu_mask = cpus_coerce(mm->cpu_vm_mask) & ~(1 << smp_processor_id());
+       cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
        if (current->active_mm == mm) {
                if(current->mm)
                        __flush_tlb_one(va);
@@ -1099,7 +1083,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry,
                   int wait)
 {
        struct call_data_struct data;
-       __u32 mask = cpus_coerce(cpu_online_map);
+       __u32 mask = cpus_addr(cpu_online_map)[0];
 
        mask &= ~(1<<smp_processor_id());
 
@@ -1219,7 +1203,7 @@ do_flush_tlb_all(void* info)
        unsigned long cpu = smp_processor_id();
 
        __flush_tlb_all();
-       if (cpu_tlbstate[cpu].state == TLBSTATE_LAZY)
+       if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_LAZY)
                leave_mm(cpu);
 }
 
@@ -1303,8 +1287,7 @@ smp_local_timer_interrupt(struct pt_regs * regs)
        int cpu = smp_processor_id();
        long weight;
 
-       x86_do_profile(regs);
-
+       profile_tick(CPU_PROFILING, regs);
        if (--per_cpu(prof_counter, cpu) <= 0) {
                /*
                 * The multiplier may have changed since the last time we got
@@ -1790,9 +1773,9 @@ set_vic_irq_affinity(unsigned int irq, cpumask_t mask)
        unsigned long irq_mask = 1 << irq;
        int cpu;
 
-       real_mask = cpus_coerce(mask) & voyager_extended_vic_processors;
+       real_mask = cpus_addr(mask)[0] & voyager_extended_vic_processors;
        
-       if(cpus_coerce(mask) == 0)
+       if(cpus_addr(mask)[0] == 0)
                /* can't have no cpu's to accept the interrupt -- extremely
                 * bad things will happen */
                return;