From owner-svn-src-all@FreeBSD.ORG Fri May 27 18:46:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC8B6106566B; Fri, 27 May 2011 18:46:24 +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 BB0DF8FC14; Fri, 27 May 2011 18:46:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4RIkOLV047632; Fri, 27 May 2011 18:46:24 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4RIkOLm047630; Fri, 27 May 2011 18:46:24 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201105271846.p4RIkOLm047630@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 27 May 2011 18:46:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222369 - stable/8/sys/dev/bge X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2011 18:46:24 -0000 Author: yongari Date: Fri May 27 18:46:24 2011 New Revision: 222369 URL: http://svn.freebsd.org/changeset/base/222369 Log: MFC r221712: Since r117657, bge(4) does not enable buffer manager for BCM5705 or newer controllers. However, all data sheet I have access has no indication that buffer manager should not be touched on these controllers. It seems the buffer manager always runs on BCM5705 or newer controllers. Some controller(e.g. BCM5719) needs other buffer manager configuration so driver should enable buffer manager for all controllers. Both Linux and OpenBSD/NetBSD use the same approach. This change polls enable bit of block to know whether specified block was really stopped as well as enabling buffer manager for all controllers in driver initialization. Obtained from: NetBSD Modified: stable/8/sys/dev/bge/if_bge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Fri May 27 18:40:31 2011 (r222368) +++ stable/8/sys/dev/bge/if_bge.c Fri May 27 18:46:24 2011 (r222369) @@ -403,6 +403,7 @@ static void bge_start(struct ifnet *); static int bge_ioctl(struct ifnet *, u_long, caddr_t); static void bge_init_locked(struct bge_softc *); static void bge_init(void *); +static void bge_stop_block(struct bge_softc *, bus_size_t, uint32_t); static void bge_stop(struct bge_softc *); static void bge_watchdog(struct bge_softc *); static int bge_shutdown(device_t); @@ -1593,22 +1594,19 @@ bge_blockinit(struct bge_softc *sc) CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_HIWAT, 10); /* Enable buffer manager */ - if (!(BGE_IS_5705_PLUS(sc))) { - CSR_WRITE_4(sc, BGE_BMAN_MODE, - BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN); + CSR_WRITE_4(sc, BGE_BMAN_MODE, + BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN); - /* Poll for buffer manager start indication */ - for (i = 0; i < BGE_TIMEOUT; i++) { - DELAY(10); - if (CSR_READ_4(sc, BGE_BMAN_MODE) & BGE_BMANMODE_ENABLE) - break; - } + /* Poll for buffer manager start indication */ + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + if (CSR_READ_4(sc, BGE_BMAN_MODE) & BGE_BMANMODE_ENABLE) + break; + } - if (i == BGE_TIMEOUT) { - device_printf(sc->bge_dev, - "buffer manager failed to start\n"); - return (ENXIO); - } + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "buffer manager failed to start\n"); + return (ENXIO); } /* Enable flow-through queues */ @@ -5137,6 +5135,20 @@ bge_watchdog(struct bge_softc *sc) ifp->if_oerrors++; } +static void +bge_stop_block(struct bge_softc *sc, bus_size_t reg, uint32_t bit) +{ + int i; + + BGE_CLRBIT(sc, reg, bit); + + for (i = 0; i < BGE_TIMEOUT; i++) { + if ((CSR_READ_4(sc, reg) & bit) == 0) + return; + DELAY(100); + } +} + /* * Stop the adapter and free any mbufs allocated to the * RX and TX lists. @@ -5165,35 +5177,36 @@ bge_stop(struct bge_softc *sc) /* * Disable all of the receiver blocks. */ - BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDBDI_MODE, BGE_RBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RBDC_MODE, BGE_RBDCMODE_ENABLE); + bge_stop_block(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); + bge_stop_block(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE); + bge_stop_block(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE); + bge_stop_block(sc, BGE_RDBDI_MODE, BGE_RBDIMODE_ENABLE); + bge_stop_block(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE); + bge_stop_block(sc, BGE_RBDC_MODE, BGE_RBDCMODE_ENABLE); /* * Disable all of the transmit blocks. */ - BGE_CLRBIT(sc, BGE_SRS_MODE, BGE_SRSMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SBDI_MODE, BGE_SBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SDI_MODE, BGE_SDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDMA_MODE, BGE_RDMAMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SDC_MODE, BGE_SDCMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE); + bge_stop_block(sc, BGE_SRS_MODE, BGE_SRSMODE_ENABLE); + bge_stop_block(sc, BGE_SBDI_MODE, BGE_SBDIMODE_ENABLE); + bge_stop_block(sc, BGE_SDI_MODE, BGE_SDIMODE_ENABLE); + bge_stop_block(sc, BGE_RDMA_MODE, BGE_RDMAMODE_ENABLE); + bge_stop_block(sc, BGE_SDC_MODE, BGE_SDCMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); + bge_stop_block(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE); /* * Shut down all of the memory managers and related * state machines. */ - BGE_CLRBIT(sc, BGE_HCC_MODE, BGE_HCCMODE_ENABLE); - BGE_CLRBIT(sc, BGE_WDMA_MODE, BGE_WDMAMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE); + bge_stop_block(sc, BGE_HCC_MODE, BGE_HCCMODE_ENABLE); + bge_stop_block(sc, BGE_WDMA_MODE, BGE_WDMAMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE); + CSR_WRITE_4(sc, BGE_FTQ_RESET, 0xFFFFFFFF); CSR_WRITE_4(sc, BGE_FTQ_RESET, 0); if (!(BGE_IS_5705_PLUS(sc))) {