From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 00:14:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 988B61065672; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 84A708FC12; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0Eu2u074010; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0Eu5w074008; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280014.p2S0Eu5w074008@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220084 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:14:56 -0000 Author: yongari Date: Mon Mar 28 00:14:56 2011 New Revision: 220084 URL: http://svn.freebsd.org/changeset/base/220084 Log: MFC r219701: Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync(). With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:13:41 2011 (r220083) +++ stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:14:56 2011 (r220084) @@ -238,7 +238,7 @@ static int dc_newbuf(struct dc_softc *, static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); -static void dc_rxeof(struct dc_softc *); +static int dc_rxeof(struct dc_softc *); static void dc_txeof(struct dc_softc *); static void dc_tick(void *); static void dc_tx_underrun(struct dc_softc *); @@ -2791,8 +2791,6 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; @@ -2829,18 +2827,19 @@ dc_discard_rxbuf(struct dc_softc *sc, in * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. */ -static void +static int dc_rxeof(struct dc_softc *sc) { struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; - int i, total_len; + int i, total_len, rx_npkts; uint32_t rxstat; DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; + rx_npkts = 0; bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); @@ -2862,6 +2861,7 @@ dc_rxeof(struct dc_softc *sc) bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); + rx_npkts++; if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { @@ -2896,7 +2896,7 @@ dc_rxeof(struct dc_softc *sc) else { ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); - return; + return (rx_npkts); } } } @@ -2942,6 +2942,7 @@ dc_rxeof(struct dc_softc *sc) } sc->dc_cdata.dc_rx_prod = i; + return (rx_npkts); } /* @@ -3259,7 +3260,7 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; uint32_t r, status; - int curpkts, n; + int n; sc = arg; @@ -3289,9 +3290,7 @@ dc_intr(void *arg) CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } @@ -3315,9 +3314,7 @@ dc_intr(void *arg) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); }