Skip to contentSkip to conversation

MIPS: ralink: use memblock instead of rescanning the FDT

PATCH In review Rob Herring 1 participant 3 messages Mar 28, 2018 – May 14, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

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(-)
arch/mips/ralink/of.c +5 -16
index 1ada8492733b..cf3b01b5c624 100644
@@ -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
#1 lore raw
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
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

#3 lore raw
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() calls add_memory_region(), which just modifies boot_mem_map. memblock isn't notified until after plat_mem_setup() returns, in bootmem_init().

Yes, you're right. I guess first boot_mem_map needs to be converted to memblock.

Rob