Pull sn2-reduce-kmalloc-wrap into release branch
[powerpc.git] / arch / arm / mm / init.c
index d1f1ec7..8b276ee 100644 (file)
@@ -262,8 +262,8 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
                if (end_pfn < end)
                        end_pfn = end;
 
-               map.physical = mi->bank[i].start;
-               map.virtual = __phys_to_virt(map.physical);
+               map.pfn = __phys_to_pfn(mi->bank[i].start);
+               map.virtual = __phys_to_virt(mi->bank[i].start);
                map.length = mi->bank[i].size;
                map.type = MT_MEMORY;
 
@@ -363,20 +363,16 @@ static void __init bootmem_init(struct meminfo *mi)
 
        memcpy(&meminfo, mi, sizeof(meminfo));
 
-#ifdef CONFIG_XIP_KERNEL
-#error needs fixing
-       p->physical   = CONFIG_XIP_PHYS_ADDR & PMD_MASK;
-       p->virtual    = (unsigned long)&_stext & PMD_MASK;
-       p->length     = ((unsigned long)&_etext - p->virtual + ~PMD_MASK) & PMD_MASK;
-       p->type       = MT_ROM;
-       p ++;
-#endif
-
        /*
         * Clear out all the mappings below the kernel image.
-        * FIXME: what about XIP?
         */
-       for (addr = 0; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
+       for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE)
+               pmd_clear(pmd_off_k(addr));
+#ifdef CONFIG_XIP_KERNEL
+       /* The XIP kernel is mapped in the module area -- skip over it */
+       addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK;
+#endif
+       for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
                pmd_clear(pmd_off_k(addr));
 
        /*
@@ -424,7 +420,8 @@ static void __init bootmem_init(struct meminfo *mi)
  * Set up device the mappings.  Since we clear out the page tables for all
  * mappings above VMALLOC_END, we will remove any debug device mappings.
  * This means you have to be careful how you debug this function, or any
- * called function.  (Do it by code inspection!)
+ * called function.  This means you can't use any function or debugging
+ * method which may touch any device, otherwise the kernel _will_ crash.
  */
 static void __init devicemaps_init(struct machine_desc *mdesc)
 {
@@ -432,39 +429,51 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
        unsigned long addr;
        void *vectors;
 
+       /*
+        * Allocate the vector page early.
+        */
+       vectors = alloc_bootmem_low_pages(PAGE_SIZE);
+       BUG_ON(!vectors);
+
        for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE)
                pmd_clear(pmd_off_k(addr));
 
+       /*
+        * Map the kernel if it is XIP.
+        * It is always first in the modulearea.
+        */
+#ifdef CONFIG_XIP_KERNEL
+       map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & PGDIR_MASK);
+       map.virtual = MODULE_START;
+       map.length = ((unsigned long)&_etext - map.virtual + ~PGDIR_MASK) & PGDIR_MASK;
+       map.type = MT_ROM;
+       create_mapping(&map);
+#endif
+
        /*
         * Map the cache flushing regions.
         */
 #ifdef FLUSH_BASE
-       map.physical = FLUSH_BASE_PHYS;
+       map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
        map.virtual = FLUSH_BASE;
        map.length = PGDIR_SIZE;
        map.type = MT_CACHECLEAN;
        create_mapping(&map);
 #endif
 #ifdef FLUSH_BASE_MINICACHE
-       map.physical = FLUSH_BASE_PHYS + PGDIR_SIZE;
+       map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + PGDIR_SIZE);
        map.virtual = FLUSH_BASE_MINICACHE;
        map.length = PGDIR_SIZE;
        map.type = MT_MINICLEAN;
        create_mapping(&map);
 #endif
 
-       flush_cache_all();
-       local_flush_tlb_all();
-
-       vectors = alloc_bootmem_low_pages(PAGE_SIZE);
-       BUG_ON(!vectors);
-
        /*
         * Create a mapping for the machine vectors at the high-vectors
         * location (0xffff0000).  If we aren't using high-vectors, also
         * create a mapping at the low-vectors virtual address.
         */
-       map.physical = virt_to_phys(vectors);
+       map.pfn = __phys_to_pfn(virt_to_phys(vectors));
        map.virtual = 0xffff0000;
        map.length = PAGE_SIZE;
        map.type = MT_HIGH_VECTORS;
@@ -478,10 +487,18 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
 
        /*
         * Ask the machine support to map in the statically mapped devices.
-        * After this point, we can start to touch devices again.
         */
        if (mdesc->map_io)
                mdesc->map_io();
+
+       /*
+        * Finally flush the caches and tlb to ensure that we're in a
+        * consistent state wrt the writebuffer.  This also ensures that
+        * any write-allocated cache lines in the vector page are written
+        * back.  After this point, we can start to touch devices again.
+        */
+       local_flush_tlb_all();
+       flush_cache_all();
 }
 
 /*