Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jun 2014 14:53:59 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267363 - in head/sys: arm/at91 arm/cavium/cns11xx dev/ae dev/age dev/alc dev/ale dev/bfe dev/bge dev/dc dev/jme dev/msk dev/nge dev/re dev/sf dev/sge dev/sis dev/sk dev/ste dev/stge de...
Message-ID:  <201406111453.s5BErxFT022932@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jun 11 14:53:58 2014
New Revision: 267363
URL: http://svnweb.freebsd.org/changeset/base/267363

Log:
  Fix various NIC drivers to properly cleanup static DMA resources.
  In particular, don't check the value of the bus_dma map against NULL
  to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded.
  Instead, assume that bus_dmamap_load() succeeeded (and thus that
  bus_dmamap_unload() should be called) if the bus address for a resource
  is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus
  that bus_dmamem_free() should be called) if the virtual address for a
  resource is not NULL.
  
  In many cases these bugs could result in leaks when a driver was detached.
  
  Reviewed by:	yongari
  MFC after:	2 weeks

Modified:
  head/sys/arm/at91/if_macb.c
  head/sys/arm/cavium/cns11xx/if_ece.c
  head/sys/dev/ae/if_ae.c
  head/sys/dev/age/if_age.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/bfe/if_bfe.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/dc/if_dc.c
  head/sys/dev/jme/if_jme.c
  head/sys/dev/msk/if_msk.c
  head/sys/dev/nge/if_nge.c
  head/sys/dev/re/if_re.c
  head/sys/dev/sf/if_sf.c
  head/sys/dev/sge/if_sge.c
  head/sys/dev/sis/if_sis.c
  head/sys/dev/sk/if_sk.c
  head/sys/dev/ste/if_ste.c
  head/sys/dev/stge/if_stge.c
  head/sys/dev/vge/if_vge.c
  head/sys/dev/vr/if_vr.c
  head/sys/dev/vte/if_vte.c
  head/sys/mips/atheros/if_arge.c
  head/sys/mips/idt/if_kr.c
  head/sys/pci/if_rl.c

Modified: head/sys/arm/at91/if_macb.c
==============================================================================
--- head/sys/arm/at91/if_macb.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/arm/at91/if_macb.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -258,14 +258,14 @@ macb_free_desc_dma_tx(struct macb_softc 
 
 	/* TX descriptor ring. */
 	if (sc->dmatag_data_tx != NULL) {
-		if (sc->dmamap_ring_tx != NULL)
+		if (sc->ring_paddr_tx != 0)
 			bus_dmamap_unload(sc->dmatag_data_tx,
 			    sc->dmamap_ring_tx);
-		if (sc->dmamap_ring_tx != NULL && sc->desc_tx != NULL)
+		if (sc->desc_tx != NULL)
 			bus_dmamem_free(sc->dmatag_data_tx, sc->desc_tx,
 			    sc->dmamap_ring_tx);
-		sc->dmamap_ring_tx = NULL;
-		sc->dmamap_ring_tx = NULL;
+		sc->ring_paddr_tx = 0;
+		sc->desc_tx = NULL;
 		bus_dma_tag_destroy(sc->dmatag_data_tx);
 		sc->dmatag_data_tx = NULL;
 	}
@@ -389,15 +389,14 @@ macb_free_desc_dma_rx(struct macb_softc 
 	}
 	/* RX descriptor ring. */
 	if (sc->dmatag_data_rx != NULL) {
-		if (sc->dmamap_ring_rx != NULL)
+		if (sc->ring_paddr_rx != 0)
 			bus_dmamap_unload(sc->dmatag_data_rx,
 			    sc->dmamap_ring_rx);
-		if (sc->dmamap_ring_rx != NULL &&
-		    sc->desc_rx != NULL)
+		if (sc->desc_rx != NULL)
 			bus_dmamem_free(sc->dmatag_data_rx, sc->desc_rx,
 			    sc->dmamap_ring_rx);
+		sc->ring_paddr_rx = 0;
 		sc->desc_rx = NULL;
-		sc->dmamap_ring_rx = NULL;
 		bus_dma_tag_destroy(sc->dmatag_data_rx);
 		sc->dmatag_data_rx = NULL;
 	}

Modified: head/sys/arm/cavium/cns11xx/if_ece.c
==============================================================================
--- head/sys/arm/cavium/cns11xx/if_ece.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/arm/cavium/cns11xx/if_ece.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -565,13 +565,15 @@ ece_free_desc_dma_tx(struct ece_softc *s
 		}
 	}
 
-	if (sc->dmamap_ring_tx) {
+	if (sc->ring_paddr_tx) {
 		bus_dmamap_unload(sc->dmatag_data_tx, sc->dmamap_ring_tx);
-		if (sc->desc_tx) {
-			bus_dmamem_free(sc->dmatag_data_tx,
-			    sc->desc_tx, sc->dmamap_ring_tx);
-		}
-		sc->dmamap_ring_tx = 0;
+		sc->ring_paddr_tx = 0;
+	}
+
+	if (sc->desc_tx) {
+		bus_dmamem_free(sc->dmatag_data_tx,
+		    sc->desc_tx, sc->dmamap_ring_tx);
+		sc->desc_tx = NULL;
 	}
 
 	if (sc->dmatag_data_tx) {
@@ -679,18 +681,24 @@ ece_free_desc_dma_rx(struct ece_softc *s
 	for (i = 0; i < ECE_MAX_RX_BUFFERS; i++) {
 		if (sc->rx_desc[i].buff) {
 			m_freem(sc->rx_desc[i].buff);
-			sc->rx_desc[i].buff= 0;
+			sc->rx_desc[i].buff = NULL;
 		}
 	}
 
-	if (sc->dmatag_data_rx) {
+	if (sc->ring_paddr_rx) {
 		bus_dmamap_unload(sc->dmatag_data_rx, sc->dmamap_ring_rx);
+		sc->ring_paddr_rx = 0;
+	}
+
+	if (sc->desc_rx) {
 		bus_dmamem_free(sc->dmatag_data_rx, sc->desc_rx,
 		    sc->dmamap_ring_rx);
+		sc->desc_rx = NULL;
+	}
+
+	if (sc->dmatag_data_rx) {
 		bus_dma_tag_destroy(sc->dmatag_data_rx);
-		sc->dmatag_data_rx = 0;
-		sc->dmamap_ring_rx = 0;
-		sc->desc_rx = 0;
+		sc->dmatag_data_rx = NULL;
 	}
 
 	if (sc->dmatag_ring_rx) {
@@ -699,7 +707,7 @@ ece_free_desc_dma_rx(struct ece_softc *s
 			    sc->rx_desc[i].dmamap);
 		bus_dmamap_destroy(sc->dmatag_ring_rx, sc->rx_sparemap);
 		bus_dma_tag_destroy(sc->dmatag_ring_rx);
-		sc->dmatag_ring_rx = 0;
+		sc->dmatag_ring_rx = NULL;
 	}
 }
 

Modified: head/sys/dev/ae/if_ae.c
==============================================================================
--- head/sys/dev/ae/if_ae.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/ae/if_ae.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1226,43 +1226,37 @@ ae_dma_free(ae_softc_t *sc)
 {
 
 	if (sc->dma_txd_tag != NULL) {
-		if (sc->dma_txd_map != NULL) {
+		if (sc->dma_txd_busaddr != 0)
 			bus_dmamap_unload(sc->dma_txd_tag, sc->dma_txd_map);
-			if (sc->txd_base != NULL)
-				bus_dmamem_free(sc->dma_txd_tag, sc->txd_base,
-				    sc->dma_txd_map);
-
-		}
+		if (sc->txd_base != NULL)
+			bus_dmamem_free(sc->dma_txd_tag, sc->txd_base,
+			    sc->dma_txd_map);
 		bus_dma_tag_destroy(sc->dma_txd_tag);
-		sc->dma_txd_map = NULL;
 		sc->dma_txd_tag = NULL;
 		sc->txd_base = NULL;
+		sc->dma_txd_busaddr = 0;
 	}
 	if (sc->dma_txs_tag != NULL) {
-		if (sc->dma_txs_map != NULL) {
+		if (sc->dma_txs_busaddr != 0)
 			bus_dmamap_unload(sc->dma_txs_tag, sc->dma_txs_map);
-			if (sc->txs_base != NULL)
-				bus_dmamem_free(sc->dma_txs_tag, sc->txs_base,
-				    sc->dma_txs_map);
-
-		}
+		if (sc->txs_base != NULL)
+			bus_dmamem_free(sc->dma_txs_tag, sc->txs_base,
+			    sc->dma_txs_map);
 		bus_dma_tag_destroy(sc->dma_txs_tag);
-		sc->dma_txs_map = NULL;
 		sc->dma_txs_tag = NULL;
 		sc->txs_base = NULL;
+		sc->dma_txs_busaddr = 0;
 	}
 	if (sc->dma_rxd_tag != NULL) {
-		if (sc->dma_rxd_map != NULL) {
+		if (sc->dma_rxd_busaddr != 0)
 			bus_dmamap_unload(sc->dma_rxd_tag, sc->dma_rxd_map);
-			if (sc->rxd_base_dma != NULL)
-				bus_dmamem_free(sc->dma_rxd_tag,
-				    sc->rxd_base_dma, sc->dma_rxd_map);
-
-		}
+		if (sc->rxd_base_dma != NULL)
+			bus_dmamem_free(sc->dma_rxd_tag, sc->rxd_base_dma,
+			    sc->dma_rxd_map);
 		bus_dma_tag_destroy(sc->dma_rxd_tag);
-		sc->dma_rxd_map = NULL;
 		sc->dma_rxd_tag = NULL;
 		sc->rxd_base_dma = NULL;
+		sc->dma_rxd_busaddr = 0;
 	}
 	if (sc->dma_parent_tag != NULL) {
 		bus_dma_tag_destroy(sc->dma_parent_tag);

Modified: head/sys/dev/age/if_age.c
==============================================================================
--- head/sys/dev/age/if_age.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/age/if_age.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1229,76 +1229,71 @@ age_dma_free(struct age_softc *sc)
 	}
 	/* Tx ring. */
 	if (sc->age_cdata.age_tx_ring_tag != NULL) {
-		if (sc->age_cdata.age_tx_ring_map != NULL)
+		if (sc->age_rdata.age_tx_ring_paddr != 0)
 			bus_dmamap_unload(sc->age_cdata.age_tx_ring_tag,
 			    sc->age_cdata.age_tx_ring_map);
-		if (sc->age_cdata.age_tx_ring_map != NULL &&
-		    sc->age_rdata.age_tx_ring != NULL)
+		if (sc->age_rdata.age_tx_ring != NULL)
 			bus_dmamem_free(sc->age_cdata.age_tx_ring_tag,
 			    sc->age_rdata.age_tx_ring,
 			    sc->age_cdata.age_tx_ring_map);
+		sc->age_rdata.age_tx_ring_paddr = 0;
 		sc->age_rdata.age_tx_ring = NULL;
-		sc->age_cdata.age_tx_ring_map = NULL;
 		bus_dma_tag_destroy(sc->age_cdata.age_tx_ring_tag);
 		sc->age_cdata.age_tx_ring_tag = NULL;
 	}
 	/* Rx ring. */
 	if (sc->age_cdata.age_rx_ring_tag != NULL) {
-		if (sc->age_cdata.age_rx_ring_map != NULL)
+		if (sc->age_rdata.age_rx_ring_paddr != 0)
 			bus_dmamap_unload(sc->age_cdata.age_rx_ring_tag,
 			    sc->age_cdata.age_rx_ring_map);
-		if (sc->age_cdata.age_rx_ring_map != NULL &&
-		    sc->age_rdata.age_rx_ring != NULL)
+		if (sc->age_rdata.age_rx_ring != NULL)
 			bus_dmamem_free(sc->age_cdata.age_rx_ring_tag,
 			    sc->age_rdata.age_rx_ring,
 			    sc->age_cdata.age_rx_ring_map);
+		sc->age_rdata.age_rx_ring_paddr = 0;
 		sc->age_rdata.age_rx_ring = NULL;
-		sc->age_cdata.age_rx_ring_map = NULL;
 		bus_dma_tag_destroy(sc->age_cdata.age_rx_ring_tag);
 		sc->age_cdata.age_rx_ring_tag = NULL;
 	}
 	/* Rx return ring. */
 	if (sc->age_cdata.age_rr_ring_tag != NULL) {
-		if (sc->age_cdata.age_rr_ring_map != NULL)
+		if (sc->age_rdata.age_rr_ring_paddr != 0)
 			bus_dmamap_unload(sc->age_cdata.age_rr_ring_tag,
 			    sc->age_cdata.age_rr_ring_map);
-		if (sc->age_cdata.age_rr_ring_map != NULL &&
-		    sc->age_rdata.age_rr_ring != NULL)
+		if (sc->age_rdata.age_rr_ring != NULL)
 			bus_dmamem_free(sc->age_cdata.age_rr_ring_tag,
 			    sc->age_rdata.age_rr_ring,
 			    sc->age_cdata.age_rr_ring_map);
+		sc->age_rdata.age_rr_ring_paddr = 0;
 		sc->age_rdata.age_rr_ring = NULL;
-		sc->age_cdata.age_rr_ring_map = NULL;
 		bus_dma_tag_destroy(sc->age_cdata.age_rr_ring_tag);
 		sc->age_cdata.age_rr_ring_tag = NULL;
 	}
 	/* CMB block */
 	if (sc->age_cdata.age_cmb_block_tag != NULL) {
-		if (sc->age_cdata.age_cmb_block_map != NULL)
+		if (sc->age_rdata.age_cmb_block_paddr != 0)
 			bus_dmamap_unload(sc->age_cdata.age_cmb_block_tag,
 			    sc->age_cdata.age_cmb_block_map);
-		if (sc->age_cdata.age_cmb_block_map != NULL &&
-		    sc->age_rdata.age_cmb_block != NULL)
+		if (sc->age_rdata.age_cmb_block != NULL)
 			bus_dmamem_free(sc->age_cdata.age_cmb_block_tag,
 			    sc->age_rdata.age_cmb_block,
 			    sc->age_cdata.age_cmb_block_map);
+		sc->age_rdata.age_cmb_block_paddr = 0;
 		sc->age_rdata.age_cmb_block = NULL;
-		sc->age_cdata.age_cmb_block_map = NULL;
 		bus_dma_tag_destroy(sc->age_cdata.age_cmb_block_tag);
 		sc->age_cdata.age_cmb_block_tag = NULL;
 	}
 	/* SMB block */
 	if (sc->age_cdata.age_smb_block_tag != NULL) {
-		if (sc->age_cdata.age_smb_block_map != NULL)
+		if (sc->age_rdata.age_smb_block_paddr != 0)
 			bus_dmamap_unload(sc->age_cdata.age_smb_block_tag,
 			    sc->age_cdata.age_smb_block_map);
-		if (sc->age_cdata.age_smb_block_map != NULL &&
-		    sc->age_rdata.age_smb_block != NULL)
+		if (sc->age_rdata.age_smb_block != NULL)
 			bus_dmamem_free(sc->age_cdata.age_smb_block_tag,
 			    sc->age_rdata.age_smb_block,
 			    sc->age_cdata.age_smb_block_map);
+		sc->age_rdata.age_smb_block_paddr = 0;
 		sc->age_rdata.age_smb_block = NULL;
-		sc->age_cdata.age_smb_block_map = NULL;
 		bus_dma_tag_destroy(sc->age_cdata.age_smb_block_tag);
 		sc->age_cdata.age_smb_block_tag = NULL;
 	}

Modified: head/sys/dev/alc/if_alc.c
==============================================================================
--- head/sys/dev/alc/if_alc.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/alc/if_alc.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1735,76 +1735,71 @@ alc_dma_free(struct alc_softc *sc)
 	}
 	/* Tx descriptor ring. */
 	if (sc->alc_cdata.alc_tx_ring_tag != NULL) {
-		if (sc->alc_cdata.alc_tx_ring_map != NULL)
+		if (sc->alc_rdata.alc_tx_ring_paddr != 0)
 			bus_dmamap_unload(sc->alc_cdata.alc_tx_ring_tag,
 			    sc->alc_cdata.alc_tx_ring_map);
-		if (sc->alc_cdata.alc_tx_ring_map != NULL &&
-		    sc->alc_rdata.alc_tx_ring != NULL)
+		if (sc->alc_rdata.alc_tx_ring != NULL)
 			bus_dmamem_free(sc->alc_cdata.alc_tx_ring_tag,
 			    sc->alc_rdata.alc_tx_ring,
 			    sc->alc_cdata.alc_tx_ring_map);
+		sc->alc_rdata.alc_tx_ring_paddr = 0;
 		sc->alc_rdata.alc_tx_ring = NULL;
-		sc->alc_cdata.alc_tx_ring_map = NULL;
 		bus_dma_tag_destroy(sc->alc_cdata.alc_tx_ring_tag);
 		sc->alc_cdata.alc_tx_ring_tag = NULL;
 	}
 	/* Rx ring. */
 	if (sc->alc_cdata.alc_rx_ring_tag != NULL) {
-		if (sc->alc_cdata.alc_rx_ring_map != NULL)
+		if (sc->alc_rdata.alc_rx_ring_paddr != 0)
 			bus_dmamap_unload(sc->alc_cdata.alc_rx_ring_tag,
 			    sc->alc_cdata.alc_rx_ring_map);
-		if (sc->alc_cdata.alc_rx_ring_map != NULL &&
-		    sc->alc_rdata.alc_rx_ring != NULL)
+		if (sc->alc_rdata.alc_rx_ring != NULL)
 			bus_dmamem_free(sc->alc_cdata.alc_rx_ring_tag,
 			    sc->alc_rdata.alc_rx_ring,
 			    sc->alc_cdata.alc_rx_ring_map);
+		sc->alc_rdata.alc_rx_ring_paddr = 0;
 		sc->alc_rdata.alc_rx_ring = NULL;
-		sc->alc_cdata.alc_rx_ring_map = NULL;
 		bus_dma_tag_destroy(sc->alc_cdata.alc_rx_ring_tag);
 		sc->alc_cdata.alc_rx_ring_tag = NULL;
 	}
 	/* Rx return ring. */
 	if (sc->alc_cdata.alc_rr_ring_tag != NULL) {
-		if (sc->alc_cdata.alc_rr_ring_map != NULL)
+		if (sc->alc_rdata.alc_rr_ring_paddr != 0)
 			bus_dmamap_unload(sc->alc_cdata.alc_rr_ring_tag,
 			    sc->alc_cdata.alc_rr_ring_map);
-		if (sc->alc_cdata.alc_rr_ring_map != NULL &&
-		    sc->alc_rdata.alc_rr_ring != NULL)
+		if (sc->alc_rdata.alc_rr_ring != NULL)
 			bus_dmamem_free(sc->alc_cdata.alc_rr_ring_tag,
 			    sc->alc_rdata.alc_rr_ring,
 			    sc->alc_cdata.alc_rr_ring_map);
+		sc->alc_rdata.alc_rr_ring_paddr = 0;
 		sc->alc_rdata.alc_rr_ring = NULL;
-		sc->alc_cdata.alc_rr_ring_map = NULL;
 		bus_dma_tag_destroy(sc->alc_cdata.alc_rr_ring_tag);
 		sc->alc_cdata.alc_rr_ring_tag = NULL;
 	}
 	/* CMB block */
 	if (sc->alc_cdata.alc_cmb_tag != NULL) {
-		if (sc->alc_cdata.alc_cmb_map != NULL)
+		if (sc->alc_rdata.alc_cmb_paddr != 0)
 			bus_dmamap_unload(sc->alc_cdata.alc_cmb_tag,
 			    sc->alc_cdata.alc_cmb_map);
-		if (sc->alc_cdata.alc_cmb_map != NULL &&
-		    sc->alc_rdata.alc_cmb != NULL)
+		if (sc->alc_rdata.alc_cmb != NULL)
 			bus_dmamem_free(sc->alc_cdata.alc_cmb_tag,
 			    sc->alc_rdata.alc_cmb,
-			    sc->alc_cdata.alc_cmb_map);
+			    sc->alc_cdata.alc_cmb_map);		
+		sc->alc_rdata.alc_cmb_paddr = 0;
 		sc->alc_rdata.alc_cmb = NULL;
-		sc->alc_cdata.alc_cmb_map = NULL;
 		bus_dma_tag_destroy(sc->alc_cdata.alc_cmb_tag);
 		sc->alc_cdata.alc_cmb_tag = NULL;
 	}
 	/* SMB block */
 	if (sc->alc_cdata.alc_smb_tag != NULL) {
-		if (sc->alc_cdata.alc_smb_map != NULL)
+		if (sc->alc_rdata.alc_smb_paddr != 0)
 			bus_dmamap_unload(sc->alc_cdata.alc_smb_tag,
 			    sc->alc_cdata.alc_smb_map);
-		if (sc->alc_cdata.alc_smb_map != NULL &&
-		    sc->alc_rdata.alc_smb != NULL)
+		if (sc->alc_rdata.alc_smb != NULL)
 			bus_dmamem_free(sc->alc_cdata.alc_smb_tag,
 			    sc->alc_rdata.alc_smb,
 			    sc->alc_cdata.alc_smb_map);
+		sc->alc_rdata.alc_smb_paddr = 0;
 		sc->alc_rdata.alc_smb = NULL;
-		sc->alc_cdata.alc_smb_map = NULL;
 		bus_dma_tag_destroy(sc->alc_cdata.alc_smb_tag);
 		sc->alc_cdata.alc_smb_tag = NULL;
 	}

Modified: head/sys/dev/ale/if_ale.c
==============================================================================
--- head/sys/dev/ale/if_ale.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/ale/if_ale.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1330,34 +1330,32 @@ ale_dma_free(struct ale_softc *sc)
 	}
 	/* Tx descriptor ring. */
 	if (sc->ale_cdata.ale_tx_ring_tag != NULL) {
-		if (sc->ale_cdata.ale_tx_ring_map != NULL)
+		if (sc->ale_cdata.ale_tx_ring_paddr != 0)
 			bus_dmamap_unload(sc->ale_cdata.ale_tx_ring_tag,
 			    sc->ale_cdata.ale_tx_ring_map);
-		if (sc->ale_cdata.ale_tx_ring_map != NULL &&
-		    sc->ale_cdata.ale_tx_ring != NULL)
+		if (sc->ale_cdata.ale_tx_ring != NULL)
 			bus_dmamem_free(sc->ale_cdata.ale_tx_ring_tag,
 			    sc->ale_cdata.ale_tx_ring,
 			    sc->ale_cdata.ale_tx_ring_map);
+		sc->ale_cdata.ale_tx_ring_paddr = 0;
 		sc->ale_cdata.ale_tx_ring = NULL;
-		sc->ale_cdata.ale_tx_ring_map = NULL;
 		bus_dma_tag_destroy(sc->ale_cdata.ale_tx_ring_tag);
 		sc->ale_cdata.ale_tx_ring_tag = NULL;
 	}
 	/* Rx page block. */
 	for (i = 0; i < ALE_RX_PAGES; i++) {
 		if (sc->ale_cdata.ale_rx_page[i].page_tag != NULL) {
-			if (sc->ale_cdata.ale_rx_page[i].page_map != NULL)
+			if (sc->ale_cdata.ale_rx_page[i].page_paddr != 0)
 				bus_dmamap_unload(
 				    sc->ale_cdata.ale_rx_page[i].page_tag,
 				    sc->ale_cdata.ale_rx_page[i].page_map);
-			if (sc->ale_cdata.ale_rx_page[i].page_map != NULL &&
-			    sc->ale_cdata.ale_rx_page[i].page_addr != NULL)
+			if (sc->ale_cdata.ale_rx_page[i].page_addr != NULL)
 				bus_dmamem_free(
 				    sc->ale_cdata.ale_rx_page[i].page_tag,
 				    sc->ale_cdata.ale_rx_page[i].page_addr,
 				    sc->ale_cdata.ale_rx_page[i].page_map);
+			sc->ale_cdata.ale_rx_page[i].page_paddr = 0;
 			sc->ale_cdata.ale_rx_page[i].page_addr = NULL;
-			sc->ale_cdata.ale_rx_page[i].page_map = NULL;
 			bus_dma_tag_destroy(
 			    sc->ale_cdata.ale_rx_page[i].page_tag);
 			sc->ale_cdata.ale_rx_page[i].page_tag = NULL;
@@ -1366,18 +1364,17 @@ ale_dma_free(struct ale_softc *sc)
 	/* Rx CMB. */
 	for (i = 0; i < ALE_RX_PAGES; i++) {
 		if (sc->ale_cdata.ale_rx_page[i].cmb_tag != NULL) {
-			if (sc->ale_cdata.ale_rx_page[i].cmb_map != NULL)
+			if (sc->ale_cdata.ale_rx_page[i].cmb_paddr != 0)
 				bus_dmamap_unload(
 				    sc->ale_cdata.ale_rx_page[i].cmb_tag,
 				    sc->ale_cdata.ale_rx_page[i].cmb_map);
-			if (sc->ale_cdata.ale_rx_page[i].cmb_map != NULL &&
-			    sc->ale_cdata.ale_rx_page[i].cmb_addr != NULL)
+			if (sc->ale_cdata.ale_rx_page[i].cmb_addr != NULL)
 				bus_dmamem_free(
 				    sc->ale_cdata.ale_rx_page[i].cmb_tag,
 				    sc->ale_cdata.ale_rx_page[i].cmb_addr,
 				    sc->ale_cdata.ale_rx_page[i].cmb_map);
+			sc->ale_cdata.ale_rx_page[i].cmb_paddr = 0;
 			sc->ale_cdata.ale_rx_page[i].cmb_addr = NULL;
-			sc->ale_cdata.ale_rx_page[i].cmb_map = NULL;
 			bus_dma_tag_destroy(
 			    sc->ale_cdata.ale_rx_page[i].cmb_tag);
 			sc->ale_cdata.ale_rx_page[i].cmb_tag = NULL;
@@ -1385,16 +1382,15 @@ ale_dma_free(struct ale_softc *sc)
 	}
 	/* Tx CMB. */
 	if (sc->ale_cdata.ale_tx_cmb_tag != NULL) {
-		if (sc->ale_cdata.ale_tx_cmb_map != NULL)
+		if (sc->ale_cdata.ale_tx_cmb_paddr != 0)
 			bus_dmamap_unload(sc->ale_cdata.ale_tx_cmb_tag,
 			    sc->ale_cdata.ale_tx_cmb_map);
-		if (sc->ale_cdata.ale_tx_cmb_map != NULL &&
-		    sc->ale_cdata.ale_tx_cmb != NULL)
+		if (sc->ale_cdata.ale_tx_cmb != NULL)
 			bus_dmamem_free(sc->ale_cdata.ale_tx_cmb_tag,
 			    sc->ale_cdata.ale_tx_cmb,
 			    sc->ale_cdata.ale_tx_cmb_map);
+		sc->ale_cdata.ale_tx_cmb_paddr = 0;
 		sc->ale_cdata.ale_tx_cmb = NULL;
-		sc->ale_cdata.ale_tx_cmb_map = NULL;
 		bus_dma_tag_destroy(sc->ale_cdata.ale_tx_cmb_tag);
 		sc->ale_cdata.ale_tx_cmb_tag = NULL;
 	}

Modified: head/sys/dev/bfe/if_bfe.c
==============================================================================
--- head/sys/dev/bfe/if_bfe.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/bfe/if_bfe.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -364,12 +364,12 @@ bfe_dma_free(struct bfe_softc *sc)
 
 	/* Tx ring. */
 	if (sc->bfe_tx_tag != NULL) {
-		if (sc->bfe_tx_map != NULL)
+		if (sc->bfe_tx_dma != 0)
 			bus_dmamap_unload(sc->bfe_tx_tag, sc->bfe_tx_map);
-		if (sc->bfe_tx_map != NULL && sc->bfe_tx_list != NULL)
+		if (sc->bfe_tx_list != NULL)
 			bus_dmamem_free(sc->bfe_tx_tag, sc->bfe_tx_list,
 			    sc->bfe_tx_map);
-		sc->bfe_tx_map = NULL;
+		sc->bfe_tx_dma = 0;
 		sc->bfe_tx_list = NULL;
 		bus_dma_tag_destroy(sc->bfe_tx_tag);
 		sc->bfe_tx_tag = NULL;
@@ -377,12 +377,12 @@ bfe_dma_free(struct bfe_softc *sc)
 
 	/* Rx ring. */
 	if (sc->bfe_rx_tag != NULL) {
-		if (sc->bfe_rx_map != NULL)
+		if (sc->bfe_rx_dma != 0)
 			bus_dmamap_unload(sc->bfe_rx_tag, sc->bfe_rx_map);
-		if (sc->bfe_rx_map != NULL && sc->bfe_rx_list != NULL)
+		if (sc->bfe_rx_list != NULL)
 			bus_dmamem_free(sc->bfe_rx_tag, sc->bfe_rx_list,
 			    sc->bfe_rx_map);
-		sc->bfe_rx_map = NULL;
+		sc->bfe_rx_dma = 0;
 		sc->bfe_rx_list = NULL;
 		bus_dma_tag_destroy(sc->bfe_rx_tag);
 		sc->bfe_rx_tag = NULL;

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/bge/if_bge.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -2817,10 +2817,10 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_tx_mtag);
 
 	/* Destroy standard RX ring. */
-	if (sc->bge_cdata.bge_rx_std_ring_map)
+	if (sc->bge_ldata.bge_rx_std_ring_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_rx_std_ring_tag,
 		    sc->bge_cdata.bge_rx_std_ring_map);
-	if (sc->bge_cdata.bge_rx_std_ring_map && sc->bge_ldata.bge_rx_std_ring)
+	if (sc->bge_ldata.bge_rx_std_ring)
 		bus_dmamem_free(sc->bge_cdata.bge_rx_std_ring_tag,
 		    sc->bge_ldata.bge_rx_std_ring,
 		    sc->bge_cdata.bge_rx_std_ring_map);
@@ -2829,12 +2829,11 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_std_ring_tag);
 
 	/* Destroy jumbo RX ring. */
-	if (sc->bge_cdata.bge_rx_jumbo_ring_map)
+	if (sc->bge_ldata.bge_rx_jumbo_ring_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 		    sc->bge_cdata.bge_rx_jumbo_ring_map);
 
-	if (sc->bge_cdata.bge_rx_jumbo_ring_map &&
-	    sc->bge_ldata.bge_rx_jumbo_ring)
+	if (sc->bge_ldata.bge_rx_jumbo_ring)
 		bus_dmamem_free(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 		    sc->bge_ldata.bge_rx_jumbo_ring,
 		    sc->bge_cdata.bge_rx_jumbo_ring_map);
@@ -2843,12 +2842,11 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_jumbo_ring_tag);
 
 	/* Destroy RX return ring. */
-	if (sc->bge_cdata.bge_rx_return_ring_map)
+	if (sc->bge_ldata.bge_rx_return_ring_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_rx_return_ring_tag,
 		    sc->bge_cdata.bge_rx_return_ring_map);
 
-	if (sc->bge_cdata.bge_rx_return_ring_map &&
-	    sc->bge_ldata.bge_rx_return_ring)
+	if (sc->bge_ldata.bge_rx_return_ring)
 		bus_dmamem_free(sc->bge_cdata.bge_rx_return_ring_tag,
 		    sc->bge_ldata.bge_rx_return_ring,
 		    sc->bge_cdata.bge_rx_return_ring_map);
@@ -2857,11 +2855,11 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_return_ring_tag);
 
 	/* Destroy TX ring. */
-	if (sc->bge_cdata.bge_tx_ring_map)
+	if (sc->bge_ldata.bge_tx_ring_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_tx_ring_tag,
 		    sc->bge_cdata.bge_tx_ring_map);
 
-	if (sc->bge_cdata.bge_tx_ring_map && sc->bge_ldata.bge_tx_ring)
+	if (sc->bge_ldata.bge_tx_ring)
 		bus_dmamem_free(sc->bge_cdata.bge_tx_ring_tag,
 		    sc->bge_ldata.bge_tx_ring,
 		    sc->bge_cdata.bge_tx_ring_map);
@@ -2870,11 +2868,11 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_tx_ring_tag);
 
 	/* Destroy status block. */
-	if (sc->bge_cdata.bge_status_map)
+	if (sc->bge_ldata.bge_status_block_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_status_tag,
 		    sc->bge_cdata.bge_status_map);
 
-	if (sc->bge_cdata.bge_status_map && sc->bge_ldata.bge_status_block)
+	if (sc->bge_ldata.bge_status_block)
 		bus_dmamem_free(sc->bge_cdata.bge_status_tag,
 		    sc->bge_ldata.bge_status_block,
 		    sc->bge_cdata.bge_status_map);
@@ -2883,11 +2881,11 @@ bge_dma_free(struct bge_softc *sc)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_status_tag);
 
 	/* Destroy statistics block. */
-	if (sc->bge_cdata.bge_stats_map)
+	if (sc->bge_ldata.bge_stats_paddr)
 		bus_dmamap_unload(sc->bge_cdata.bge_stats_tag,
 		    sc->bge_cdata.bge_stats_map);
 
-	if (sc->bge_cdata.bge_stats_map && sc->bge_ldata.bge_stats)
+	if (sc->bge_ldata.bge_stats)
 		bus_dmamem_free(sc->bge_cdata.bge_stats_tag,
 		    sc->bge_ldata.bge_stats,
 		    sc->bge_cdata.bge_stats_map);

Modified: head/sys/dev/dc/if_dc.c
==============================================================================
--- head/sys/dev/dc/if_dc.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/dc/if_dc.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1982,9 +1982,9 @@ dc_dma_free(struct dc_softc *sc)
 
 	/* RX descriptor list. */
 	if (sc->dc_rx_ltag) {
-		if (sc->dc_rx_lmap != NULL)
+		if (sc->dc_ldata.dc_rx_list_paddr != 0)
 			bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap);
-		if (sc->dc_rx_lmap != NULL && sc->dc_ldata.dc_rx_list != NULL)
+		if (sc->dc_ldata.dc_rx_list != NULL)
 			bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list,
 			    sc->dc_rx_lmap);
 		bus_dma_tag_destroy(sc->dc_rx_ltag);
@@ -1992,9 +1992,9 @@ dc_dma_free(struct dc_softc *sc)
 
 	/* TX descriptor list. */
 	if (sc->dc_tx_ltag) {
-		if (sc->dc_tx_lmap != NULL)
+		if (sc->dc_ldata.dc_tx_list_paddr != 0)
 			bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap);
-		if (sc->dc_tx_lmap != NULL && sc->dc_ldata.dc_tx_list != NULL)
+		if (sc->dc_ldata.dc_tx_list != NULL)
 			bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list,
 			    sc->dc_tx_lmap);
 		bus_dma_tag_destroy(sc->dc_tx_ltag);
@@ -2002,9 +2002,9 @@ dc_dma_free(struct dc_softc *sc)
 
 	/* multicast setup frame. */
 	if (sc->dc_stag) {
-		if (sc->dc_smap != NULL)
+		if (sc->dc_saddr != 0)
 			bus_dmamap_unload(sc->dc_stag, sc->dc_smap);
-		if (sc->dc_smap != NULL && sc->dc_cdata.dc_sbuf != NULL)
+		if (sc->dc_cdata.dc_sbuf != NULL)
 			bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf,
 			    sc->dc_smap);
 		bus_dma_tag_destroy(sc->dc_stag);

Modified: head/sys/dev/jme/if_jme.c
==============================================================================
--- head/sys/dev/jme/if_jme.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/jme/if_jme.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1408,31 +1408,29 @@ jme_dma_free(struct jme_softc *sc)
 
 	/* Tx ring */
 	if (sc->jme_cdata.jme_tx_ring_tag != NULL) {
-		if (sc->jme_cdata.jme_tx_ring_map)
+		if (sc->jme_rdata.jme_tx_ring_paddr)
 			bus_dmamap_unload(sc->jme_cdata.jme_tx_ring_tag,
 			    sc->jme_cdata.jme_tx_ring_map);
-		if (sc->jme_cdata.jme_tx_ring_map &&
-		    sc->jme_rdata.jme_tx_ring)
+		if (sc->jme_rdata.jme_tx_ring)
 			bus_dmamem_free(sc->jme_cdata.jme_tx_ring_tag,
 			    sc->jme_rdata.jme_tx_ring,
 			    sc->jme_cdata.jme_tx_ring_map);
 		sc->jme_rdata.jme_tx_ring = NULL;
-		sc->jme_cdata.jme_tx_ring_map = NULL;
+		sc->jme_rdata.jme_tx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->jme_cdata.jme_tx_ring_tag);
 		sc->jme_cdata.jme_tx_ring_tag = NULL;
 	}
 	/* Rx ring */
 	if (sc->jme_cdata.jme_rx_ring_tag != NULL) {
-		if (sc->jme_cdata.jme_rx_ring_map)
+		if (sc->jme_rdata.jme_rx_ring_paddr)
 			bus_dmamap_unload(sc->jme_cdata.jme_rx_ring_tag,
 			    sc->jme_cdata.jme_rx_ring_map);
-		if (sc->jme_cdata.jme_rx_ring_map &&
-		    sc->jme_rdata.jme_rx_ring)
+		if (sc->jme_rdata.jme_rx_ring)
 			bus_dmamem_free(sc->jme_cdata.jme_rx_ring_tag,
 			    sc->jme_rdata.jme_rx_ring,
 			    sc->jme_cdata.jme_rx_ring_map);
 		sc->jme_rdata.jme_rx_ring = NULL;
-		sc->jme_cdata.jme_rx_ring_map = NULL;
+		sc->jme_rdata.jme_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->jme_cdata.jme_rx_ring_tag);
 		sc->jme_cdata.jme_rx_ring_tag = NULL;
 	}
@@ -1470,15 +1468,15 @@ jme_dma_free(struct jme_softc *sc)
 
 	/* Shared status block. */
 	if (sc->jme_cdata.jme_ssb_tag != NULL) {
-		if (sc->jme_cdata.jme_ssb_map)
+		if (sc->jme_rdata.jme_ssb_block_paddr)
 			bus_dmamap_unload(sc->jme_cdata.jme_ssb_tag,
 			    sc->jme_cdata.jme_ssb_map);
-		if (sc->jme_cdata.jme_ssb_map && sc->jme_rdata.jme_ssb_block)
+		if (sc->jme_rdata.jme_ssb_block)
 			bus_dmamem_free(sc->jme_cdata.jme_ssb_tag,
 			    sc->jme_rdata.jme_ssb_block,
 			    sc->jme_cdata.jme_ssb_map);
 		sc->jme_rdata.jme_ssb_block = NULL;
-		sc->jme_cdata.jme_ssb_map = NULL;
+		sc->jme_rdata.jme_ssb_block_paddr = 0;
 		bus_dma_tag_destroy(sc->jme_cdata.jme_ssb_tag);
 		sc->jme_cdata.jme_ssb_tag = NULL;
 	}

Modified: head/sys/dev/msk/if_msk.c
==============================================================================
--- head/sys/dev/msk/if_msk.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/msk/if_msk.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -2209,14 +2209,14 @@ msk_status_dma_free(struct msk_softc *sc
 
 	/* Destroy status block. */
 	if (sc->msk_stat_tag) {
-		if (sc->msk_stat_map) {
+		if (sc->msk_stat_ring_paddr) {
 			bus_dmamap_unload(sc->msk_stat_tag, sc->msk_stat_map);
-			if (sc->msk_stat_ring) {
-				bus_dmamem_free(sc->msk_stat_tag,
-				    sc->msk_stat_ring, sc->msk_stat_map);
-				sc->msk_stat_ring = NULL;
-			}
-			sc->msk_stat_map = NULL;
+			sc->msk_stat_ring_paddr = 0;
+		}
+		if (sc->msk_stat_ring) {
+			bus_dmamem_free(sc->msk_stat_tag,
+			    sc->msk_stat_ring, sc->msk_stat_map);
+			sc->msk_stat_ring = NULL;
 		}
 		bus_dma_tag_destroy(sc->msk_stat_tag);
 		sc->msk_stat_tag = NULL;
@@ -2527,31 +2527,29 @@ msk_txrx_dma_free(struct msk_if_softc *s
 
 	/* Tx ring. */
 	if (sc_if->msk_cdata.msk_tx_ring_tag) {
-		if (sc_if->msk_cdata.msk_tx_ring_map)
+		if (sc_if->msk_rdata.msk_tx_ring_paddr)
 			bus_dmamap_unload(sc_if->msk_cdata.msk_tx_ring_tag,
 			    sc_if->msk_cdata.msk_tx_ring_map);
-		if (sc_if->msk_cdata.msk_tx_ring_map &&
-		    sc_if->msk_rdata.msk_tx_ring)
+		if (sc_if->msk_rdata.msk_tx_ring)
 			bus_dmamem_free(sc_if->msk_cdata.msk_tx_ring_tag,
 			    sc_if->msk_rdata.msk_tx_ring,
 			    sc_if->msk_cdata.msk_tx_ring_map);
 		sc_if->msk_rdata.msk_tx_ring = NULL;
-		sc_if->msk_cdata.msk_tx_ring_map = NULL;
+		sc_if->msk_rdata.msk_tx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc_if->msk_cdata.msk_tx_ring_tag);
 		sc_if->msk_cdata.msk_tx_ring_tag = NULL;
 	}
 	/* Rx ring. */
 	if (sc_if->msk_cdata.msk_rx_ring_tag) {
-		if (sc_if->msk_cdata.msk_rx_ring_map)
+		if (sc_if->msk_rdata.msk_rx_ring_paddr)
 			bus_dmamap_unload(sc_if->msk_cdata.msk_rx_ring_tag,
 			    sc_if->msk_cdata.msk_rx_ring_map);
-		if (sc_if->msk_cdata.msk_rx_ring_map &&
-		    sc_if->msk_rdata.msk_rx_ring)
+		if (sc_if->msk_rdata.msk_rx_ring)
 			bus_dmamem_free(sc_if->msk_cdata.msk_rx_ring_tag,
 			    sc_if->msk_rdata.msk_rx_ring,
 			    sc_if->msk_cdata.msk_rx_ring_map);
 		sc_if->msk_rdata.msk_rx_ring = NULL;
-		sc_if->msk_cdata.msk_rx_ring_map = NULL;
+		sc_if->msk_rdata.msk_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc_if->msk_cdata.msk_rx_ring_tag);
 		sc_if->msk_cdata.msk_rx_ring_tag = NULL;
 	}
@@ -2600,16 +2598,15 @@ msk_rx_dma_jfree(struct msk_if_softc *sc
 
 	/* Jumbo Rx ring. */
 	if (sc_if->msk_cdata.msk_jumbo_rx_ring_tag) {
-		if (sc_if->msk_cdata.msk_jumbo_rx_ring_map)
+		if (sc_if->msk_rdata.msk_jumbo_rx_ring_paddr)
 			bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_ring_tag,
 			    sc_if->msk_cdata.msk_jumbo_rx_ring_map);
-		if (sc_if->msk_cdata.msk_jumbo_rx_ring_map &&
-		    sc_if->msk_rdata.msk_jumbo_rx_ring)
+		if (sc_if->msk_rdata.msk_jumbo_rx_ring)
 			bus_dmamem_free(sc_if->msk_cdata.msk_jumbo_rx_ring_tag,
 			    sc_if->msk_rdata.msk_jumbo_rx_ring,
 			    sc_if->msk_cdata.msk_jumbo_rx_ring_map);
 		sc_if->msk_rdata.msk_jumbo_rx_ring = NULL;
-		sc_if->msk_cdata.msk_jumbo_rx_ring_map = NULL;
+		sc_if->msk_rdata.msk_jumbo_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_ring_tag);
 		sc_if->msk_cdata.msk_jumbo_rx_ring_tag = NULL;
 	}

Modified: head/sys/dev/nge/if_nge.c
==============================================================================
--- head/sys/dev/nge/if_nge.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/nge/if_nge.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1225,31 +1225,29 @@ nge_dma_free(struct nge_softc *sc)
 
 	/* Tx ring. */
 	if (sc->nge_cdata.nge_tx_ring_tag) {
-		if (sc->nge_cdata.nge_tx_ring_map)
+		if (sc->nge_rdata.nge_tx_ring_paddr)
 			bus_dmamap_unload(sc->nge_cdata.nge_tx_ring_tag,
 			    sc->nge_cdata.nge_tx_ring_map);
-		if (sc->nge_cdata.nge_tx_ring_map &&
-		    sc->nge_rdata.nge_tx_ring)
+		if (sc->nge_rdata.nge_tx_ring)
 			bus_dmamem_free(sc->nge_cdata.nge_tx_ring_tag,
 			    sc->nge_rdata.nge_tx_ring,
 			    sc->nge_cdata.nge_tx_ring_map);
 		sc->nge_rdata.nge_tx_ring = NULL;
-		sc->nge_cdata.nge_tx_ring_map = NULL;
+		sc->nge_rdata.nge_tx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->nge_cdata.nge_tx_ring_tag);
 		sc->nge_cdata.nge_tx_ring_tag = NULL;
 	}
 	/* Rx ring. */
 	if (sc->nge_cdata.nge_rx_ring_tag) {
-		if (sc->nge_cdata.nge_rx_ring_map)
+		if (sc->nge_rdata.nge_rx_ring_paddr)
 			bus_dmamap_unload(sc->nge_cdata.nge_rx_ring_tag,
 			    sc->nge_cdata.nge_rx_ring_map);
-		if (sc->nge_cdata.nge_rx_ring_map &&
-		    sc->nge_rdata.nge_rx_ring)
+		if (sc->nge_rdata.nge_rx_ring)
 			bus_dmamem_free(sc->nge_cdata.nge_rx_ring_tag,
 			    sc->nge_rdata.nge_rx_ring,
 			    sc->nge_cdata.nge_rx_ring_map);
 		sc->nge_rdata.nge_rx_ring = NULL;
-		sc->nge_cdata.nge_rx_ring_map = NULL;
+		sc->nge_rdata.nge_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->nge_cdata.nge_rx_ring_tag);
 		sc->nge_cdata.nge_rx_ring_tag = NULL;
 	}

Modified: head/sys/dev/re/if_re.c
==============================================================================
--- head/sys/dev/re/if_re.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/re/if_re.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1818,10 +1818,10 @@ re_detach(device_t dev)
 	/* Unload and free the RX DMA ring memory and map */
 
 	if (sc->rl_ldata.rl_rx_list_tag) {
-		if (sc->rl_ldata.rl_rx_list_map)
+		if (sc->rl_ldata.rl_rx_list_addr)
 			bus_dmamap_unload(sc->rl_ldata.rl_rx_list_tag,
 			    sc->rl_ldata.rl_rx_list_map);
-		if (sc->rl_ldata.rl_rx_list_map && sc->rl_ldata.rl_rx_list)
+		if (sc->rl_ldata.rl_rx_list)
 			bus_dmamem_free(sc->rl_ldata.rl_rx_list_tag,
 			    sc->rl_ldata.rl_rx_list,
 			    sc->rl_ldata.rl_rx_list_map);
@@ -1831,10 +1831,10 @@ re_detach(device_t dev)
 	/* Unload and free the TX DMA ring memory and map */
 
 	if (sc->rl_ldata.rl_tx_list_tag) {
-		if (sc->rl_ldata.rl_tx_list_map)
+		if (sc->rl_ldata.rl_tx_list_addr)
 			bus_dmamap_unload(sc->rl_ldata.rl_tx_list_tag,
 			    sc->rl_ldata.rl_tx_list_map);
-		if (sc->rl_ldata.rl_tx_list_map && sc->rl_ldata.rl_tx_list)
+		if (sc->rl_ldata.rl_tx_list)
 			bus_dmamem_free(sc->rl_ldata.rl_tx_list_tag,
 			    sc->rl_ldata.rl_tx_list,
 			    sc->rl_ldata.rl_tx_list_map);
@@ -1876,10 +1876,10 @@ re_detach(device_t dev)
 	/* Unload and free the stats buffer and map */
 
 	if (sc->rl_ldata.rl_stag) {
-		if (sc->rl_ldata.rl_smap)
+		if (sc->rl_ldata.rl_stats_addr)
 			bus_dmamap_unload(sc->rl_ldata.rl_stag,
 			    sc->rl_ldata.rl_smap);
-		if (sc->rl_ldata.rl_smap && sc->rl_ldata.rl_stats)
+		if (sc->rl_ldata.rl_stats)
 			bus_dmamem_free(sc->rl_ldata.rl_stag,
 			    sc->rl_ldata.rl_stats, sc->rl_ldata.rl_smap);
 		bus_dma_tag_destroy(sc->rl_ldata.rl_stag);

Modified: head/sys/dev/sf/if_sf.c
==============================================================================
--- head/sys/dev/sf/if_sf.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/sf/if_sf.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1292,61 +1292,57 @@ sf_dma_free(struct sf_softc *sc)
 
 	/* Tx ring. */
 	if (sc->sf_cdata.sf_tx_ring_tag) {
-		if (sc->sf_cdata.sf_tx_ring_map)
+		if (sc->sf_rdata.sf_tx_ring_paddr)
 			bus_dmamap_unload(sc->sf_cdata.sf_tx_ring_tag,
 			    sc->sf_cdata.sf_tx_ring_map);
-		if (sc->sf_cdata.sf_tx_ring_map &&
-		    sc->sf_rdata.sf_tx_ring)
+		if (sc->sf_rdata.sf_tx_ring)
 			bus_dmamem_free(sc->sf_cdata.sf_tx_ring_tag,
 			    sc->sf_rdata.sf_tx_ring,
 			    sc->sf_cdata.sf_tx_ring_map);
 		sc->sf_rdata.sf_tx_ring = NULL;
-		sc->sf_cdata.sf_tx_ring_map = NULL;
+		sc->sf_rdata.sf_tx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->sf_cdata.sf_tx_ring_tag);
 		sc->sf_cdata.sf_tx_ring_tag = NULL;
 	}
 	/* Tx completion ring. */
 	if (sc->sf_cdata.sf_tx_cring_tag) {
-		if (sc->sf_cdata.sf_tx_cring_map)
+		if (sc->sf_rdata.sf_tx_cring_paddr)
 			bus_dmamap_unload(sc->sf_cdata.sf_tx_cring_tag,
 			    sc->sf_cdata.sf_tx_cring_map);
-		if (sc->sf_cdata.sf_tx_cring_map &&
-		    sc->sf_rdata.sf_tx_cring)
+		if (sc->sf_rdata.sf_tx_cring)
 			bus_dmamem_free(sc->sf_cdata.sf_tx_cring_tag,
 			    sc->sf_rdata.sf_tx_cring,
 			    sc->sf_cdata.sf_tx_cring_map);
 		sc->sf_rdata.sf_tx_cring = NULL;
-		sc->sf_cdata.sf_tx_cring_map = NULL;
+		sc->sf_rdata.sf_tx_cring_paddr = 0;
 		bus_dma_tag_destroy(sc->sf_cdata.sf_tx_cring_tag);
 		sc->sf_cdata.sf_tx_cring_tag = NULL;
 	}
 	/* Rx ring. */
 	if (sc->sf_cdata.sf_rx_ring_tag) {
-		if (sc->sf_cdata.sf_rx_ring_map)
+		if (sc->sf_rdata.sf_rx_ring_paddr)
 			bus_dmamap_unload(sc->sf_cdata.sf_rx_ring_tag,
 			    sc->sf_cdata.sf_rx_ring_map);
-		if (sc->sf_cdata.sf_rx_ring_map &&
-		    sc->sf_rdata.sf_rx_ring)
+		if (sc->sf_rdata.sf_rx_ring)
 			bus_dmamem_free(sc->sf_cdata.sf_rx_ring_tag,
 			    sc->sf_rdata.sf_rx_ring,
 			    sc->sf_cdata.sf_rx_ring_map);
 		sc->sf_rdata.sf_rx_ring = NULL;
-		sc->sf_cdata.sf_rx_ring_map = NULL;
+		sc->sf_rdata.sf_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc->sf_cdata.sf_rx_ring_tag);
 		sc->sf_cdata.sf_rx_ring_tag = NULL;
 	}
 	/* Rx completion ring. */
 	if (sc->sf_cdata.sf_rx_cring_tag) {
-		if (sc->sf_cdata.sf_rx_cring_map)
+		if (sc->sf_rdata.sf_rx_cring_paddr)
 			bus_dmamap_unload(sc->sf_cdata.sf_rx_cring_tag,
 			    sc->sf_cdata.sf_rx_cring_map);
-		if (sc->sf_cdata.sf_rx_cring_map &&
-		    sc->sf_rdata.sf_rx_cring)
+		if (sc->sf_rdata.sf_rx_cring)
 			bus_dmamem_free(sc->sf_cdata.sf_rx_cring_tag,
 			    sc->sf_rdata.sf_rx_cring,
 			    sc->sf_cdata.sf_rx_cring_map);
 		sc->sf_rdata.sf_rx_cring = NULL;
-		sc->sf_cdata.sf_rx_cring_map = NULL;
+		sc->sf_rdata.sf_rx_cring_paddr = 0;
 		bus_dma_tag_destroy(sc->sf_cdata.sf_rx_cring_tag);
 		sc->sf_cdata.sf_rx_cring_tag = NULL;
 	}

Modified: head/sys/dev/sge/if_sge.c
==============================================================================
--- head/sys/dev/sge/if_sge.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/sge/if_sge.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -916,25 +916,25 @@ sge_dma_free(struct sge_softc *sc)
 	ld = &sc->sge_ldata;
 	/* Rx ring. */
 	if (cd->sge_rx_tag != NULL) {
-		if (cd->sge_rx_dmamap != NULL)
+		if (ld->sge_rx_paddr != 0)
 			bus_dmamap_unload(cd->sge_rx_tag, cd->sge_rx_dmamap);
-		if (cd->sge_rx_dmamap != NULL && ld->sge_rx_ring != NULL)
+		if (ld->sge_rx_ring != NULL)
 			bus_dmamem_free(cd->sge_rx_tag, ld->sge_rx_ring,
 			    cd->sge_rx_dmamap);
 		ld->sge_rx_ring = NULL;
-		cd->sge_rx_dmamap = NULL;
+		ld->sge_rx_paddr = 0;
 		bus_dma_tag_destroy(cd->sge_rx_tag);
 		cd->sge_rx_tag = NULL;
 	}
 	/* Tx ring. */
 	if (cd->sge_tx_tag != NULL) {
-		if (cd->sge_tx_dmamap != NULL)
+		if (ld->sge_tx_paddr != 0)
 			bus_dmamap_unload(cd->sge_tx_tag, cd->sge_tx_dmamap);
-		if (cd->sge_tx_dmamap != NULL && ld->sge_tx_ring != NULL)
+		if (ld->sge_tx_ring != NULL)
 			bus_dmamem_free(cd->sge_tx_tag, ld->sge_tx_ring,
 			    cd->sge_tx_dmamap);
 		ld->sge_tx_ring = NULL;
-		cd->sge_tx_dmamap = NULL;
+		ld->sge_tx_paddr = 0;
 		bus_dma_tag_destroy(cd->sge_tx_tag);
 		cd->sge_tx_tag = NULL;
 	}

Modified: head/sys/dev/sis/if_sis.c
==============================================================================
--- head/sys/dev/sis/if_sis.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/sis/if_sis.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -1329,9 +1329,9 @@ sis_dma_free(struct sis_softc *sc)
 		bus_dma_tag_destroy(sc->sis_tx_tag);
 
 	/* Destroy RX ring. */
-	if (sc->sis_rx_list_map)
+	if (sc->sis_rx_paddr)
 		bus_dmamap_unload(sc->sis_rx_list_tag, sc->sis_rx_list_map);
-	if (sc->sis_rx_list_map && sc->sis_rx_list)
+	if (sc->sis_rx_list)
 		bus_dmamem_free(sc->sis_rx_list_tag, sc->sis_rx_list,
 		    sc->sis_rx_list_map);
 
@@ -1339,10 +1339,10 @@ sis_dma_free(struct sis_softc *sc)
 		bus_dma_tag_destroy(sc->sis_rx_list_tag);
 
 	/* Destroy TX ring. */
-	if (sc->sis_tx_list_map)
+	if (sc->sis_tx_paddr)
 		bus_dmamap_unload(sc->sis_tx_list_tag, sc->sis_tx_list_map);
 
-	if (sc->sis_tx_list_map && sc->sis_tx_list)
+	if (sc->sis_tx_list)
 		bus_dmamem_free(sc->sis_tx_list_tag, sc->sis_tx_list,
 		    sc->sis_tx_list_map);
 

Modified: head/sys/dev/sk/if_sk.c
==============================================================================
--- head/sys/dev/sk/if_sk.c	Wed Jun 11 12:56:49 2014	(r267362)
+++ head/sys/dev/sk/if_sk.c	Wed Jun 11 14:53:58 2014	(r267363)
@@ -2223,31 +2223,29 @@ sk_dma_free(sc_if)
 
 	/* Tx ring */
 	if (sc_if->sk_cdata.sk_tx_ring_tag) {
-		if (sc_if->sk_cdata.sk_tx_ring_map)
+		if (sc_if->sk_rdata.sk_tx_ring_paddr)
 			bus_dmamap_unload(sc_if->sk_cdata.sk_tx_ring_tag,
 			    sc_if->sk_cdata.sk_tx_ring_map);
-		if (sc_if->sk_cdata.sk_tx_ring_map &&
-		    sc_if->sk_rdata.sk_tx_ring)
+		if (sc_if->sk_rdata.sk_tx_ring)
 			bus_dmamem_free(sc_if->sk_cdata.sk_tx_ring_tag,
 			    sc_if->sk_rdata.sk_tx_ring,
 			    sc_if->sk_cdata.sk_tx_ring_map);
 		sc_if->sk_rdata.sk_tx_ring = NULL;
-		sc_if->sk_cdata.sk_tx_ring_map = NULL;
+		sc_if->sk_rdata.sk_tx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc_if->sk_cdata.sk_tx_ring_tag);
 		sc_if->sk_cdata.sk_tx_ring_tag = NULL;
 	}
 	/* Rx ring */
 	if (sc_if->sk_cdata.sk_rx_ring_tag) {
-		if (sc_if->sk_cdata.sk_rx_ring_map)
+		if (sc_if->sk_rdata.sk_rx_ring_paddr)
 			bus_dmamap_unload(sc_if->sk_cdata.sk_rx_ring_tag,
 			    sc_if->sk_cdata.sk_rx_ring_map);
-		if (sc_if->sk_cdata.sk_rx_ring_map &&
-		    sc_if->sk_rdata.sk_rx_ring)
+		if (sc_if->sk_rdata.sk_rx_ring)
 			bus_dmamem_free(sc_if->sk_cdata.sk_rx_ring_tag,
 			    sc_if->sk_rdata.sk_rx_ring,
 			    sc_if->sk_cdata.sk_rx_ring_map);
 		sc_if->sk_rdata.sk_rx_ring = NULL;
-		sc_if->sk_cdata.sk_rx_ring_map = NULL;
+		sc_if->sk_rdata.sk_rx_ring_paddr = 0;
 		bus_dma_tag_destroy(sc_if->sk_cdata.sk_rx_ring_tag);
 		sc_if->sk_cdata.sk_rx_ring_tag = NULL;
 	}
@@ -2298,16 +2296,15 @@ sk_dma_jumbo_free(sc_if)
 
 	/* jumbo Rx ring */
 	if (sc_if->sk_cdata.sk_jumbo_rx_ring_tag) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406111453.s5BErxFT022932>