Skip to content

Commit 2a12187

Browse files
andirrobherring
authored andcommitted
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: 1f01228 ("of/fdt: Rework early_init_dt_scan_memory() to call directly") Cc: [email protected] Signed-off-by: Andreas Rammhold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring <[email protected]>
1 parent 1b929c0 commit 2a12187

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

arch/mips/ralink/of.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void __init plat_mem_setup(void)
6464
dtb = get_fdt();
6565
__dt_setup_arch(dtb);
6666

67-
if (!early_init_dt_scan_memory())
67+
if (early_init_dt_scan_memory())
6868
return;
6969

7070
if (soc_info.mem_detect)

drivers/of/fdt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ u64 __init dt_mem_next_cell(int s, const __be32 **cellp)
10991099
*/
11001100
int __init early_init_dt_scan_memory(void)
11011101
{
1102-
int node;
1102+
int node, found_memory = 0;
11031103
const void *fdt = initial_boot_params;
11041104

11051105
fdt_for_each_subnode(node, fdt, 0) {
@@ -1139,6 +1139,8 @@ int __init early_init_dt_scan_memory(void)
11391139

11401140
early_init_dt_add_memory_arch(base, size);
11411141

1142+
found_memory = 1;
1143+
11421144
if (!hotpluggable)
11431145
continue;
11441146

@@ -1147,7 +1149,7 @@ int __init early_init_dt_scan_memory(void)
11471149
base, base + size);
11481150
}
11491151
}
1150-
return 0;
1152+
return found_memory;
11511153
}
11521154

11531155
int __init early_init_dt_scan_chosen(char *cmdline)

0 commit comments

Comments
 (0)