From owner-svn-src-stable@FreeBSD.ORG Tue Aug 23 14:32:59 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 D6B7E106564A; Tue, 23 Aug 2011 14:32:59 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BD2AB8FC14; Tue, 23 Aug 2011 14:32:59 +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 p7NEWxH1007494; Tue, 23 Aug 2011 14:32:59 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7NEWxpU007491; Tue, 23 Aug 2011 14:32:59 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201108231432.p7NEWxpU007491@svn.freebsd.org> From: Marius Strobl Date: Tue, 23 Aug 2011 14:32:59 +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: r225117 - stable/7/sys/dev/mii 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: Tue, 23 Aug 2011 14:33:00 -0000 Author: marius Date: Tue Aug 23 14:32:59 2011 New Revision: 225117 URL: http://svn.freebsd.org/changeset/base/225117 Log: MFC: r225014 r221812 (MFC'ed to stable/7 in r222160) reveals that at least some Broadcom PHYs default to being not only isolated but also powered down after a reset and while they just work fine [sic] when both is the case they don't if they are only deisolate but still powered down. So in order to put PHYs in an overall normal operation mode for the common case, ensure in mii_phy_reset() that they are not powered down after a reset. Unfortunately, this only helps in case of BCM5421, while BCM5709S apparently only work when they remain isolated and powered down after a reset. So don't call mii_phy_reset() in brgphy_reset() and implement the reset locally leaving the problematic bits alone. Effectively this bypasses r221812 for brgphy(4). Thanks to Justin Hibbits for doing a binary search in order to identify the problematic commit. PR: 157405, 158156 Reviewed by: yongari (mii_phy_reset() part) Modified: stable/7/sys/dev/mii/brgphy.c stable/7/sys/dev/mii/mii_physubr.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/mii/brgphy.c ============================================================================== --- stable/7/sys/dev/mii/brgphy.c Tue Aug 23 14:32:53 2011 (r225116) +++ stable/7/sys/dev/mii/brgphy.c Tue Aug 23 14:32:59 2011 (r225117) @@ -913,10 +913,22 @@ brgphy_reset(struct mii_softc *sc) struct bge_softc *bge_sc = NULL; struct bce_softc *bce_sc = NULL; struct ifnet *ifp; - int val; + int i, val; - /* Perform a standard PHY reset. */ - mii_phy_reset(sc); + /* + * Perform a reset. Note that at least some Broadcom PHYs default to + * being powered down as well as isolated after a reset but don't work + * if one or both of these bits are cleared. However, they just work + * fine if both bits remain set, so we don't use mii_phy_reset() here. + */ + PHY_WRITE(sc, BRGPHY_MII_BMCR, BRGPHY_BMCR_RESET); + + /* Wait 100ms for it to complete. */ + for (i = 0; i < 100; i++) { + if ((PHY_READ(sc, BRGPHY_MII_BMCR) & BRGPHY_BMCR_RESET) == 0) + break; + DELAY(1000); + } /* Handle any PHY specific procedures following the reset. */ switch (bsc->mii_oui) { Modified: stable/7/sys/dev/mii/mii_physubr.c ============================================================================== --- stable/7/sys/dev/mii/mii_physubr.c Tue Aug 23 14:32:53 2011 (r225116) +++ stable/7/sys/dev/mii/mii_physubr.c Tue Aug 23 14:32:59 2011 (r225117) @@ -276,8 +276,8 @@ mii_phy_reset(struct mii_softc *sc) DELAY(1000); } - /* NB: a PHY may default to isolation. */ - reg &= ~BMCR_ISO; + /* NB: a PHY may default to being powered down and/or isolated. */ + reg &= ~(BMCR_PDOWN | BMCR_ISO); if ((sc->mii_flags & MIIF_NOISOLATE) == 0 && ((ife == NULL && sc->mii_inst != 0) || (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst)))