From d1785c8a68e47900569ff18389426f53c841f38c Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 25 Nov 2021 17:10:39 +0100 Subject: ARM: qemu: enable deep probe support It's a bug to call barebox_register_of at pure_initcall level, because device tree probe may depend on other initialization done at pure_initcall. For example, if the QEMU-supplied Virt device tree had a model, barebox would attempt to register a new global variable before the global device is even initialized. With the move to deep probe we can just do overlay fixup in the board driver at safe postcore level. Fixes: ff8b098a4ad2 ("ARM: qemu: support for state & env via DT overlay") Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20211125161042.3829996-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- arch/arm/boards/qemu-virt/board.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c index b2a3cb29ab..1333687918 100644 --- a/arch/arm/boards/qemu-virt/board.c +++ b/arch/arm/boards/qemu-virt/board.c @@ -6,8 +6,8 @@ #include #include #include +#include #include -#include #ifdef CONFIG_64BIT #define MACHINE "virt64" @@ -17,38 +17,10 @@ extern char __dtb_overlay_of_flash_start[]; -static int replace_dtb(void) { - struct device_node *overlay; - void *fdt; - struct device_node *root; - - fdt = barebox_arm_boot_dtb(); - if (fdt) - pr_debug("using boarddata provided DTB\n"); - - if (!fdt) { - pr_debug("No DTB found\n"); - return 0; - } - - root = of_unflatten_dtb(fdt, INT_MAX); - - if (!of_device_is_compatible(root, "linux,dummy-virt")) { - of_delete_node(root); - return 0; - } - - overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX); - of_overlay_apply_tree(root, overlay); - - return barebox_register_of(root); -} - -pure_initcall(replace_dtb); - static int virt_probe(struct device_d *dev) { const char *hostname = MACHINE; + struct device_node *overlay; if (cpu_is_cortex_a7()) hostname = "virt-a7"; @@ -58,6 +30,10 @@ static int virt_probe(struct device_d *dev) barebox_set_model("ARM QEMU " MACHINE); barebox_set_hostname(hostname); + overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX); + of_overlay_apply_tree(dev->device_node, overlay); + /* of_probe() will happen later at of_populate_initcall */ + return 0; } @@ -65,6 +41,7 @@ static const struct of_device_id virt_of_match[] = { { .compatible = "linux,dummy-virt" }, { /* Sentinel */}, }; +BAREBOX_DEEP_PROBE_ENABLE(virt_of_match); static struct driver_d virt_board_driver = { .name = "board-qemu-virt", -- cgit v1.2.3