aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ti
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2014-06-17 14:47:49 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2014-06-17 14:47:49 +0000
commitc34f1a08c676b01b6115e83dfe7052d55556c702 (patch)
tree237a911762e2e217590604019af2bd80f748d18c /sys/dev/ti
parent31bcfda84ec3ad17f6f827869991e465c4ece894 (diff)
downloadsrc-c34f1a08c676b01b6115e83dfe7052d55556c702.tar.gz
src-c34f1a08c676b01b6115e83dfe7052d55556c702.zip
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
Notes
Notes: svn path=/head/; revision=267580
Diffstat (limited to 'sys/dev/ti')
-rw-r--r--sys/dev/ti/if_ti.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index bba974bea61f..fa63aa9543bb 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -227,7 +227,7 @@ static void ti_dma_free(struct ti_softc *);
static int ti_dma_ring_alloc(struct ti_softc *, bus_size_t, bus_size_t,
bus_dma_tag_t *, uint8_t **, bus_dmamap_t *, bus_addr_t *, const char *);
static void ti_dma_ring_free(struct ti_softc *, bus_dma_tag_t *, uint8_t **,
- bus_dmamap_t *);
+ bus_dmamap_t, bus_addr_t *);
static int ti_newbuf_std(struct ti_softc *, int);
static int ti_newbuf_mini(struct ti_softc *, int);
static int ti_newbuf_jumbo(struct ti_softc *, int, struct mbuf *);
@@ -1035,15 +1035,16 @@ ti_dma_ring_alloc(struct ti_softc *sc, bus_size_t alignment, bus_size_t maxsize,
static void
ti_dma_ring_free(struct ti_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);
@@ -1336,32 +1337,39 @@ ti_dma_free(struct ti_softc *sc)
/* Destroy standard RX ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_std_ring_tag,
(void *)&sc->ti_rdata.ti_rx_std_ring,
- &sc->ti_cdata.ti_rx_std_ring_map);
+ sc->ti_cdata.ti_rx_std_ring_map,
+ &sc->ti_rdata.ti_rx_std_ring_paddr);
/* Destroy jumbo RX ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_jumbo_ring_tag,
(void *)&sc->ti_rdata.ti_rx_jumbo_ring,
- &sc->ti_cdata.ti_rx_jumbo_ring_map);
+ sc->ti_cdata.ti_rx_jumbo_ring_map,
+ &sc->ti_rdata.ti_rx_jumbo_ring_paddr);
/* Destroy mini RX ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_mini_ring_tag,
(void *)&sc->ti_rdata.ti_rx_mini_ring,
- &sc->ti_cdata.ti_rx_mini_ring_map);
+ sc->ti_cdata.ti_rx_mini_ring_map,
+ &sc->ti_rdata.ti_rx_mini_ring_paddr);
/* Destroy RX return ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_return_ring_tag,
(void *)&sc->ti_rdata.ti_rx_return_ring,
- &sc->ti_cdata.ti_rx_return_ring_map);
+ sc->ti_cdata.ti_rx_return_ring_map,
+ &sc->ti_rdata.ti_rx_return_ring_paddr);
/* Destroy TX ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_tx_ring_tag,
- (void *)&sc->ti_rdata.ti_tx_ring, &sc->ti_cdata.ti_tx_ring_map);
+ (void *)&sc->ti_rdata.ti_tx_ring, sc->ti_cdata.ti_tx_ring_map,
+ &sc->ti_rdata.ti_tx_ring_paddr);
/* Destroy status block. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_status_tag,
- (void *)&sc->ti_rdata.ti_status, &sc->ti_cdata.ti_status_map);
+ (void *)&sc->ti_rdata.ti_status, sc->ti_cdata.ti_status_map,
+ &sc->ti_rdata.ti_status_paddr);
/* Destroy event ring. */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_event_ring_tag,
(void *)&sc->ti_rdata.ti_event_ring,
- &sc->ti_cdata.ti_event_ring_map);
+ sc->ti_cdata.ti_event_ring_map, &sc->ti_rdata.ti_event_ring_paddr);
/* Destroy GIB */
ti_dma_ring_free(sc, &sc->ti_cdata.ti_gib_tag,
- (void *)&sc->ti_rdata.ti_info, &sc->ti_cdata.ti_gib_map);
+ (void *)&sc->ti_rdata.ti_info, sc->ti_cdata.ti_gib_map,
+ &sc->ti_rdata.ti_info_paddr);
/* Destroy the parent tag. */
if (sc->ti_cdata.ti_parent_tag) {