diff options
author | 2019-04-16 13:15:31 +0000 | |
---|---|---|
committer | 2019-04-16 13:15:31 +0000 | |
commit | d45a5b64abd387cacc9c97a01693f44af4c4bc36 (patch) | |
tree | b35f00300134cbf60a89903e181cf660b0e19a65 | |
parent | i2c reads are more reliable a byte at a time. (diff) | |
download | wireguard-openbsd-d45a5b64abd387cacc9c97a01693f44af4c4bc36.tar.xz wireguard-openbsd-d45a5b64abd387cacc9c97a01693f44af4c4bc36.zip |
Prevent attaching drivers to devices for which we attached a driver early.
ok patrick@, dlg@, visa@
-rw-r--r-- | sys/arch/arm64/dev/simplebus.c | 25 | ||||
-rw-r--r-- | sys/arch/arm64/dev/simplebusvar.h | 3 |
2 files changed, 24 insertions, 4 deletions
diff --git a/sys/arch/arm64/dev/simplebus.c b/sys/arch/arm64/dev/simplebus.c index 652279f6b80..87256d2693b 100644 --- a/sys/arch/arm64/dev/simplebus.c +++ b/sys/arch/arm64/dev/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.10 2019/03/07 07:58:26 patrick Exp $ */ +/* $OpenBSD: simplebus.c,v 1.11 2019/04/16 13:15:31 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -180,6 +180,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; @@ -188,6 +189,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; @@ -241,8 +250,18 @@ simplebus_attach_node(struct device *self, int node) fa.fa_dmat->_flags |= BUS_DMA_COHERENT; } - 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/arm64/dev/simplebusvar.h b/sys/arch/arm64/dev/simplebusvar.h index 084c17bbfbe..5b236c1b162 100644 --- a/sys/arch/arm64/dev/simplebusvar.h +++ b/sys/arch/arm64/dev/simplebusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebusvar.h,v 1.2 2017/01/23 10:46:02 kettenis Exp $ */ +/* $OpenBSD: simplebusvar.h,v 1.3 2019/04/16 13:15:31 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -31,6 +31,7 @@ struct simplebus_softc { int *sc_dmaranges; int sc_dmarangeslen; int sc_early; + int sc_early_nodes[64]; }; extern void simplebus_attach(struct device *, struct device *, void *); |