[PATCH 4/7] ARM: qemu: enable deep probe support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <a.fatoum@xxxxxxxxxxxxxx>
---
Cc: Rouven Czerwinski <r.czerwinski@xxxxxxxxxxxxxx>
---
 arch/arm/boards/qemu-virt/board.c | 37 ++++++-------------------------
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c
index b2a3cb29ab09..1333687918e1 100644
--- a/arch/arm/boards/qemu-virt/board.c
+++ b/arch/arm/boards/qemu-virt/board.c
@@ -6,8 +6,8 @@
 #include <common.h>
 #include <init.h>
 #include <of.h>
+#include <deep-probe.h>
 #include <asm/system_info.h>
-#include <asm/barebox-arm.h>
 
 #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",
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux