Re: [PATCH 2/3] nios2: use generic early_init_dt_add_memory_arch
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:
> All we have to do is to enable memblock, the generic FDT code will
> take
> care of the rest.
>
> Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
> ---
> Âarch/nios2/KconfigÂÂÂÂÂÂÂÂ|ÂÂ1 +
> Âarch/nios2/kernel/prom.cÂÂ| 10 ----------
> Âarch/nios2/kernel/setup.c |ÂÂ2 ++
> Â3 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
> index 3d4ec88..5db8fa1 100644
> --- a/arch/nios2/Kconfig
> +++ b/arch/nios2/Kconfig
> @@ -19,6 +19,7 @@ config NIOS2
> ÂÂÂÂÂÂÂÂselect SPARSE_IRQ
> ÂÂÂÂÂÂÂÂselect USB_ARCH_HAS_HCD if USB_SUPPORT
> ÂÂÂÂÂÂÂÂselect CPU_NO_EFFICIENT_FFS
> +ÂÂÂÂÂÂÂselect HAVE_MEMBLOCK
>
> Âconfig GENERIC_CSUM
> ÂÂÂÂÂÂÂÂdef_bool y
> diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
> index 8d7446a..ba96a49 100644
> --- a/arch/nios2/kernel/prom.c
> +++ b/arch/nios2/kernel/prom.c
> @@ -32,16 +32,6 @@
>
> Â#include <asm/sections.h>
>
> -void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> -{
> -ÂÂÂÂÂÂÂu64 kernel_start = (u64)virt_to_phys(_text);
> -
> -ÂÂÂÂÂÂÂif (!memory_size &&
> -ÂÂÂÂÂÂÂÂÂÂÂ(kernel_start >= base) && (kernel_start < (base + size)))
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmemory_size = size;
> -
> -}
> -
> Âint __init early_init_dt_reserve_memory_arch(phys_addr_t base,
> phys_addr_t size,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbool nomap)
> Â{
> diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
> index 926a02b..0946840 100644
> --- a/arch/nios2/kernel/setup.c
> +++ b/arch/nios2/kernel/setup.c
> @@ -17,6 +17,7 @@
> Â#include <linux/sched/task.h>
> Â#include <linux/console.h>
> Â#include <linux/bootmem.h>
> +#include <linux/memblock.h>
> Â#include <linux/initrd.h>
> Â#include <linux/of_fdt.h>
> Â#include <linux/screen_info.h>
> @@ -147,6 +148,7 @@ void __init setup_arch(char **cmdline_p)
>
> ÂÂÂÂÂÂÂÂconsole_verbose();
>
> +ÂÂÂÂÂÂÂmemory_size = memblock_phys_mem_size();
> ÂÂÂÂÂÂÂÂmemory_start = PAGE_ALIGN((unsigned long)__pa(_end));
> ÂÂÂÂÂÂÂÂmemory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE +
> memory_size;
>
> --
Acked-by: Ley Foon Tan <ley.foon.tan@xxxxxxxxx>