ARM64: mm: Restore memblock limit when map_mem finished.
[firefly-linux-kernel-4.4.55.git] / arch / arm64 / mm / mmu.c
index ba7477efad5ca60912476d0bd93ca2e776b49d20..49961d1fa033ce887906df20aa7f9bd90ab8ec73 100644 (file)
@@ -305,6 +305,16 @@ static void __init map_mem(void)
 {
        struct memblock_region *reg;
 
+       /*
+        * Temporarily limit the memblock range. We need to do this as
+        * create_mapping requires puds, pmds and ptes to be allocated from
+        * memory addressable from the initial direct kernel mapping.
+        *
+        * The initial direct kernel mapping, located at swapper_pg_dir,
+        * gives us PGDIR_SIZE memory starting from PHYS_OFFSET (aligned).
+        */
+       memblock_set_current_limit((PHYS_OFFSET & PGDIR_MASK) + PGDIR_SIZE);
+
        /* map all the memory banks */
        for_each_memblock(memory, reg) {
                phys_addr_t start = reg->base;
@@ -315,6 +325,9 @@ static void __init map_mem(void)
 
                create_mapping(start, __phys_to_virt(start), end - start);
        }
+
+       /* Limit no longer required. */
+       memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);
 }
 
 /*
@@ -325,12 +338,6 @@ void __init paging_init(void)
 {
        void *zero_page;
 
-       /*
-        * Maximum PGDIR_SIZE addressable via the initial direct kernel
-        * mapping in swapper_pg_dir.
-        */
-       memblock_set_current_limit((PHYS_OFFSET & PGDIR_MASK) + PGDIR_SIZE);
-
        init_mem_pgprot();
        map_mem();