diff options
author | green <green@FreeBSD.org> | 2004-08-02 00:18:36 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2004-08-02 00:18:36 +0000 |
commit | 9532ab7116a36e60ae15ec463c757a7d2e7f9b39 (patch) | |
tree | ff53102435294d83e0ddcbd011824aa65f84e3c8 /sys/dev/en | |
parent | 14a50c4ac0247a8950847156b4fc16cf935c14ca (diff) | |
download | FreeBSD-src-9532ab7116a36e60ae15ec463c757a7d2e7f9b39.zip FreeBSD-src-9532ab7116a36e60ae15ec463c757a7d2e7f9b39.tar.gz |
* Add a "how" argument to uma_zone constructors and initialization functions
so that they know whether the allocation is supposed to be able to sleep
or not.
* Allow uma_zone constructors and initialation functions to return either
success or error. Almost all of the ones in the tree currently return
success unconditionally, but mbuf is a notable exception: the packet
zone constructor wants to be able to fail if it cannot suballocate an
mbuf cluster, and the mbuf allocators want to be able to fail in general
in a MAC kernel if the MAC mbuf initializer fails. This fixes the
panics people are seeing when they run out of memory for mbuf clusters.
* Allow debug.nosleepwithlocks on WITNESS to be disabled, without changing
the default.
Both bmilekic and jeff have reviewed the changes made to make failable
zone allocations work.
Diffstat (limited to 'sys/dev/en')
-rw-r--r-- | sys/dev/en/midway.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index 02096b3..3310838 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -437,25 +437,21 @@ en_dump_packet(struct en_softc *sc, struct mbuf *m) * * LOCK: any, not needed */ -static void -en_map_ctor(void *mem, int size, void *arg) +static int +en_map_ctor(void *mem, int size, void *arg, int flags) { struct en_softc *sc = arg; struct en_map *map = mem; int err; - if (map->sc == NULL) - map->sc = sc; - - if (!(map->flags & ENMAP_ALLOC)) { - err = bus_dmamap_create(sc->txtag, 0, &map->map); - if (err != 0) - if_printf(&sc->ifatm.ifnet, - "cannot create DMA map %d\n", err); - else - map->flags |= ENMAP_ALLOC; + err = bus_dmamap_create(sc->txtag, 0, &map->map); + if (err != 0) { + if_printf(&sc->ifatm.ifnet, "cannot create DMA map %d\n", err); + return (err); } - map->flags &= ~ENMAP_LOADED; + map->flags = ENMAP_ALLOC; + map->sc = sc; + return (0); } /* @@ -490,8 +486,7 @@ en_map_fini(void *mem, int size) { struct en_map *map = mem; - if (map->flags & ENMAP_ALLOC) - bus_dmamap_destroy(map->sc->txtag, map->map); + bus_dmamap_destroy(map->sc->txtag, map->map); } /*********************************************************************/ @@ -1041,11 +1036,9 @@ en_start(struct ifnet *ifp) * locks. */ map = uma_zalloc_arg(sc->map_zone, sc, M_NOWAIT); - if (map == NULL || !(map->flags & ENMAP_ALLOC)) { + if (map == NULL) { /* drop that packet */ EN_COUNT(sc->stats.txnomap); - if (map != NULL) - uma_zfree(sc->map_zone, map); EN_UNLOCK(sc); m_freem(m); continue; @@ -2330,13 +2323,11 @@ en_service(struct en_softc *sc) if (m != NULL) { /* M_NOWAIT - called from interrupt context */ map = uma_zalloc_arg(sc->map_zone, sc, M_NOWAIT); - if (map == NULL || !(map->flags & ENMAP_ALLOC)) { + if (map == NULL) { rx.post_skip += mlen; m_freem(m); DBG(sc, SERV, ("rx%td: out of maps", slot - sc->rxslot)); - if (map->map != NULL) - uma_zfree(sc->map_zone, map); goto skip; } rx.m = m; |