Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/net-2.6
[safe/jmp/linux-2.6] / arch / powerpc / mm / stab.c
index 1b83f00..50448d5 100644 (file)
@@ -12,7 +12,6 @@
  *      2 of the License, or (at your option) any later version.
  */
 
-#include <linux/config.h>
 #include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/cputable.h>
 #include <asm/lmb.h>
 #include <asm/abs_addr.h>
+#include <asm/firmware.h>
+#include <asm/iseries/hv_call.h>
 
 struct stab_entry {
        unsigned long esid_data;
        unsigned long vsid_data;
 };
 
-/* Both the segment table and SLB code uses the following cache */
 #define NR_STAB_CACHE_ENTRIES 8
 DEFINE_PER_CPU(long, stab_cache_ptr);
 DEFINE_PER_CPU(long, stab_cache[NR_STAB_CACHE_ENTRIES]);
@@ -40,7 +40,7 @@ static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid)
        unsigned long entry, group, old_esid, castout_entry, i;
        unsigned int global_entry;
        struct stab_entry *ste, *castout_ste;
-       unsigned long kernel_segment = (esid << SID_SHIFT) >= KERNELBASE;
+       unsigned long kernel_segment = (esid << SID_SHIFT) >= PAGE_OFFSET;
 
        vsid_data = vsid << STE_VSID_SHIFT;
        esid_data = esid << SID_SHIFT | STE_ESID_KP | STE_ESID_V;
@@ -56,7 +56,7 @@ static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid)
                for (entry = 0; entry < 8; entry++, ste++) {
                        if (!(ste->esid_data & STE_ESID_V)) {
                                ste->vsid_data = vsid_data;
-                               asm volatile("eieio":::"memory");
+                               eieio();
                                ste->esid_data = esid_data;
                                return (global_entry | entry);
                        }
@@ -83,7 +83,7 @@ static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid)
                }
 
                /* Dont cast out the first kernel segment */
-               if ((castout_ste->esid_data & ESID_MASK) != KERNELBASE)
+               if ((castout_ste->esid_data & ESID_MASK) != PAGE_OFFSET)
                        break;
 
                castout_entry = (castout_entry + 1) & 0xf;
@@ -102,7 +102,7 @@ static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid)
        asm volatile("sync" : : : "memory");    /* Order update */
 
        castout_ste->vsid_data = vsid_data;
-       asm volatile("eieio" : : : "memory");   /* Order update */
+       eieio();                                /* Order update */
        castout_ste->esid_data = esid_data;
 
        asm volatile("slbie  %0" : : "r" (old_esid << SID_SHIFT));
@@ -122,18 +122,18 @@ static int __ste_allocate(unsigned long ea, struct mm_struct *mm)
        unsigned long offset;
 
        /* Kernel or user address? */
-       if (ea >= KERNELBASE) {
-               vsid = get_kernel_vsid(ea);
+       if (is_kernel_addr(ea)) {
+               vsid = get_kernel_vsid(ea, MMU_SEGSIZE_256M);
        } else {
                if ((ea >= TASK_SIZE_USER64) || (! mm))
                        return 1;
 
-               vsid = get_vsid(mm->context.id, ea);
+               vsid = get_vsid(mm->context.id, ea, MMU_SEGSIZE_256M);
        }
 
        stab_entry = make_ste(get_paca()->stab_addr, GET_ESID(ea), vsid);
 
-       if (ea < KERNELBASE) {
+       if (!is_kernel_addr(ea)) {
                offset = __get_cpu_var(stab_cache_ptr);
                if (offset < NR_STAB_CACHE_ENTRIES)
                        __get_cpu_var(stab_cache[offset++]) = stab_entry;
@@ -186,11 +186,11 @@ void switch_stab(struct task_struct *tsk, struct mm_struct *mm)
                /* Never flush the first entry. */
                ste += 1;
                for (entry = 1;
-                    entry < (PAGE_SIZE / sizeof(struct stab_entry));
+                    entry < (HW_PAGE_SIZE / sizeof(struct stab_entry));
                     entry++, ste++) {
                        unsigned long ea;
                        ea = ste->esid_data & ESID_MASK;
-                       if (ea < KERNELBASE) {
+                       if (!is_kernel_addr(ea)) {
                                ste->esid_data = 0;
                        }
                }
@@ -223,38 +223,35 @@ void switch_stab(struct task_struct *tsk, struct mm_struct *mm)
        asm volatile("sync" : : : "memory");
 }
 
-extern void slb_initialize(void);
-
 /*
  * Allocate segment tables for secondary CPUs.  These must all go in
  * the first (bolted) segment, so that do_stab_bolted won't get a
  * recursive segment miss on the segment table itself.
  */
-void stabs_alloc(void)
+void __init stabs_alloc(void)
 {
        int cpu;
 
        if (cpu_has_feature(CPU_FTR_SLB))
                return;
 
-       for_each_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                unsigned long newstab;
 
                if (cpu == 0)
                        continue; /* stab for CPU 0 is statically allocated */
 
-               newstab = lmb_alloc_base(PAGE_SIZE, PAGE_SIZE, 1<<SID_SHIFT);
-               if (! newstab)
-                       panic("Unable to allocate segment table for CPU %d.\n",
-                             cpu);
-
-               newstab += KERNELBASE;
+               newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE,
+                                        1<<SID_SHIFT);
+               newstab = (unsigned long)__va(newstab);
 
-               memset((void *)newstab, 0, PAGE_SIZE);
+               memset((void *)newstab, 0, HW_PAGE_SIZE);
 
                paca[cpu].stab_addr = newstab;
                paca[cpu].stab_real = virt_to_abs(newstab);
-               printk(KERN_DEBUG "Segment table for CPU %d at 0x%lx virtual, 0x%lx absolute\n", cpu, paca[cpu].stab_addr, paca[cpu].stab_real);
+               printk(KERN_INFO "Segment table for CPU %d at 0x%lx "
+                      "virtual, 0x%lx absolute\n",
+                      cpu, paca[cpu].stab_addr, paca[cpu].stab_real);
        }
 }
 
@@ -265,15 +262,24 @@ void stabs_alloc(void)
  */
 void stab_initialize(unsigned long stab)
 {
-       unsigned long vsid = get_kernel_vsid(KERNELBASE);
+       unsigned long vsid = get_kernel_vsid(PAGE_OFFSET, MMU_SEGSIZE_256M);
+       unsigned long stabreal;
 
-       if (cpu_has_feature(CPU_FTR_SLB)) {
-               slb_initialize();
-       } else {
-               asm volatile("isync; slbia; isync":::"memory");
-               make_ste(stab, GET_ESID(KERNELBASE), vsid);
+       asm volatile("isync; slbia; isync":::"memory");
+       make_ste(stab, GET_ESID(PAGE_OFFSET), vsid);
 
-               /* Order update */
-               asm volatile("sync":::"memory");
+       /* Order update */
+       asm volatile("sync":::"memory");
+
+       /* Set ASR */
+       stabreal = get_paca()->stab_real | 0x1ul;
+
+#ifdef CONFIG_PPC_ISERIES
+       if (firmware_has_feature(FW_FEATURE_ISERIES)) {
+               HvCall1(HvCallBaseSetASR, stabreal);
+               return;
        }
+#endif /* CONFIG_PPC_ISERIES */
+
+       mtspr(SPRN_ASR, stabreal);
 }