Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of/fdt: run soc memory setup when early_init_dt_scan_memory fails

If memory has been found early_init_dt_scan_memory now returns 1. If
it hasn't found any memory it will return 0, allowing other memory
setup mechanisms to carry on.

Previously early_init_dt_scan_memory always returned 0 without
distinguishing between any kind of memory setup being done or not. Any
code path after the early_init_dt_scan memory call in the ramips
plat_mem_setup code wouldn't be executed anymore. Making
early_init_dt_scan_memory the only way to initialize the memory.

Some boards, including my mt7621 based Cudy X6 board, depend on memory
initialization being done via the soc_info.mem_detect function
pointer. Those wouldn't be able to obtain memory and panic the kernel
during early bootup with the message "early_init_dt_alloc_memory_arch:
Failed to allocate 12416 bytes align=0x40".

Fixes: 1f012283e936 ("of/fdt: Rework early_init_dt_scan_memory() to call directly")
Cc: stable@vger.kernel.org
Signed-off-by: Andreas Rammhold <andreas@rammhold.de>
Link: https://lore.kernel.org/r/20221223112748.2935235-1-andreas@rammhold.de
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Andreas Rammhold and committed by
Rob Herring
2a12187d 1b929c02

+5 -3
+1 -1
arch/mips/ralink/of.c
··· 64 64 dtb = get_fdt(); 65 65 __dt_setup_arch(dtb); 66 66 67 - if (!early_init_dt_scan_memory()) 67 + if (early_init_dt_scan_memory()) 68 68 return; 69 69 70 70 if (soc_info.mem_detect)
+4 -2
drivers/of/fdt.c
··· 1099 1099 */ 1100 1100 int __init early_init_dt_scan_memory(void) 1101 1101 { 1102 - int node; 1102 + int node, found_memory = 0; 1103 1103 const void *fdt = initial_boot_params; 1104 1104 1105 1105 fdt_for_each_subnode(node, fdt, 0) { ··· 1139 1139 1140 1140 early_init_dt_add_memory_arch(base, size); 1141 1141 1142 + found_memory = 1; 1143 + 1142 1144 if (!hotpluggable) 1143 1145 continue; 1144 1146 ··· 1149 1147 base, base + size); 1150 1148 } 1151 1149 } 1152 - return 0; 1150 + return found_memory; 1153 1151 } 1154 1152 1155 1153 int __init early_init_dt_scan_chosen(char *cmdline)