Author: loos
Date: Fri Sep  6 12:47:14 2013
New Revision: 255300
URL: http://svnweb.freebsd.org/changeset/base/255300

Log:
  Fix the leakage of dma tags on if_arge.  The leak occur when arge_start()
  add some packet(s) to tx ring and arge_stop() is called before receive the
  sent packet interrupt from hardware.  Fix arge_stop() to unload the in use
  dma tags and free the associated mbuf.
  
  PR:           178319, 163670
  Approved by:  adrian (mentor)

Modified:
  head/sys/mips/atheros/if_arge.c

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c     Fri Sep  6 12:45:08 2013        
(r255299)
+++ head/sys/mips/atheros/if_arge.c     Fri Sep  6 12:47:14 2013        
(r255300)
@@ -142,6 +142,7 @@ static int arge_resume(device_t);
 static int arge_rx_ring_init(struct arge_softc *);
 static void arge_rx_ring_free(struct arge_softc *sc);
 static int arge_tx_ring_init(struct arge_softc *);
+static void arge_tx_ring_free(struct arge_softc *);
 #ifdef DEVICE_POLLING
 static int arge_poll(struct ifnet *, enum poll_cmd, int);
 #endif
@@ -1278,6 +1279,7 @@ arge_stop(struct arge_softc *sc)
        /* Flush FIFO and free any existing mbufs */
        arge_flush_ddr(sc);
        arge_rx_ring_free(sc);
+       arge_tx_ring_free(sc);
 }
 
 
@@ -1708,6 +1710,30 @@ arge_tx_ring_init(struct arge_softc *sc)
 }
 
 /*
+ * Free the Tx ring, unload any pending dma transaction and free the mbuf.
+ */
+static void
+arge_tx_ring_free(struct arge_softc *sc)
+{
+       struct arge_txdesc      *txd;
+       int                     i;
+
+       /* Free the Tx buffers. */
+       for (i = 0; i < ARGE_TX_RING_COUNT; i++) {
+               txd = &sc->arge_cdata.arge_txdesc[i];
+               if (txd->tx_dmamap) {
+                       bus_dmamap_sync(sc->arge_cdata.arge_tx_tag,
+                           txd->tx_dmamap, BUS_DMASYNC_POSTWRITE);
+                       bus_dmamap_unload(sc->arge_cdata.arge_tx_tag,
+                           txd->tx_dmamap);
+               }
+               if (txd->tx_m)
+                       m_freem(txd->tx_m);
+               txd->tx_m = NULL;
+       }
+}
+
+/*
  * Initialize the RX descriptors and allocate mbufs for them. Note that
  * we arrange the descriptors in a closed ring, so that the last descriptor
  * points back to the first.
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to