sh: Preparation for uncached jumps through PMB.
[powerpc.git] / arch / sh / mm / pmb.c
index a08a4a9..ab81c60 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/io.h>
+#include <asm/mmu_context.h>
 
 #define NR_PMB_ENTRIES 16
 
@@ -145,7 +146,7 @@ repeat:
 
        ctrl_outl(vpn | PMB_V, mk_pmb_addr(pos));
 
-#ifdef CONFIG_SH_WRITETHROUGH
+#ifdef CONFIG_CACHE_WRITETHROUGH
        /*
         * When we are in 32-bit address extended mode, CCR.CB becomes
         * invalid, so care must be taken to manually adjust cacheable
@@ -162,18 +163,18 @@ repeat:
        return 0;
 }
 
-int set_pmb_entry(struct pmb_entry *pmbe)
+int __uses_jump_to_uncached set_pmb_entry(struct pmb_entry *pmbe)
 {
        int ret;
 
-       jump_to_P2();
+       jump_to_uncached();
        ret = __set_pmb_entry(pmbe->vpn, pmbe->ppn, pmbe->flags, &pmbe->entry);
-       back_to_P1();
+       back_to_cached();
 
        return ret;
 }
 
-void clear_pmb_entry(struct pmb_entry *pmbe)
+void __uses_jump_to_uncached clear_pmb_entry(struct pmb_entry *pmbe)
 {
        unsigned int entry = pmbe->entry;
        unsigned long addr;
@@ -187,7 +188,7 @@ void clear_pmb_entry(struct pmb_entry *pmbe)
                     entry >= NR_PMB_ENTRIES))
                return;
 
-       jump_to_P2();
+       jump_to_uncached();
 
        /* Clear V-bit */
        addr = mk_pmb_addr(entry);
@@ -196,7 +197,7 @@ void clear_pmb_entry(struct pmb_entry *pmbe)
        addr = mk_pmb_data(entry);
        ctrl_outl(ctrl_inl(addr) & ~PMB_V, addr);
 
-       back_to_P1();
+       back_to_cached();
 
        clear_bit(entry, &pmb_map);
 }
@@ -292,8 +293,7 @@ void pmb_unmap(unsigned long addr)
        } while (pmbe);
 }
 
-static void pmb_cache_ctor(void *pmb, struct kmem_cache *cachep,
-                          unsigned long flags)
+static void pmb_cache_ctor(struct kmem_cache *cachep, void *pmb)
 {
        struct pmb_entry *pmbe = pmb;
 
@@ -302,17 +302,17 @@ static void pmb_cache_ctor(void *pmb, struct kmem_cache *cachep,
        pmbe->entry = PMB_NO_ENTRY;
 }
 
-static int __init pmb_init(void)
+static int __uses_jump_to_uncached pmb_init(void)
 {
        unsigned int nr_entries = ARRAY_SIZE(pmb_init_map);
-       unsigned int entry;
+       unsigned int entry, i;
 
        BUG_ON(unlikely(nr_entries >= NR_PMB_ENTRIES));
 
        pmb_cache = kmem_cache_create("pmb", sizeof(struct pmb_entry), 0,
                                      SLAB_PANIC, pmb_cache_ctor);
 
-       jump_to_P2();
+       jump_to_uncached();
 
        /*
         * Ordering is important, P2 must be mapped in the PMB before we
@@ -330,7 +330,12 @@ static int __init pmb_init(void)
        /* PMB.SE and UB[7] */
        ctrl_outl((1 << 31) | (1 << 7), PMB_PASCR);
 
-       back_to_P1();
+       /* Flush out the TLB */
+       i =  ctrl_inl(MMUCR);
+       i |= MMUCR_TI;
+       ctrl_outl(i, MMUCR);
+
+       back_to_cached();
 
        return 0;
 }