summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-04-16 18:03:07 +0000
committerpatrick <patrick@openbsd.org>2019-04-16 18:03:07 +0000
commit449408a90202e178acd7af3d254f64b67eeb7376 (patch)
tree284ae8f99a23be0a37f175b7021b6eaa6a522a09
parentWhen entering kernel pages uncached we need to make sure to flush the (diff)
downloadwireguard-openbsd-449408a90202e178acd7af3d254f64b67eeb7376.tar.xz
wireguard-openbsd-449408a90202e178acd7af3d254f64b67eeb7376.zip
When we encounter ppb(4)s that are not configured we allocate a range
of bus numbers from the parent's bus extent. On detach, which can happen with hotplug-able devices, we should free those busses. ok kettenis@
-rw-r--r--sys/dev/pci/ppb.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c
index 34e3697dd51..c6146b90bac 100644
--- a/sys/dev/pci/ppb.c
+++ b/sys/dev/pci/ppb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ppb.c,v 1.66 2018/04/06 13:59:30 kettenis Exp $ */
+/* $OpenBSD: ppb.c,v 1.67 2019/04/16 18:03:07 patrick Exp $ */
/* $NetBSD: ppb.c,v 1.16 1997/06/06 23:48:05 thorpej Exp $ */
/*
@@ -66,6 +66,7 @@ struct ppb_softc {
pcitag_t sc_tag; /* ...and tag. */
pci_intr_handle_t sc_ih[4];
void *sc_intrhand;
+ struct extent *sc_parent_busex;
struct extent *sc_busex;
struct extent *sc_ioex;
struct extent *sc_memex;
@@ -77,6 +78,9 @@ struct ppb_softc {
struct task sc_remove_task;
struct timeout sc_to;
+ u_long sc_busnum;
+ u_long sc_busrange;
+
bus_addr_t sc_iobase, sc_iolimit;
bus_addr_t sc_membase, sc_memlimit;
bus_addr_t sc_pmembase, sc_pmemlimit;
@@ -390,6 +394,10 @@ ppbdetach(struct device *self, int flags)
free(name, M_DEVBUF, PPB_EXNAMLEN);
}
+ if (sc->sc_parent_busex)
+ extent_free(sc->sc_parent_busex, sc->sc_busnum,
+ sc->sc_busrange, EX_NOWAIT);
+
return (rv);
}
@@ -529,6 +537,9 @@ ppb_alloc_busrange(struct ppb_softc *sc, struct pci_attach_args *pa,
if (extent_alloc(pa->pa_busex, busrange, 1, 0, 0,
EX_NOWAIT, &busnum))
continue;
+ sc->sc_parent_busex = pa->pa_busex;
+ sc->sc_busnum = busnum;
+ sc->sc_busrange = busrange;
*busdata |= pa->pa_bus;
*busdata |= (busnum << 8);
*busdata |= ((busnum + busrange - 1) << 16);