Merge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc
[pandora-kernel.git] / arch / arm / mm / init.c
index c168f32..9ea1f87 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/initrd.h>
 
 #include <asm/mach-types.h>
-#include <asm/hardware.h>
 #include <asm/setup.h>
+#include <asm/sizes.h>
 #include <asm/tlb.h>
 
 #include <asm/mach/arch.h>
@@ -420,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)
 {
@@ -428,6 +429,12 @@ 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));
 
@@ -449,24 +456,18 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
 #ifdef FLUSH_BASE
        map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
        map.virtual = FLUSH_BASE;
-       map.length = PGDIR_SIZE;
+       map.length = SZ_1M;
        map.type = MT_CACHECLEAN;
        create_mapping(&map);
 #endif
 #ifdef FLUSH_BASE_MINICACHE
-       map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + PGDIR_SIZE);
+       map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
        map.virtual = FLUSH_BASE_MINICACHE;
-       map.length = PGDIR_SIZE;
+       map.length = SZ_1M;
        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
@@ -491,12 +492,13 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
                mdesc->map_io();
 
        /*
-        * Finally flush the tlb again - this ensures that we're in a
-        * consistent state wrt the writebuffer if the writebuffer needs
-        * draining.  After this point, we can start to touch devices
-        * again.
+        * 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();
 }
 
 /*
@@ -529,7 +531,7 @@ static inline void free_area(unsigned long addr, unsigned long end, char *s)
        for (; addr < end; addr += PAGE_SIZE) {
                struct page *page = virt_to_page(addr);
                ClearPageReserved(page);
-               set_page_count(page, 1);
+               init_page_count(page);
                free_page(addr);
                totalram_pages++;
        }