@@ -967,18 +967,22 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)
967967 elfcorehdr_addr , elfcorehdr_size );
968968}
969969
970- static phys_addr_t cap_mem_addr ;
971- static phys_addr_t cap_mem_size ;
970+ static unsigned long chosen_node_offset = - FDT_ERR_NOTFOUND ;
972971
973972/**
974973 * early_init_dt_check_for_usable_mem_range - Decode usable memory range
975974 * location from flat tree
976- * @node: reference to node containing usable memory range location ('chosen')
977975 */
978- static void __init early_init_dt_check_for_usable_mem_range (unsigned long node )
976+ void __init early_init_dt_check_for_usable_mem_range (void )
979977{
980978 const __be32 * prop ;
981979 int len ;
980+ phys_addr_t cap_mem_addr ;
981+ phys_addr_t cap_mem_size ;
982+ unsigned long node = chosen_node_offset ;
983+
984+ if ((long )node < 0 )
985+ return ;
982986
983987 pr_debug ("Looking for usable-memory-range property... " );
984988
@@ -991,6 +995,8 @@ static void __init early_init_dt_check_for_usable_mem_range(unsigned long node)
991995
992996 pr_debug ("cap_mem_start=%pa cap_mem_size=%pa\n" , & cap_mem_addr ,
993997 & cap_mem_size );
998+
999+ memblock_cap_memory_range (cap_mem_addr , cap_mem_size );
9941000}
9951001
9961002#ifdef CONFIG_SERIAL_EARLYCON
@@ -1143,9 +1149,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
11431149 if (node < 0 )
11441150 return - ENOENT ;
11451151
1152+ chosen_node_offset = node ;
1153+
11461154 early_init_dt_check_for_initrd (node );
11471155 early_init_dt_check_for_elfcorehdr (node );
1148- early_init_dt_check_for_usable_mem_range (node );
11491156
11501157 /* Retrieve command line */
11511158 p = of_get_flat_dt_prop (node , "bootargs" , & l );
@@ -1280,7 +1287,7 @@ void __init early_init_dt_scan_nodes(void)
12801287 early_init_dt_scan_memory ();
12811288
12821289 /* Handle linux,usable-memory-range property */
1283- memblock_cap_memory_range ( cap_mem_addr , cap_mem_size );
1290+ early_init_dt_check_for_usable_mem_range ( );
12841291}
12851292
12861293bool __init early_init_dt_scan (void * params )
0 commit comments