From 159e7744ccd737420b7004ccc2efba3b454a18cf Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 19 Jul 2023 20:26:11 +0000 Subject: [PATCH] Implement "early 2" locator for mainbus(4) and simplebus(4) to make drivers attach even earlier. ok drahn@, deraadt@ --- sys/arch/arm64/dev/mainbus.c | 13 +++++-------- sys/arch/arm64/dev/simplebus.c | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/sys/arch/arm64/dev/mainbus.c b/sys/arch/arm64/dev/mainbus.c index ebe9befdcfd..f1d84d0eb9d 100644 --- a/sys/arch/arm64/dev/mainbus.c +++ b/sys/arch/arm64/dev/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.25 2023/05/19 21:15:16 patrick Exp $ */ +/* $OpenBSD: mainbus.c,v 1.26 2023/07/19 20:26:11 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * Copyright (c) 2017 Mark Kettenis @@ -154,13 +154,10 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) mainbus_attach_apm(self); /* Scan the whole tree. */ - sc->sc_early = 1; - for (node = OF_child(sc->sc_node); node != 0; node = OF_peer(node)) - mainbus_attach_node(self, node, NULL); - - sc->sc_early = 0; - for (node = OF_child(sc->sc_node); node != 0; node = OF_peer(node)) - mainbus_attach_node(self, node, NULL); + for (sc->sc_early = 2; sc->sc_early >= 0; sc->sc_early--) { + for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) + mainbus_attach_node(self, node, NULL); + } mainbus_attach_framebuffer(self); diff --git a/sys/arch/arm64/dev/simplebus.c b/sys/arch/arm64/dev/simplebus.c index e28a6a2a205..4bd468eaa10 100644 --- a/sys/arch/arm64/dev/simplebus.c +++ b/sys/arch/arm64/dev/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.16 2022/11/06 12:01:52 patrick Exp $ */ +/* $OpenBSD: simplebus.c,v 1.17 2023/07/19 20:26:11 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -140,13 +140,10 @@ simplebus_attach(struct device *parent, struct device *self, void *aux) } /* Scan the whole tree. */ - sc->sc_early = 1; - for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) - simplebus_attach_node(self, node); - - sc->sc_early = 0; - for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) - simplebus_attach_node(self, node); + for (sc->sc_early = 2; sc->sc_early >= 0; sc->sc_early--) { + for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) + simplebus_attach_node(self, node); + } } int -- 2.20.1