Hi,

with kettenis' change from 2015(?) we are able to configure ppb(4)'s
that are hotplugged.  I think on detach we should make sure to free the
bus range that was allocated for that device dynamically.  Otherwise
plug and pull can starve the extent.

Feedback?

Patrick

diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c
index 34e3697dd51..a9ff32ce33c 100644
--- a/sys/dev/pci/ppb.c
+++ b/sys/dev/pci/ppb.c
@@ -67,6 +67,7 @@ struct ppb_softc {
        pci_intr_handle_t sc_ih[4];
        void *sc_intrhand;
        struct extent *sc_busex;
+       struct extent *sc_pbusex;
        struct extent *sc_ioex;
        struct extent *sc_memex;
        struct extent *sc_pmemex;
@@ -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_pbusex)
+               extent_free(sc->sc_pbusex, 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_pbusex = pa->pa_busex;
+               sc->sc_busnum = busnum;
+               sc->sc_busrange = busrange;
                *busdata |= pa->pa_bus;
                *busdata |= (busnum << 8);
                *busdata |= ((busnum + busrange - 1) << 16);

Reply via email to