@@ -967,18 +967,22 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)
967
967
elfcorehdr_addr , elfcorehdr_size );
968
968
}
969
969
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 ;
972
971
973
972
/**
974
973
* early_init_dt_check_for_usable_mem_range - Decode usable memory range
975
974
* location from flat tree
976
- * @node: reference to node containing usable memory range location ('chosen')
977
975
*/
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 )
979
977
{
980
978
const __be32 * prop ;
981
979
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 ;
982
986
983
987
pr_debug ("Looking for usable-memory-range property... " );
984
988
@@ -991,6 +995,8 @@ static void __init early_init_dt_check_for_usable_mem_range(unsigned long node)
991
995
992
996
pr_debug ("cap_mem_start=%pa cap_mem_size=%pa\n" , & cap_mem_addr ,
993
997
& cap_mem_size );
998
+
999
+ memblock_cap_memory_range (cap_mem_addr , cap_mem_size );
994
1000
}
995
1001
996
1002
#ifdef CONFIG_SERIAL_EARLYCON
@@ -1143,9 +1149,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
1143
1149
if (node < 0 )
1144
1150
return - ENOENT ;
1145
1151
1152
+ chosen_node_offset = node ;
1153
+
1146
1154
early_init_dt_check_for_initrd (node );
1147
1155
early_init_dt_check_for_elfcorehdr (node );
1148
- early_init_dt_check_for_usable_mem_range (node );
1149
1156
1150
1157
/* Retrieve command line */
1151
1158
p = of_get_flat_dt_prop (node , "bootargs" , & l );
@@ -1280,7 +1287,7 @@ void __init early_init_dt_scan_nodes(void)
1280
1287
early_init_dt_scan_memory ();
1281
1288
1282
1289
/* 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 ( );
1284
1291
}
1285
1292
1286
1293
bool __init early_init_dt_scan (void * params )
0 commit comments