Skip to content

Commit 8347b41

Browse files
Zhen Leirobherring
authored andcommitted
of: fdt: Aggregate the processing of "linux,usable-memory-range"
Currently, we parse the "linux,usable-memory-range" property in early_init_dt_scan_chosen(), to obtain the specified memory range of the crash kernel. We then reserve the required memory after early_init_dt_scan_memory() has identified all available physical memory. Because the two pieces of code are separated far, the readability and maintainability are reduced. So bring them together. Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> (change the prototype of early_init_dt_check_for_usable_mem_range(), in order to use it outside) Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Tested-by: Dave Kleikamp <dave.kleikamp@oracle.com> Acked-by: John Donnelly <john.p.donnelly@oracle.com> Reviewed-by: Rob Herring <robh@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org To: devicetree@vger.kernel.org To: linux-efi@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 75e8953 commit 8347b41

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/of/fdt.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -965,18 +965,22 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)
965965
elfcorehdr_addr, elfcorehdr_size);
966966
}
967967

968-
static phys_addr_t cap_mem_addr;
969-
static phys_addr_t cap_mem_size;
968+
static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND;
970969

971970
/**
972971
* early_init_dt_check_for_usable_mem_range - Decode usable memory range
973972
* location from flat tree
974-
* @node: reference to node containing usable memory range location ('chosen')
975973
*/
976-
static void __init early_init_dt_check_for_usable_mem_range(unsigned long node)
974+
static void __init early_init_dt_check_for_usable_mem_range(void)
977975
{
978976
const __be32 *prop;
979977
int len;
978+
phys_addr_t cap_mem_addr;
979+
phys_addr_t cap_mem_size;
980+
unsigned long node = chosen_node_offset;
981+
982+
if ((long)node < 0)
983+
return;
980984

981985
pr_debug("Looking for usable-memory-range property... ");
982986

@@ -989,6 +993,8 @@ static void __init early_init_dt_check_for_usable_mem_range(unsigned long node)
989993

990994
pr_debug("cap_mem_start=%pa cap_mem_size=%pa\n", &cap_mem_addr,
991995
&cap_mem_size);
996+
997+
memblock_cap_memory_range(cap_mem_addr, cap_mem_size);
992998
}
993999

9941000
#ifdef CONFIG_SERIAL_EARLYCON
@@ -1137,9 +1143,10 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
11371143
(strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
11381144
return 0;
11391145

1146+
chosen_node_offset = node;
1147+
11401148
early_init_dt_check_for_initrd(node);
11411149
early_init_dt_check_for_elfcorehdr(node);
1142-
early_init_dt_check_for_usable_mem_range(node);
11431150

11441151
/* Retrieve command line */
11451152
p = of_get_flat_dt_prop(node, "bootargs", &l);
@@ -1275,7 +1282,7 @@ void __init early_init_dt_scan_nodes(void)
12751282
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
12761283

12771284
/* Handle linux,usable-memory-range property */
1278-
memblock_cap_memory_range(cap_mem_addr, cap_mem_size);
1285+
early_init_dt_check_for_usable_mem_range();
12791286
}
12801287

12811288
bool __init early_init_dt_scan(void *params)

0 commit comments

Comments
 (0)