From owner-svn-src-stable@FreeBSD.ORG Fri Jul 26 06:23:58 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 357F434C; Fri, 26 Jul 2013 06:23:58 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 217942710; Fri, 26 Jul 2013 06:23:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6Q6NvgN009600; Fri, 26 Jul 2013 06:23:57 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6Q6NvTU009599; Fri, 26 Jul 2013 06:23:57 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201307260623.r6Q6NvTU009599@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 26 Jul 2013 06:23:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r253664 - stable/8/sys/dev/ae X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 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: Fri, 26 Jul 2013 06:23:58 -0000 Author: yongari Date: Fri Jul 26 06:23:57 2013 New Revision: 253664 URL: http://svnweb.freebsd.org/changeset/base/253664 Log: MFC r253404: o TxD ring requires 8 bytes alignment to work so change alignment constraint to 8. Previously it may have triggered watchdog timeouts. o Check whether interrupt is ours or not. o Enable interrupts before attemping to transmit queued packets. This will slightly improve TX performance. o No need to clear IFF_DRV_OACTIVE in a loop. AE_FLAG_TXAVAIL is used to know whether there are enough available TxD ring space. o Added missing bus_dmamap_sync(9) in ae_rx_intr() and rearranged code to avoid unncessary register access. o Make sure to clear TxD, TxS, RxD rings in driver initialization. Otherwise some data in these rings could be interpreted as 'updated' which in turn will advance internally maintained pointers and can trigger watchdog timeouts. PR: kern/180382 Modified: stable/8/sys/dev/ae/if_ae.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/ae/ (props changed) Modified: stable/8/sys/dev/ae/if_ae.c ============================================================================== --- stable/8/sys/dev/ae/if_ae.c Fri Jul 26 06:23:06 2013 (r253663) +++ stable/8/sys/dev/ae/if_ae.c Fri Jul 26 06:23:57 2013 (r253664) @@ -586,6 +586,9 @@ ae_init_locked(ae_softc_t *sc) val = eaddr[0] << 8 | eaddr[1]; AE_WRITE_4(sc, AE_EADDR1_REG, val); + bzero(sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120); + bzero(sc->txd_base, AE_TXD_BUFSIZE_DEFAULT); + bzero(sc->txs_base, AE_TXS_COUNT_DEFAULT * 4); /* * Set ring buffers base addresses. */ @@ -1116,7 +1119,7 @@ ae_alloc_rings(ae_softc_t *sc) * Create DMA tag for TxD. */ error = bus_dma_tag_create(sc->dma_parent_tag, - 4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, + 8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, AE_TXD_BUFSIZE_DEFAULT, 1, AE_TXD_BUFSIZE_DEFAULT, 0, NULL, NULL, &sc->dma_txd_tag); @@ -1129,7 +1132,7 @@ ae_alloc_rings(ae_softc_t *sc) * Create DMA tag for TxS. */ error = bus_dma_tag_create(sc->dma_parent_tag, - 4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, + 8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, AE_TXS_COUNT_DEFAULT * 4, 1, AE_TXS_COUNT_DEFAULT * 4, 0, NULL, NULL, &sc->dma_txs_tag); @@ -1762,6 +1765,10 @@ ae_int_task(void *arg, int pending) ifp = sc->ifp; val = AE_READ_4(sc, AE_ISR_REG); /* Read interrupt status. */ + if (val == 0) { + AE_UNLOCK(sc); + return; + } /* * Clear interrupts and disable them. @@ -1784,12 +1791,16 @@ ae_int_task(void *arg, int pending) ae_tx_intr(sc); if ((val & AE_ISR_RX_EVENT) != 0) ae_rx_intr(sc); - } + /* + * Re-enable interrupts. + */ + AE_WRITE_4(sc, AE_ISR_REG, 0); - /* - * Re-enable interrupts. - */ - AE_WRITE_4(sc, AE_ISR_REG, 0); + if ((sc->flags & AE_FLAG_TXAVAIL) != 0) { + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + ae_start_locked(ifp); + } + } AE_UNLOCK(sc); } @@ -1850,10 +1861,10 @@ ae_tx_intr(ae_softc_t *sc) ifp->if_oerrors++; sc->tx_inproc--; - - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } + if ((sc->flags & AE_FLAG_TXAVAIL) != 0) + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (sc->tx_inproc < 0) { if_printf(ifp, "Received stray Tx interrupt(s).\n"); sc->tx_inproc = 0; @@ -1861,11 +1872,6 @@ ae_tx_intr(ae_softc_t *sc) if (sc->tx_inproc == 0) sc->wd_timer = 0; /* Unarm watchdog. */ - - if ((sc->flags & AE_FLAG_TXAVAIL) != 0) { - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - ae_start_locked(ifp); - } /* * Syncronize DMA buffers. @@ -1924,7 +1930,7 @@ ae_rx_intr(ae_softc_t *sc) ae_rxd_t *rxd; struct ifnet *ifp; uint16_t flags; - int error; + int count, error; KASSERT(sc != NULL, ("[ae, %d]: sc is NULL!", __LINE__)); @@ -1938,7 +1944,7 @@ ae_rx_intr(ae_softc_t *sc) bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - for (;;) { + for (count = 0;; count++) { rxd = (ae_rxd_t *)(sc->rxd_base + sc->rxd_cur); flags = le16toh(rxd->flags); if ((flags & AE_RXD_UPDATE) == 0) @@ -1965,10 +1971,14 @@ ae_rx_intr(ae_softc_t *sc) } } - /* - * Update Rx index. - */ - AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur); + if (count > 0) { + bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + /* + * Update Rx index. + */ + AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur); + } } static void