Merge ../linux-2.6/
[powerpc.git] / arch / x86_64 / kernel / smp.c
index 9db9dda..5a1c0a3 100644 (file)
@@ -27,8 +27,7 @@
 #include <asm/mmu_context.h>
 #include <asm/proto.h>
 #include <asm/apicdef.h>
-
-#define __cpuinit __init
+#include <asm/idle.h>
 
 /*
  *     Smarter SMP flushing macros. 
@@ -76,7 +75,7 @@ static inline void leave_mm(int cpu)
 {
        if (read_pda(mmu_state) == TLBSTATE_OK)
                BUG();
-       clear_bit(cpu, &read_pda(active_mm)->cpu_vm_mask);
+       cpu_clear(cpu, read_pda(active_mm)->cpu_vm_mask);
        load_cr3(swapper_pg_dir);
 }
 
@@ -86,7 +85,7 @@ static inline void leave_mm(int cpu)
  * [cpu0: the cpu that switches]
  * 1) switch_mm() either 1a) or 1b)
  * 1a) thread switch to a different mm
- * 1a1) clear_bit(cpu, &old_mm->cpu_vm_mask);
+ * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask);
  *     Stop ipi delivery for the old mm. This is not synchronized with
  *     the other cpus, but smp_invalidate_interrupt ignore flush ipis
  *     for the wrong mm, and in the worst case we perform a superfluous
@@ -96,7 +95,7 @@ static inline void leave_mm(int cpu)
  *     was in lazy tlb mode.
  * 1a3) update cpu active_mm
  *     Now cpu0 accepts tlb flushes for the new mm.
- * 1a4) set_bit(cpu, &new_mm->cpu_vm_mask);
+ * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask);
  *     Now the other cpus will send tlb flush ipis.
  * 1a4) change cr3.
  * 1b) thread switch without mm change
@@ -136,10 +135,10 @@ asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs)
 
        cpu = smp_processor_id();
        /*
-        * orig_rax contains the interrupt vector - 256.
+        * orig_rax contains the negated interrupt vector.
         * Use that to determine where the sender put the data.
         */
-       sender = regs->orig_rax + 256 - INVALIDATE_TLB_VECTOR_START;
+       sender = ~regs->orig_rax - INVALIDATE_TLB_VECTOR_START;
        f = &per_cpu(flush_state, sender);
 
        if (!cpu_isset(cpu, f->flush_cpumask))
@@ -225,6 +224,7 @@ void flush_tlb_current_task(void)
                flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
        preempt_enable();
 }
+EXPORT_SYMBOL(flush_tlb_current_task);
 
 void flush_tlb_mm (struct mm_struct * mm)
 {
@@ -245,6 +245,7 @@ void flush_tlb_mm (struct mm_struct * mm)
 
        preempt_enable();
 }
+EXPORT_SYMBOL(flush_tlb_mm);
 
 void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
 {
@@ -267,6 +268,7 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
 
        preempt_enable();
 }
+EXPORT_SYMBOL(flush_tlb_page);
 
 static void do_flush_tlb_all(void* info)
 {
@@ -282,11 +284,6 @@ void flush_tlb_all(void)
        on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
 }
 
-void smp_kdb_stop(void)
-{
-       send_IPI_allbutself(KDB_VECTOR);
-}
-
 /*
  * this function sends a 'reschedule' IPI to another CPU.
  * it goes straight through and wastes no time serializing
@@ -449,23 +446,25 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
        spin_unlock(&call_lock);
        return 0;
 }
+EXPORT_SYMBOL(smp_call_function);
 
 void smp_stop_cpu(void)
 {
+       unsigned long flags;
        /*
         * Remove this CPU:
         */
        cpu_clear(smp_processor_id(), cpu_online_map);
-       local_irq_disable();
+       local_irq_save(flags);
        disable_local_APIC();
-       local_irq_enable(); 
+       local_irq_restore(flags);
 }
 
 static void smp_really_stop_cpu(void *dummy)
 {
        smp_stop_cpu(); 
        for (;;) 
-               asm("hlt"); 
+               halt();
 } 
 
 void smp_send_stop(void)
@@ -475,7 +474,7 @@ void smp_send_stop(void)
                return;
        /* Don't deadlock on the call lock in panic */
        if (!spin_trylock(&call_lock)) {
-               /* ignore locking because we have paniced anyways */
+               /* ignore locking because we have panicked anyways */
                nolock = 1;
        }
        __smp_call_function(smp_really_stop_cpu, NULL, 0, 0);
@@ -513,6 +512,7 @@ asmlinkage void smp_call_function_interrupt(void)
        /*
         * At this point the info structure may be out of scope unless wait==1
         */
+       exit_idle();
        irq_enter();
        (*func)(info);
        irq_exit();
@@ -524,13 +524,13 @@ asmlinkage void smp_call_function_interrupt(void)
 
 int safe_smp_processor_id(void)
 {
-       int apicid, i;
+       unsigned apicid, i;
 
        if (disable_apic)
                return 0;
 
        apicid = hard_smp_processor_id();
-       if (x86_cpu_to_apicid[apicid] == apicid)
+       if (apicid < NR_CPUS && x86_cpu_to_apicid[apicid] == apicid)
                return apicid;
 
        for (i = 0; i < NR_CPUS; ++i) {