> Date: Mon, 15 Apr 2019 08:50:04 +0200 > From: Patrick Wildt <patr...@blueri.se> > Content-Type: text/plain; charset="utf-8" > Content-Disposition: inline > > 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?
The only thing I can think of is that the name sc_pbusex is a bitconfusing since we already have sc_pmemex where the "p" stands for prefetchable. Maybe just call it sc_parent_busex? > 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); > >