MIPS: ralink: use memblock instead of rescanning the FDT
Subsystems (2)
PATCH 1/1 MIPS: ralink: use memblock instead of rescanning the FDT
There's no need to scan /memory nodes twice. The DT core code scans nodes and adds memblocks already, so we can just use memblock_phys_mem_size() to see if we have any memory already setup.
--- arch/mips/ralink/of.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
arch/mips/ralink/of.c +5 -16
@@ -14,7 +14,7 @@#include <linux/sizes.h> #include <linux/of_fdt.h> #include <linux/kernel.h> -#include <linux/bootmem.h> +#include <linux/memblock.h> #include <linux/of_platform.h> #include <linux/of_address.h>
@@ -53,17 +53,6 @@ void __init device_tree_init(void)unflatten_and_copy_device_tree (); } -static int memory_dtb; - -static int __init early_init_dt_find_memory (unsigned long node, -const char *uname,int depth,void *data) -{ -if (depth ==1 && !strcmp (uname,"memory@0" )) - memory_dtb =1 ; - -return 0 ; -} -void __init plat_mem_setup (void ) {void *dtb =NULL ;
@@ -82,10 +71,10 @@ void __init plat_mem_setup(void)__dt_setup_arch (dtb); -of_scan_flat_dt (early_init_dt_find_memory,NULL ); -if (memory_dtb) -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); -else if (soc_info.mem_size) +if (memblock_phys_mem_size ()) +return ; + +if (soc_info.mem_size)add_memory_region (soc_info.mem_base, soc_info.mem_size *SZ_1M ,BOOT_MEM_RAM );else
Signature · 1 line
2.14.1
Quoted 4 lines · Rob Herring
There's no need to scan /memory nodes twice. The DT core code scans nodes and adds memblocks already, so we can just use
memblock_phys_mem_size()to see if we have any memory already setup.
Quoted 8 lines
Signed-off-by Rob Herring <[email protected]>Cc John Crispin <[email protected]>Cc Ralf Baechle <[email protected]>Cc James Hogan <[email protected]>--- arch/mips/ralink/of.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
Ping. Can MIPS maintainers please pick this up.
Rob
A message that is not in the archive (sent off-list or not yet received): 20180508233758.GE14903@jamesdev
Quoted 8 lines · James Hogan
Quoted 3 lines · Rob Herring
There's no need to scan /memory nodes twice. The DT core code scans nodes and adds memblocks already, so we can just use
memblock_phys_mem_size()to see if we have any memory already setup.Hmm, on MIPS,
early_init_dt_add_memory_arch()callsadd_memory_region(), which just modifiesboot_mem_map. memblock isn't notified until afterplat_mem_setup()returns, inbootmem_init().
Yes, you're right. I guess first boot_mem_map needs to be converted to memblock.
Rob