From owner-svn-src-head@FreeBSD.ORG Mon May 18 01:51:53 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 052961065674; Mon, 18 May 2009 01:51:53 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC8958FC12; Mon, 18 May 2009 01:51:52 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I1pqm5045846; Mon, 18 May 2009 01:51:52 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I1pqb4045845; Mon, 18 May 2009 01:51:52 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200905180151.n4I1pqb4045845@svn.freebsd.org> From: Xin LI Date: Mon, 18 May 2009 01:51:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192281 - head/sys/dev/bce X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 01:51:53 -0000 Author: delphij Date: Mon May 18 01:51:52 2009 New Revision: 192281 URL: http://svn.freebsd.org/changeset/base/192281 Log: DMA synchronization fixes: - In bce_rx_intr(), use BUS_DMASYNC_POSTREAD instead of BUS_DMASYNC_POSTWRITE, as we want to "read" from the rx page chain pages. - Document why we need to do PREWRITE after we have updated the rx page chain pages. - In bce_intr(), use BUS_DMASYNC_POSTREAD and BUS_DMASYNC_PREREAD when before and after CPU "reading" the status block. - Adjust some nearby style mismatches/etc. Pointed out by: yongari Approved by: davidch (no objection) but bugs are mine :) Modified: head/sys/dev/bce/if_bce.c Modified: head/sys/dev/bce/if_bce.c ============================================================================== --- head/sys/dev/bce/if_bce.c Mon May 18 01:45:52 2009 (r192280) +++ head/sys/dev/bce/if_bce.c Mon May 18 01:51:52 2009 (r192281) @@ -4884,7 +4884,7 @@ bce_get_rx_buf(struct bce_softc *sc, str KASSERT(nsegs == 1, ("%s(): Too many segments returned (%d)!", __FUNCTION__, nsegs)); - /* ToDo: Do we need bus_dmamap_sync(,,BUS_DMASYNC_PREWRITE) here? */ + /* ToDo: Do we need bus_dmamap_sync(,,BUS_DMASYNC_PREREAD) here? */ /* Setup the rx_bd for the segment. */ rxbd = &sc->rx_bd_chain[RX_PAGE(*chain_prod)][RX_IDX(*chain_prod)]; @@ -4993,7 +4993,7 @@ bce_get_pg_buf(struct bce_softc *sc, str goto bce_get_pg_buf_exit; } - /* ToDo: Do we need bus_dmamap_sync(,,BUS_DMASYNC_PREWRITE) here? */ + /* ToDo: Do we need bus_dmamap_sync(,,BUS_DMASYNC_PREREAD) here? */ /* * The page chain uses the same rx_bd data structure @@ -5270,13 +5270,11 @@ bce_init_rx_chain(struct bce_softc *sc) rxbd->rx_bd_haddr_lo = htole32(BCE_ADDR_LO(sc->rx_bd_chain_paddr[j])); } -/* Fill up the RX chain. */ + /* Fill up the RX chain. */ bce_fill_rx_chain(sc); for (i = 0; i < RX_PAGES; i++) { - bus_dmamap_sync( - sc->rx_bd_chain_tag, - sc->rx_bd_chain_map[i], + bus_dmamap_sync(sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i], BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } @@ -5447,9 +5445,7 @@ bce_init_pg_chain(struct bce_softc *sc) bce_fill_pg_chain(sc); for (i = 0; i < PG_PAGES; i++) { - bus_dmamap_sync( - sc->pg_bd_chain_tag, - sc->pg_bd_chain_map[i], + bus_dmamap_sync(sc->pg_bd_chain_tag, sc->pg_bd_chain_map[i], BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } @@ -5732,13 +5728,13 @@ bce_rx_intr(struct bce_softc *sc) /* Prepare the RX chain pages to be accessed by the host CPU. */ for (int i = 0; i < RX_PAGES; i++) bus_dmamap_sync(sc->rx_bd_chain_tag, - sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); + sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTREAD); #ifdef ZERO_COPY_SOCKETS /* Prepare the page chain pages to be accessed by the host CPU. */ for (int i = 0; i < PG_PAGES; i++) bus_dmamap_sync(sc->pg_bd_chain_tag, - sc->pg_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); + sc->pg_bd_chain_map[i], BUS_DMASYNC_POSTREAD); #endif /* Get the hardware's view of the RX consumer index. */ @@ -5765,9 +5761,8 @@ bce_rx_intr(struct bce_softc *sc) sw_rx_cons_idx = RX_CHAIN_IDX(sw_rx_cons); /* Unmap the mbuf from DMA space. */ - bus_dmamap_sync(sc->rx_mbuf_tag, - sc->rx_mbuf_map[sw_rx_cons_idx], - BUS_DMASYNC_POSTREAD); + bus_dmamap_sync(sc->rx_mbuf_tag, sc->rx_mbuf_map[sw_rx_cons_idx], + BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->rx_mbuf_tag, sc->rx_mbuf_map[sw_rx_cons_idx]); @@ -6011,6 +6006,7 @@ bce_rx_int_next_rx: sc->rx_cons = sw_rx_cons; bce_fill_rx_chain(sc); + /* Prepare the page chain pages to be accessed by the NIC. */ for (int i = 0; i < RX_PAGES; i++) bus_dmamap_sync(sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i], BUS_DMASYNC_PREWRITE); @@ -7023,8 +7019,9 @@ bce_intr(void *xsc) DBRUN(sc->interrupts_generated++); + /* Synchnorize before we read from interface's status block */ bus_dmamap_sync(sc->status_tag, sc->status_map, - BUS_DMASYNC_POSTWRITE); + BUS_DMASYNC_POSTREAD); /* * If the hardware status block index @@ -7112,7 +7109,7 @@ bce_intr(void *xsc) } bus_dmamap_sync(sc->status_tag, sc->status_map, - BUS_DMASYNC_PREWRITE); + BUS_DMASYNC_PREREAD); /* Re-enable interrupts. */ bce_enable_intr(sc, 0);