openrisc: Consolidate setup to use memblock instead of bootmem
Stafford Horne
maintainerPATCH 1/1 openrisc: Consolidate setup to use memblock instead of bootmem
Clearing out one todo item. This simplifies the boot process by using the memblock api throughout the init process.
The old logic bootstrapped from memblock -> bootmem -> buddy allocator This is now simplified by using NO_BOOTMEM.
--- arch/openrisc/Kconfig | 1 + arch/openrisc/TODO.openrisc | 3 --- arch/openrisc/include/asm/pgalloc.h | 1 - arch/openrisc/kernel/setup.c | 34 ++++++++++++---------------------- arch/openrisc/mm/init.c | 2 +- arch/openrisc/mm/ioremap.c | 4 ---- 6 files changed, 14 insertions(+), 31 deletions(-)
arch/openrisc/Kconfig +1 -0
@@ -27,6 +27,7 @@ config OPENRISC select HAVE_DEBUG_STACKOVERFLOW select OR1K_PIC select OMPIC if SMP + select NO_BOOTMEM config MMU def_bool y
arch/openrisc/TODO.openrisc +0 -3
@@ -5,9 +5,6 @@ that are due for investigation shortly, i.e. our TODO list: -- Implement the rest of the DMA API... dma_map_sg, etc. --- Consolidate usage of memblock and bootmem... move everything over to - memblock. - -- Finish the renaming cleanup... there are references to or32 in the code which was an older name for the architecture. The name we've settled on is or1k and this change is slowly trickling through the stack. For the time
arch/openrisc/include/asm/pgalloc.h +0 -1
@@ -23,7 +23,6 @@#include <linux/threads.h> #include <linux/mm.h> #include <linux/memblock.h> -#include <linux/bootmem.h> extern int mem_init_done;
arch/openrisc/kernel/setup.c +12 -22
@@ -51,18 +51,16 @@#include "vmlinux.h" -static unsigned long __init setup_memory (void ) +static void __init setup_memory (void ) { -unsigned long bootmap_size;unsigned long ram_start_pfn; -unsigned long free_ram_start_pfn;unsigned long ram_end_pfn;phys_addr_t memory_start, memory_end;struct memblock_region *region; memory_end = memory_start =0 ; -/* Find main memory where is the kernel */ +/* Find main memory where is the kernel, we assume its the only one */ for_each_memblock (memory, region) { memory_start = region->base; memory_end = region->base + region->size;
@@ -75,10 +73,11 @@ static unsigned long __init setup_memory(void) } ram_start_pfn =PFN_UP (memory_start); -/* free_ram_start_pfn is first page after kernel */ - free_ram_start_pfn =PFN_UP (__pa (_end)); ram_end_pfn =PFN_DOWN (memblock_end_of_DRAM ()); +/* setup bootmem globals (we use no_bootmem, but mm still depends on this) */ + min_low_pfn = ram_start_pfn; + max_low_pfn = ram_end_pfn; max_pfn = ram_end_pfn;/*
@@ -86,22 +85,13 @@ static unsigned long __init setup_memory(void)* * This makes the memory from the end of the kernel to the end of * RAM usable. -* init_bootmem sets the global values min_low_pfn, max_low_pfn. */ - bootmap_size =init_bootmem (free_ram_start_pfn, - ram_end_pfn - ram_start_pfn); -free_bootmem (PFN_PHYS (free_ram_start_pfn), - (ram_end_pfn - free_ram_start_pfn) <<PAGE_SHIFT ); -reserve_bootmem (PFN_PHYS (free_ram_start_pfn), bootmap_size, -BOOTMEM_DEFAULT ); - -for_each_memblock (reserved, region) { -printk (KERN_INFO "Reserved - 0x%08x-0x%08x\n" , - (u32 ) region->base, (u32 ) region->size); -reserve_bootmem (region->base, region->size,BOOTMEM_DEFAULT ); - } +memblock_reserve (__pa (_stext), _end - _stext); + +early_init_fdt_reserve_self (); +early_init_fdt_scan_reserved_mem (); -return ram_end_pfn; +memblock_dump_all (); }struct cpuinfo_or1k cpuinfo_or1k[NR_CPUS ];
@@ -327,8 +317,8 @@ void __init setup_arch(char **cmdline_p) initrd_below_start_ok =1 ;#endif -/* setup bootmem allocator */ - max_low_pfn =setup_memory (); +/* setup memblock allocator */ +setup_memory ();/* paging_init() sets up the MMU and marks all pages as reserved */ paging_init ();
arch/openrisc/mm/init.c +1 -1
@@ -106,7 +106,7 @@ static void __init map_ram(void) }/* Alloc one page for holding PTE's... */ - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); + pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE ));set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */
arch/openrisc/mm/ioremap.c +0 -4
@@ -124,11 +124,7 @@ pte_t __init_refok *pte_alloc_one_kernel(struct mm_struct *mm,if (likely (mem_init_done)) { pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_REPEAT); }else { - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); -#if 0 -/* FIXME: use memblock... */ pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE )); -#endif }if (pte)
Signature · 1 line
2.5.0
Quoted 7 lines · Stafford Horne
Clearing out one todo item. This simplifies the boot process by using the memblock api throughout the init process.
The old logic bootstrapped from memblock -> bootmem -> buddy allocator This is now simplified by using
NO_BOOTMEM.Signed-off-by Stafford Horne <[email protected]>
FWIW:
Guenter
Quoted 154 lines
--- arch/openrisc/Kconfig | 1 + arch/openrisc/TODO.openrisc | 3 --- arch/openrisc/include/asm/pgalloc.h | 1 - arch/openrisc/kernel/setup.c | 34 ++++++++++++---------------------- arch/openrisc/mm/init.c | 2 +- arch/openrisc/mm/ioremap.c | 4 ---- 6 files changed, 14 insertions(+), 31 deletions(-)arch/openrisc/Kconfig +1
-0@@ -27,6 +27,7 @@ config OPENRISC select HAVE_DEBUG_STACKOVERFLOW select OR1K_PIC select OMPIC if SMP + select NO_BOOTMEM config MMU def_bool yarch/openrisc/TODO.openrisc +0
-3@@ -5,9 +5,6 @@ that are due for investigation shortly, i.e. our TODO list: -- Implement the rest of the DMA API... dma_map_sg, etc. --- Consolidate usage of memblock and bootmem... move everything over to - memblock. - -- Finish the renaming cleanup... there are references to or32 in the code which was an older name for the architecture. The name we've settled on is or1k and this change is slowly trickling through the stack. For the timearch/openrisc/include/asm/pgalloc.h +0
-1@@ -23,7 +23,6 @@#include <linux/threads.h> #include <linux/mm.h> #include <linux/memblock.h> -#include <linux/bootmem.h> extern int mem_init_done;arch/openrisc/kernel/setup.c +12
-22@@ -51,18 +51,16 @@#include "vmlinux.h" -static unsigned long __init setup_memory (void ) +static void __init setup_memory (void ) { -unsigned long bootmap_size;unsigned long ram_start_pfn; -unsigned long free_ram_start_pfn;unsigned long ram_end_pfn;phys_addr_t memory_start, memory_end;struct memblock_region *region; memory_end = memory_start =0 ; -/* Find main memory where is the kernel */ +/* Find main memory where is the kernel, we assume its the only one */ for_each_memblock (memory, region) { memory_start = region->base; memory_end = region->base + region->size;@@ -75,10 +73,11 @@ static unsigned long __init setup_memory(void) } ram_start_pfn =PFN_UP (memory_start); -/* free_ram_start_pfn is first page after kernel */ - free_ram_start_pfn =PFN_UP (__pa (_end)); ram_end_pfn =PFN_DOWN (memblock_end_of_DRAM ()); +/* setup bootmem globals (we use no_bootmem, but mm still depends on this) */ + min_low_pfn = ram_start_pfn; + max_low_pfn = ram_end_pfn; max_pfn = ram_end_pfn;/* @@ -86,22 +85,13 @@ static unsigned long __init setup_memory(void)* * This makes the memory from the end of the kernel to the end of * RAM usable. -* init_bootmem sets the global values min_low_pfn, max_low_pfn. */ - bootmap_size =init_bootmem (free_ram_start_pfn, - ram_end_pfn - ram_start_pfn); -free_bootmem (PFN_PHYS (free_ram_start_pfn), - (ram_end_pfn - free_ram_start_pfn) <<PAGE_SHIFT ); -reserve_bootmem (PFN_PHYS (free_ram_start_pfn), bootmap_size, -BOOTMEM_DEFAULT ); - -for_each_memblock (reserved, region) { -printk (KERN_INFO "Reserved - 0x%08x-0x%08x\n" , - (u32 ) region->base, (u32 ) region->size); -reserve_bootmem (region->base, region->size,BOOTMEM_DEFAULT ); - } +memblock_reserve (__pa (_stext), _end - _stext); + +early_init_fdt_reserve_self (); +early_init_fdt_scan_reserved_mem (); -return ram_end_pfn; +memblock_dump_all (); }struct cpuinfo_or1k cpuinfo_or1k[NR_CPUS ];@@ -327,8 +317,8 @@ void __init setup_arch(char **cmdline_p) initrd_below_start_ok =1 ;#endif -/* setup bootmem allocator */ - max_low_pfn =setup_memory (); +/* setup memblock allocator */ +setup_memory ();/* paging_init() sets up the MMU and marks all pages as reserved */ paging_init ();arch/openrisc/mm/init.c +1
-1@@ -106,7 +106,7 @@ static void __init map_ram(void) }/* Alloc one page for holding PTE's... */ - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); + pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE ));set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */ arch/openrisc/mm/ioremap.c +0
-4@@ -124,11 +124,7 @@ pte_t __init_refok *pte_alloc_one_kernel(struct mm_struct *mm,if (likely (mem_init_done)) { pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_REPEAT); }else { - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); -#if 0 -/* FIXME: use memblock... */ pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE )); -#endif }if (pte)
Stafford Horne
maintainerQuoted 4 lines · Guenter Roeck
Quoted 3 lines · Stafford Horne
Clearing out one todo item. This simplifies the boot process by using the memblock api throughout the init process.
Quoted 8 lines
Quoted 4 lines
The old logic bootstrapped from memblock -> bootmem -> buddy allocator This is now simplified by using
NO_BOOTMEM.Signed-off-by Stafford Horne <[email protected]>FWIW:
Tested-by Guenter Roeck <[email protected]>
Thank you,
-Stafford
Quoted 11 lines · Guenter Roeck
Quoted 7 lines · Stafford Horne
Clearing out one todo item. This simplifies the boot process by using the memblock api throughout the init process.
The old logic bootstrapped from memblock -> bootmem -> buddy allocator This is now simplified by using
NO_BOOTMEM.Signed-off-by Stafford Horne <[email protected]>FWIW:
Tested-by Guenter Roeck <[email protected]>
It's worth a lot. I asked for a Tested-by on this patch many months ago... never heard from anybody.
Thanks. This one is upstream material.
Stafford, queue this one up for upstream.
/Jonas
Quoted 157 lines
Guenter
Quoted 154 lines
--- arch/openrisc/Kconfig | 1 + arch/openrisc/TODO.openrisc | 3 --- arch/openrisc/include/asm/pgalloc.h | 1 - arch/openrisc/kernel/setup.c | 34 ++++++++++++---------------------- arch/openrisc/mm/init.c | 2 +- arch/openrisc/mm/ioremap.c | 4 ---- 6 files changed, 14 insertions(+), 31 deletions(-)arch/openrisc/Kconfig +1
-0@@ -27,6 +27,7 @@ config OPENRISC select HAVE_DEBUG_STACKOVERFLOW select OR1K_PIC select OMPIC if SMP + select NO_BOOTMEM config MMU def_bool yarch/openrisc/TODO.openrisc +0
-3@@ -5,9 +5,6 @@ that are due for investigation shortly, i.e. our TODO list: -- Implement the rest of the DMA API... dma_map_sg, etc. --- Consolidate usage of memblock and bootmem... move everything over to - memblock. - -- Finish the renaming cleanup... there are references to or32 in the code which was an older name for the architecture. The name we've settled on is or1k and this change is slowly trickling through the stack. For the timearch/openrisc/include/asm/pgalloc.h +0
-1@@ -23,7 +23,6 @@#include <linux/threads.h> #include <linux/mm.h> #include <linux/memblock.h> -#include <linux/bootmem.h> extern int mem_init_done;arch/openrisc/kernel/setup.c +12
-22@@ -51,18 +51,16 @@#include "vmlinux.h" -static unsigned long __init setup_memory (void ) +static void __init setup_memory (void ) { -unsigned long bootmap_size;unsigned long ram_start_pfn; -unsigned long free_ram_start_pfn;unsigned long ram_end_pfn;phys_addr_t memory_start, memory_end;struct memblock_region *region; memory_end = memory_start =0 ; -/* Find main memory where is the kernel */ +/* Find main memory where is the kernel, we assume its the only one */ for_each_memblock (memory, region) { memory_start = region->base; memory_end = region->base + region->size;@@ -75,10 +73,11 @@ static unsigned long __init setup_memory(void) } ram_start_pfn =PFN_UP (memory_start); -/* free_ram_start_pfn is first page after kernel */ - free_ram_start_pfn =PFN_UP (__pa (_end)); ram_end_pfn =PFN_DOWN (memblock_end_of_DRAM ()); +/* setup bootmem globals (we use no_bootmem, but mm still depends on this) */ + min_low_pfn = ram_start_pfn; + max_low_pfn = ram_end_pfn; max_pfn = ram_end_pfn;/* @@ -86,22 +85,13 @@ static unsigned long __init setup_memory(void)* * This makes the memory from the end of the kernel to the end of * RAM usable. -* init_bootmem sets the global values min_low_pfn, max_low_pfn. */ - bootmap_size =init_bootmem (free_ram_start_pfn, - ram_end_pfn - ram_start_pfn); -free_bootmem (PFN_PHYS (free_ram_start_pfn), - (ram_end_pfn - free_ram_start_pfn) <<PAGE_SHIFT ); -reserve_bootmem (PFN_PHYS (free_ram_start_pfn), bootmap_size, -BOOTMEM_DEFAULT ); - -for_each_memblock (reserved, region) { -printk (KERN_INFO "Reserved - 0x%08x-0x%08x\n" , - (u32 ) region->base, (u32 ) region->size); -reserve_bootmem (region->base, region->size,BOOTMEM_DEFAULT ); - } +memblock_reserve (__pa (_stext), _end - _stext); + +early_init_fdt_reserve_self (); +early_init_fdt_scan_reserved_mem (); -return ram_end_pfn; +memblock_dump_all (); }struct cpuinfo_or1k cpuinfo_or1k[NR_CPUS ];@@ -327,8 +317,8 @@ void __init setup_arch(char **cmdline_p) initrd_below_start_ok =1 ;#endif -/* setup bootmem allocator */ - max_low_pfn =setup_memory (); +/* setup memblock allocator */ +setup_memory ();/* paging_init() sets up the MMU and marks all pages as reserved */ paging_init ();arch/openrisc/mm/init.c +1
-1@@ -106,7 +106,7 @@ static void __init map_ram(void) }/* Alloc one page for holding PTE's... */ - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); + pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE ));set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */ arch/openrisc/mm/ioremap.c +0
-4@@ -124,11 +124,7 @@ pte_t __init_refok *pte_alloc_one_kernel(struct mm_struct *mm,if (likely (mem_init_done)) { pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_REPEAT); }else { - pte = (pte_t *)alloc_bootmem_low_pages (PAGE_SIZE ); -#if 0 -/* FIXME: use memblock... */ pte = (pte_t *)__va (memblock_alloc (PAGE_SIZE ,PAGE_SIZE )); -#endif }if (pte)