svn commit: r241572 - head/sys/arm/ti/cpsw
Tim Kientzle
kientzle at FreeBSD.org
Mon Oct 15 04:10:50 UTC 2012
Author: kientzle
Date: Mon Oct 15 04:10:49 2012
New Revision: 241572
URL: http://svn.freebsd.org/changeset/base/241572
Log:
Fix an mbuf leak in cpsw driver, clean up mbuf management:
* Record TX mbufs when we get them so we can release them.
* Set TX/RX mbuf slots to NULL when we are no longer responsible for them
* Move dma sync on RX into RX intr routine
Modified:
head/sys/arm/ti/cpsw/if_cpsw.c
Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==============================================================================
--- head/sys/arm/ti/cpsw/if_cpsw.c Mon Oct 15 01:13:36 2012 (r241571)
+++ head/sys/arm/ti/cpsw/if_cpsw.c Mon Oct 15 04:10:49 2012 (r241572)
@@ -522,11 +522,6 @@ cpsw_new_rxbuf(struct cpsw_softc *sc, ui
int error;
int nsegs;
- if (sc->rx_mbuf[i]) {
- bus_dmamap_sync(sc->mbuf_dtag, sc->rx_dmamap[i], BUS_DMASYNC_POSTREAD);
- bus_dmamap_unload(sc->mbuf_dtag, sc->rx_dmamap[i]);
- }
-
sc->rx_mbuf[i] = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (sc->rx_mbuf[i] == NULL)
return (ENOBUFS);
@@ -593,6 +588,7 @@ cpsw_encap(struct cpsw_softc *sc, struct
/* Write descriptor */
cpsw_cpdma_write_txbd(idx, &bd);
+ sc->tx_mbuf[idx] = m0;
/* Previous descriptor should point to us */
cpsw_cpdma_write_txbd_next(((idx-1<0)?(CPSW_MAX_TX_BUFFERS-1):(idx-1)),
@@ -821,9 +817,15 @@ cpsw_intr_rx_locked(void *arg)
}
}
+ bus_dmamap_sync(sc->mbuf_dtag,
+ sc->rx_dmamap[i],
+ BUS_DMASYNC_POSTREAD);
+ bus_dmamap_unload(sc->mbuf_dtag, sc->rx_dmamap[i]);
+
/* Handover packet */
CPSW_RX_UNLOCK(sc);
(*ifp->if_input)(ifp, sc->rx_mbuf[i]);
+ sc->rx_mbuf[i] = NULL;
CPSW_RX_LOCK(sc);
/* Allocate new buffer for current descriptor */
@@ -890,6 +892,7 @@ cpsw_intr_tx_locked(void *arg)
BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(sc->mbuf_dtag, sc->tx_dmamap[sc->txbd_head]);
m_freem(sc->tx_mbuf[sc->txbd_head]);
+ sc->tx_mbuf[sc->txbd_head] = NULL;
cpsw_write_4(CPSW_CPDMA_TX_CP(0), cpsw_cpdma_txbd_paddr(sc->txbd_head));
More information about the svn-src-head
mailing list