Merge tag 'csky-for-linus-4.20-fixup-dtb' of https://github.com/c-sky/csky-linux
[linux-block.git] / arch / hexagon / mm / init.c
index 1495d45e472d880a0e484ed8b567435414d91884..1719ede9e9bde102b66432d66e65bc462d5e6e15 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <linux/init.h>
 #include <linux/mm.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <asm/atomic.h>
 #include <linux/highmem.h>
 #include <asm/tlb.h>
@@ -67,7 +67,7 @@ unsigned long long kmap_generation;
 void __init mem_init(void)
 {
        /*  No idea where this is actually declared.  Seems to evade LXR.  */
-       free_all_bootmem();
+       memblock_free_all();
        mem_init_print_info(NULL);
 
        /*
@@ -176,7 +176,6 @@ size_t hexagon_coherent_pool_size = (size_t) (DMA_RESERVE << 22);
 
 void __init setup_arch_memory(void)
 {
-       int bootmap_size;
        /*  XXX Todo: this probably should be cleaned up  */
        u32 *segtable = (u32 *) &swapper_pg_dir[0];
        u32 *segtable_end;
@@ -195,18 +194,22 @@ void __init setup_arch_memory(void)
        bootmem_lastpg = PFN_DOWN((bootmem_lastpg << PAGE_SHIFT) &
                ~((BIG_KERNEL_PAGE_SIZE) - 1));
 
+       memblock_add(PHYS_OFFSET,
+                    (bootmem_lastpg - ARCH_PFN_OFFSET) << PAGE_SHIFT);
+
+       /* Reserve kernel text/data/bss */
+       memblock_reserve(PHYS_OFFSET,
+                        (bootmem_startpg - ARCH_PFN_OFFSET) << PAGE_SHIFT);
        /*
         * Reserve the top DMA_RESERVE bytes of RAM for DMA (uncached)
         * memory allocation
         */
-
        max_low_pfn = bootmem_lastpg - PFN_DOWN(DMA_RESERVED_BYTES);
        min_low_pfn = ARCH_PFN_OFFSET;
-       bootmap_size =  init_bootmem_node(NODE_DATA(0), bootmem_startpg, min_low_pfn, max_low_pfn);
+       memblock_reserve(PFN_PHYS(max_low_pfn), DMA_RESERVED_BYTES);
 
        printk(KERN_INFO "bootmem_startpg:  0x%08lx\n", bootmem_startpg);
        printk(KERN_INFO "bootmem_lastpg:  0x%08lx\n", bootmem_lastpg);
-       printk(KERN_INFO "bootmap_size:  %d\n", bootmap_size);
        printk(KERN_INFO "min_low_pfn:  0x%08lx\n", min_low_pfn);
        printk(KERN_INFO "max_low_pfn:  0x%08lx\n", max_low_pfn);
 
@@ -256,14 +259,6 @@ void __init setup_arch_memory(void)
        printk(KERN_INFO "*segtable = 0x%08x\n", *segtable);
 #endif
 
-       /*
-        * Free all the memory that wasn't taken up by the bootmap, the DMA
-        * reserve, or kernel itself.
-        */
-       free_bootmem(PFN_PHYS(bootmem_startpg) + bootmap_size,
-                    PFN_PHYS(bootmem_lastpg - bootmem_startpg) - bootmap_size -
-                    DMA_RESERVED_BYTES);
-
        /*
         *  The bootmem allocator seemingly just lives to feed memory
         *  to the paging system