diff options
author | 2019-04-16 13:16:06 +0000 | |
---|---|---|
committer | 2019-04-16 13:16:06 +0000 | |
commit | 2a1245a1658648a18e7cc6071aef722b4898055c (patch) | |
tree | 6600272c0d3d06b112196f87a94dae0227e75d7b | |
parent | Use the actual cluster size instead of fixed MCLBYTES for the (diff) | |
download | wireguard-openbsd-2a1245a1658648a18e7cc6071aef722b4898055c.tar.xz wireguard-openbsd-2a1245a1658648a18e7cc6071aef722b4898055c.zip |
Prevent attaching drivers to devices for which we attached a driver early.
ok patrick@, dlg@, visa@
-rw-r--r-- | sys/arch/arm/simplebus/simplebus.c | 25 | ||||
-rw-r--r-- | sys/arch/arm/simplebus/simplebusvar.h | 3 |
2 files changed, 24 insertions, 4 deletions
diff --git a/sys/arch/arm/simplebus/simplebus.c b/sys/arch/arm/simplebus/simplebus.c index 1742a336bcf..94feea46df2 100644 --- a/sys/arch/arm/simplebus/simplebus.c +++ b/sys/arch/arm/simplebus/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.14 2019/01/05 03:42:19 jsg Exp $ */ +/* $OpenBSD: simplebus.c,v 1.15 2019/04/16 13:16:06 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -146,6 +146,7 @@ simplebus_attach_node(struct device *self, int node) char buf[32]; int i, len, line; uint32_t *cell, *reg; + struct device *child; if (OF_getproplen(node, "compatible") <= 0) return; @@ -154,6 +155,14 @@ simplebus_attach_node(struct device *self, int node) strcmp(buf, "disabled") == 0) return; + /* Skip if already attached early. */ + for (i = 0; i < nitems(sc->sc_early_nodes); i++) { + if (sc->sc_early_nodes[i] == node) + return; + if (sc->sc_early_nodes[i] == 0) + break; + } + memset(&fa, 0, sizeof(fa)); fa.fa_name = ""; fa.fa_node = node; @@ -200,8 +209,18 @@ simplebus_attach_node(struct device *self, int node) OF_getpropintarray(node, "interrupts", fa.fa_intr, len); } - config_found_sm(self, &fa, sc->sc_early ? NULL : simplebus_print, - simplebus_submatch); + child = config_found_sm(self, &fa, sc->sc_early ? NULL : + simplebus_print, simplebus_submatch); + + /* Record nodes that we attach early. */ + if (child && sc->sc_early) { + for (i = 0; i < nitems(sc->sc_early_nodes); i++) { + if (sc->sc_early_nodes[i] != 0) + continue; + sc->sc_early_nodes[i] = node; + break; + } + } free(fa.fa_reg, M_DEVBUF, fa.fa_nreg * sizeof(struct fdt_reg)); free(fa.fa_intr, M_DEVBUF, fa.fa_nintr * sizeof(uint32_t)); diff --git a/sys/arch/arm/simplebus/simplebusvar.h b/sys/arch/arm/simplebus/simplebusvar.h index 597ebe5aa2e..0e044f5d2a2 100644 --- a/sys/arch/arm/simplebus/simplebusvar.h +++ b/sys/arch/arm/simplebus/simplebusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebusvar.h,v 1.1 2016/10/21 20:09:49 patrick Exp $ */ +/* $OpenBSD: simplebusvar.h,v 1.2 2019/04/16 13:16:06 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -28,6 +28,7 @@ struct simplebus_softc { int *sc_ranges; int sc_rangeslen; int sc_early; + int sc_early_nodes[64]; }; extern void simplebus_attach(struct device *, struct device *, void *); |