Re: [PATCH 3/3] nios2: switch to NO_BOOTMEM

From: Ley Foon Tan
Date: Thu Aug 02 2018 - 12:02:26 EST


On Wed, 2018-07-04 at 16:18 +0300, Mike Rapoport wrote:
> Remove bootmem bitmap initialization and replace reserve_bootmem()
> with
> memblock_reserve().
>
> Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
> ---
> Âarch/nios2/KconfigÂÂÂÂÂÂÂÂ|ÂÂ2 ++
> Âarch/nios2/kernel/prom.cÂÂ|ÂÂ7 -------
> Âarch/nios2/kernel/setup.c | 37 +++++--------------------------------
> Â3 files changed, 7 insertions(+), 39 deletions(-)
>
> diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
> index 5db8fa1..661f7f9 100644
> --- a/arch/nios2/Kconfig
> +++ b/arch/nios2/Kconfig
> @@ -20,6 +20,8 @@ config NIOS2
> ÂÂÂÂÂÂÂÂselect USB_ARCH_HAS_HCD if USB_SUPPORT
> ÂÂÂÂÂÂÂÂselect CPU_NO_EFFICIENT_FFS
> ÂÂÂÂÂÂÂÂselect HAVE_MEMBLOCK
> +ÂÂÂÂÂÂÂselect ARCH_DISCARD_MEMBLOCK
> +ÂÂÂÂÂÂÂselect NO_BOOTMEM
>
> Âconfig GENERIC_CSUM
> ÂÂÂÂÂÂÂÂdef_bool y
> diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
> index ba96a49..a6d4f75 100644
> --- a/arch/nios2/kernel/prom.c
> +++ b/arch/nios2/kernel/prom.c
> @@ -32,13 +32,6 @@
>
> Â#include <asm/sections.h>
>
> -int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
> phys_addr_t size,
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbool nomap)
> -{
> -ÂÂÂÂÂÂÂreserve_bootmem(base, size, BOOTMEM_DEFAULT);
> -ÂÂÂÂÂÂÂreturn 0;
> -}
> -
> Âvoid __init early_init_devtree(void *params)
> Â{
> ÂÂÂÂÂÂÂÂ__be32 *dtb = (u32 *)__dtb_start;
> diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
> index 0946840..2d0011d 100644
> --- a/arch/nios2/kernel/setup.c
> +++ b/arch/nios2/kernel/setup.c
> @@ -144,10 +144,11 @@ asmlinkage void __init nios2_boot_init(unsigned
> r4, unsigned r5, unsigned r6,
>
> Âvoid __init setup_arch(char **cmdline_p)
> Â{
> -ÂÂÂÂÂÂÂint bootmap_size;
> +ÂÂÂÂÂÂÂint dram_start;
>
> ÂÂÂÂÂÂÂÂconsole_verbose();
>
> +ÂÂÂÂÂÂÂdram_start = memblock_start_of_DRAM();
> ÂÂÂÂÂÂÂÂmemory_size = memblock_phys_mem_size();
> ÂÂÂÂÂÂÂÂmemory_start = PAGE_ALIGN((unsigned long)__pa(_end));
> ÂÂÂÂÂÂÂÂmemory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE +
> memory_size;
> @@ -165,39 +166,11 @@ void __init setup_arch(char **cmdline_p)
> ÂÂÂÂÂÂÂÂmax_low_pfn = PFN_DOWN(memory_end);
> ÂÂÂÂÂÂÂÂmax_mapnr = max_low_pfn;
>
> -ÂÂÂÂÂÂÂ/*
> -ÂÂÂÂÂÂÂÂ* give all the memory to the bootmap allocator,ÂÂtell it to
> put the
> -ÂÂÂÂÂÂÂÂ* boot mem_map at the start of memory
> -ÂÂÂÂÂÂÂÂ*/
> -ÂÂÂÂÂÂÂpr_debug("init_bootmem_node(?,%#lx, %#x, %#lx)\n",
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmin_low_pfn, PFN_DOWN(PHYS_OFFSET), max_low_pfn);
> -ÂÂÂÂÂÂÂbootmap_size = init_bootmem_node(NODE_DATA(0),
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmin_low_pfn,
> PFN_DOWN(PHYS_OFFSET),
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmax_low_pfn);
> -
> -ÂÂÂÂÂÂÂ/*
> -ÂÂÂÂÂÂÂÂ* free the usable memory,ÂÂwe have to make sure we do not
> free
> -ÂÂÂÂÂÂÂÂ* the bootmem bitmap so we then reserve it after freeing it
> :-)
> -ÂÂÂÂÂÂÂÂ*/
> -ÂÂÂÂÂÂÂpr_debug("free_bootmem(%#lx, %#lx)\n",
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmemory_start, memory_end - memory_start);
> -ÂÂÂÂÂÂÂfree_bootmem(memory_start, memory_end - memory_start);
> -
> -ÂÂÂÂÂÂÂ/*
> -ÂÂÂÂÂÂÂÂ* Reserve the bootmem bitmap itself as well. We do this in
> two
> -ÂÂÂÂÂÂÂÂ* steps (first step was init_bootmem()) because this catches
> -ÂÂÂÂÂÂÂÂ* the (very unlikely) case of us accidentally initializing
> the
> -ÂÂÂÂÂÂÂÂ* bootmem allocator with an invalid RAM area.
> -ÂÂÂÂÂÂÂÂ*
> -ÂÂÂÂÂÂÂÂ* Arguments are start, size
> -ÂÂÂÂÂÂÂÂ*/
> -ÂÂÂÂÂÂÂpr_debug("reserve_bootmem(%#lx, %#x)\n", memory_start,
> bootmap_size);
> -ÂÂÂÂÂÂÂreserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
> -
> +ÂÂÂÂÂÂÂmemblock_reserve(dram_start, memory_start - dram_start);
> Â#ifdef CONFIG_BLK_DEV_INITRD
> ÂÂÂÂÂÂÂÂif (initrd_start) {
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreserve_bootmem(virt_to_phys((void *)initrd_start),
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinitrd_end - initrd_start,
> BOOTMEM_DEFAULT);
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmemblock_reserve(virt_to_phys((void *)initrd_start),
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinitrd_end - initrd_start);
> ÂÂÂÂÂÂÂÂ}
> Â#endif /* CONFIG_BLK_DEV_INITRD */
>
> --
> 2.7.4

Acked-by: Ley Foon Tan <ley.foon.tan@xxxxxxxxx>