diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-06-05 22:13:19 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-06-05 22:13:19 +0000 |
commit | 4eecec7b2a7d23e31901e0ab42908cc5b88cf01a (patch) | |
tree | e4896937c2ebeb8409bd6a209f03a9cb5ca01b72 /sys | |
parent | bf77f4d0375c1aad695ae5b79bc73635a5a84400 (diff) |
fix dma map handling logic in hme_newbuf(); from jason@.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/hme.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c index 98dab758938..979f229ca43 100644 --- a/sys/dev/ic/hme.c +++ b/sys/dev/ic/hme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hme.c,v 1.14 2002/03/14 01:26:54 millert Exp $ */ +/* $OpenBSD: hme.c,v 1.15 2002/06/05 22:13:18 fgsch Exp $ */ /* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */ /*- @@ -1305,6 +1305,11 @@ hme_newbuf(sc, d, freeit) struct mbuf *m; bus_dmamap_t map; + /* + * All operations should be on local variables and/or rx spare map + * until we're sure everything is a success. + */ + MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) return (ENOBUFS); @@ -1316,28 +1321,26 @@ hme_newbuf(sc, d, freeit) return (ENOBUFS); } - if (d->sd_loaded) { - bus_dmamap_sync(sc->sc_dmatag, d->sd_map, - 0, d->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(sc->sc_dmatag, d->sd_map); - d->sd_loaded = 0; - } - if (bus_dmamap_load(sc->sc_dmatag, sc->sc_rxmap_spare, mtod(m, caddr_t), MCLBYTES - HME_RX_OFFSET, NULL, BUS_DMA_NOWAIT) != 0) { - if (d->sd_mbuf == NULL) - return (ENOBUFS); m_freem(m); return (ENOBUFS); } + /* + * At this point we have a new buffer loaded into the spare map. + * Just need to clear out the old mbuf/map and put the new one + * in place. + */ + if (d->sd_loaded) { - bus_dmamap_sync(sc->sc_dmatag, d->sd_map, 0, - d->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD); + bus_dmamap_sync(sc->sc_dmatag, d->sd_map, + 0, d->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->sc_dmatag, d->sd_map); d->sd_loaded = 0; } + if ((d->sd_mbuf != NULL) && freeit) { m_freem(d->sd_mbuf); d->sd_mbuf = NULL; |