Module Name:    src
Committed By:   msaitoh
Date:           Wed Feb 11 23:07:13 UTC 2015

Modified Files:
        src/sys/dev/pci: if_bge.c

Log Message:
Fix three bugs reported by enami@:
 - bge_miibus_writereg(): Fix a bug that BCM5906 may leave an APE lock.
 - Fix hwcfg4 isn't printed correctly.
 - Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some PCIe 
devices.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.277 src/sys/dev/pci/if_bge.c:1.278
--- src/sys/dev/pci/if_bge.c:1.277	Sun Aug 10 16:44:36 2014
+++ src/sys/dev/pci/if_bge.c	Wed Feb 11 23:07:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.277 2014/08/10 16:44:36 tls Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.278 2015/02/11 23:07:13 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.277 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.278 2015/02/11 23:07:13 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1397,13 +1397,13 @@ bge_miibus_writereg(device_t dev, int ph
 	uint32_t autopoll;
 	int i;
 
-	if (bge_ape_lock(sc, sc->bge_phy_ape_lock) != 0)
-		return;
-
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906 &&
 	    (reg == BRGPHY_MII_1000CTL || reg == BRGPHY_MII_AUXCTL))
 		return;
 
+	if (bge_ape_lock(sc, sc->bge_phy_ape_lock) != 0)
+		return;
+
 	/* Reading with autopolling on may trigger PCI errors */
 	autopoll = CSR_READ_4(sc, BGE_MI_MODE);
 	if (autopoll & BGE_MIMODE_AUTOPOLL) {
@@ -3742,7 +3742,7 @@ bge_attach(device_t parent, device_t sel
 			hwcfg2 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_2);
 		if (sc->bge_flags & BGEF_PCIE)
 			hwcfg3 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_3);
-		if (BGE_ASICREV(sc->bge_chipid == BGE_ASICREV_BCM5785))
+		if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785)
 			hwcfg4 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_4);
 		if (BGE_IS_5717_PLUS(sc))
 			hwcfg5 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_5);
@@ -4170,7 +4170,7 @@ bge_reset(struct bge_softc *sc)
 	 * XXX: from FreeBSD/Linux; no documentation
 	 */
 	if (sc->bge_flags & BGEF_PCIE) {
-		if (BGE_ASICREV(sc->bge_chipid != BGE_ASICREV_BCM5785) &&
+		if ((BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5785) &&
 		    !BGE_IS_57765_PLUS(sc) &&
 		    (CSR_READ_4(sc, BGE_PHY_TEST_CTRL_REG) ==
 			(BGE_PHY_PCIE_LTASS_MODE | BGE_PHY_PCIE_SCRAM_MODE))) {

Reply via email to