Skip to content

Commit 40f18db

Browse files
bebarinorobherring
authored andcommitted
x86/of: Unconditionally call unflatten_and_copy_device_tree()
Call this function unconditionally so that we can populate an empty DTB on platforms that don't boot with a firmware provided or builtin DTB. There's no harm in calling unflatten_device_tree() unconditionally here. If there isn't a non-NULL 'initial_boot_params' pointer then unflatten_device_tree() returns early. Cc: Rob Herring <[email protected]> Cc: Frank Rowand <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: H. Peter Anvin <[email protected]> Tested-by: Saurabh Sengar <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring <[email protected]>
1 parent 221a819 commit 40f18db

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

arch/x86/kernel/devicetree.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,24 @@ void __init x86_flattree_get_config(void)
283283
u32 size, map_len;
284284
void *dt;
285285

286-
if (!initial_dtb)
287-
return;
288-
289-
map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128);
286+
if (initial_dtb) {
287+
map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128);
288+
289+
dt = early_memremap(initial_dtb, map_len);
290+
size = fdt_totalsize(dt);
291+
if (map_len < size) {
292+
early_memunmap(dt, map_len);
293+
dt = early_memremap(initial_dtb, size);
294+
map_len = size;
295+
}
290296

291-
dt = early_memremap(initial_dtb, map_len);
292-
size = fdt_totalsize(dt);
293-
if (map_len < size) {
294-
early_memunmap(dt, map_len);
295-
dt = early_memremap(initial_dtb, size);
296-
map_len = size;
297+
early_init_dt_verify(dt);
297298
}
298299

299-
early_init_dt_verify(dt);
300300
unflatten_and_copy_device_tree();
301-
early_memunmap(dt, map_len);
301+
302+
if (initial_dtb)
303+
early_memunmap(dt, map_len);
302304
}
303305
#endif
304306

0 commit comments

Comments
 (0)