@@ -972,6 +972,32 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)
972
972
elfcorehdr_addr , elfcorehdr_size );
973
973
}
974
974
975
+ static phys_addr_t cap_mem_addr ;
976
+ static phys_addr_t cap_mem_size ;
977
+
978
+ /**
979
+ * early_init_dt_check_for_usable_mem_range - Decode usable memory range
980
+ * location from flat tree
981
+ * @node: reference to node containing usable memory range location ('chosen')
982
+ */
983
+ static void __init early_init_dt_check_for_usable_mem_range (unsigned long node )
984
+ {
985
+ const __be32 * prop ;
986
+ int len ;
987
+
988
+ pr_debug ("Looking for usable-memory-range property... " );
989
+
990
+ prop = of_get_flat_dt_prop (node , "linux,usable-memory-range" , & len );
991
+ if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells )))
992
+ return ;
993
+
994
+ cap_mem_addr = dt_mem_next_cell (dt_root_addr_cells , & prop );
995
+ cap_mem_size = dt_mem_next_cell (dt_root_size_cells , & prop );
996
+
997
+ pr_debug ("cap_mem_start=%pa cap_mem_size=%pa\n" , & cap_mem_addr ,
998
+ & cap_mem_size );
999
+ }
1000
+
975
1001
#ifdef CONFIG_SERIAL_EARLYCON
976
1002
977
1003
int __init early_init_dt_scan_chosen_stdout (void )
@@ -1120,6 +1146,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
1120
1146
1121
1147
early_init_dt_check_for_initrd (node );
1122
1148
early_init_dt_check_for_elfcorehdr (node );
1149
+ early_init_dt_check_for_usable_mem_range (node );
1123
1150
1124
1151
/* Retrieve command line */
1125
1152
p = of_get_flat_dt_prop (node , "bootargs" , & l );
@@ -1253,6 +1280,9 @@ void __init early_init_dt_scan_nodes(void)
1253
1280
1254
1281
/* Setup memory, calling early_init_dt_add_memory_arch */
1255
1282
of_scan_flat_dt (early_init_dt_scan_memory , NULL );
1283
+
1284
+ /* Handle linux,usable-memory-range property */
1285
+ memblock_cap_memory_range (cap_mem_addr , cap_mem_size );
1256
1286
}
1257
1287
1258
1288
bool __init early_init_dt_scan (void * params )
0 commit comments