diff options
author | jhb <jhb@FreeBSD.org> | 2014-06-17 14:47:49 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2014-06-17 14:47:49 +0000 |
commit | c2c10fcea6f7f1fe8e8dc140b4e58917fe2967e6 (patch) | |
tree | 237a911762e2e217590604019af2bd80f748d18c /sys/dev/et/if_et.c | |
parent | e76e4c51ab12e652f3278af6833adf7e0b6696db (diff) | |
download | FreeBSD-src-c2c10fcea6f7f1fe8e8dc140b4e58917fe2967e6.zip FreeBSD-src-c2c10fcea6f7f1fe8e8dc140b4e58917fe2967e6.tar.gz |
Fix teardown of static DMA allocations in various NIC drivers:
- Add missing calls to bus_dmamap_unload() in et(4).
- Check the bus address against 0 to decide when to call
bus_dmamap_unload() instead of comparing the bus_dma map against NULL.
- Check the virtual address against NULL to decide when to call
bus_dmamem_free() instead of comparing the bus_dma map against NULL.
- Don't clear bus_dma map pointers to NULL for static allocations.
Instead, treat the value as completely opaque.
- Pass the correct virtual address to bus_dmamem_free() in wpi(4) instead
of trying to free a pointer to the virtual address.
Reviewed by: yongari
Diffstat (limited to 'sys/dev/et/if_et.c')
-rw-r--r-- | sys/dev/et/if_et.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sys/dev/et/if_et.c b/sys/dev/et/if_et.c index abca427..cd714b0 100644 --- a/sys/dev/et/if_et.c +++ b/sys/dev/et/if_et.c @@ -120,7 +120,7 @@ static int et_dma_ring_alloc(struct et_softc *, bus_size_t, bus_size_t, bus_dma_tag_t *, uint8_t **, bus_dmamap_t *, bus_addr_t *, const char *); static void et_dma_ring_free(struct et_softc *, bus_dma_tag_t *, uint8_t **, - bus_dmamap_t *); + bus_dmamap_t, bus_addr_t *); static void et_init_tx_ring(struct et_softc *); static int et_init_rx_ring(struct et_softc *); static void et_free_tx_ring(struct et_softc *); @@ -841,15 +841,16 @@ et_dma_ring_alloc(struct et_softc *sc, bus_size_t alignment, bus_size_t maxsize, static void et_dma_ring_free(struct et_softc *sc, bus_dma_tag_t *tag, uint8_t **ring, - bus_dmamap_t *map) + bus_dmamap_t map, bus_addr_t *paddr) { - if (*map != NULL) - bus_dmamap_unload(*tag, *map); - if (*map != NULL && *ring != NULL) { - bus_dmamem_free(*tag, *ring, *map); + if (*paddr != 0) { + bus_dmamap_unload(*tag, map); + *paddr = 0; + } + if (*ring != NULL) { + bus_dmamem_free(*tag, *ring, map); *ring = NULL; - *map = NULL; } if (*tag) { bus_dma_tag_destroy(*tag); @@ -1101,27 +1102,27 @@ et_dma_free(struct et_softc *sc) /* Destroy mini RX ring, ring 0. */ rx_ring = &sc->sc_rx_ring[0]; et_dma_ring_free(sc, &rx_ring->rr_dtag, (void *)&rx_ring->rr_desc, - &rx_ring->rr_dmap); + rx_ring->rr_dmap, &rx_ring->rr_paddr); /* Destroy standard RX ring, ring 1. */ rx_ring = &sc->sc_rx_ring[1]; et_dma_ring_free(sc, &rx_ring->rr_dtag, (void *)&rx_ring->rr_desc, - &rx_ring->rr_dmap); + rx_ring->rr_dmap, &rx_ring->rr_paddr); /* Destroy RX stat ring. */ rxst_ring = &sc->sc_rxstat_ring; et_dma_ring_free(sc, &rxst_ring->rsr_dtag, (void *)&rxst_ring->rsr_stat, - &rxst_ring->rsr_dmap); + rxst_ring->rsr_dmap, &rxst_ring->rsr_paddr); /* Destroy RX status block. */ rxsd = &sc->sc_rx_status; et_dma_ring_free(sc, &rxst_ring->rsr_dtag, (void *)&rxst_ring->rsr_stat, - &rxst_ring->rsr_dmap); + rxst_ring->rsr_dmap, &rxst_ring->rsr_paddr); /* Destroy TX ring. */ tx_ring = &sc->sc_tx_ring; et_dma_ring_free(sc, &tx_ring->tr_dtag, (void *)&tx_ring->tr_desc, - &tx_ring->tr_dmap); + tx_ring->tr_dmap, &tx_ring->tr_paddr); /* Destroy TX status block. */ txsd = &sc->sc_tx_status; et_dma_ring_free(sc, &txsd->txsd_dtag, (void *)&txsd->txsd_status, - &txsd->txsd_dmap); + txsd->txsd_dmap, &txsd->txsd_paddr); /* Destroy the parent tag. */ if (sc->sc_dtag) { |