From owner-svn-src-head@FreeBSD.ORG Tue Dec 29 14:00:17 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 6D57E106568B; Tue, 29 Dec 2009 14:00:17 +0000 (UTC) (envelope-from philip@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D7F78FC0A; Tue, 29 Dec 2009 14:00:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBTE0HdE026304; Tue, 29 Dec 2009 14:00:17 GMT (envelope-from philip@svn.freebsd.org) Received: (from philip@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBTE0Hl1026302; Tue, 29 Dec 2009 14:00:17 GMT (envelope-from philip@svn.freebsd.org) Message-Id: <200912291400.nBTE0Hl1026302@svn.freebsd.org> From: Philip Paeps Date: Tue, 29 Dec 2009 14:00:17 +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: r201198 - head/sys/dev/mge 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: Tue, 29 Dec 2009 14:00:17 -0000 Author: philip Date: Tue Dec 29 14:00:17 2009 New Revision: 201198 URL: http://svn.freebsd.org/changeset/base/201198 Log: Fix autonegotiation: tell the MAC where to find the PHY. Fix crashes in the detach path. Submitted by: Kristof Provost MFC after: 1 month Modified: head/sys/dev/mge/if_mge.c Modified: head/sys/dev/mge/if_mge.c ============================================================================== --- head/sys/dev/mge/if_mge.c Tue Dec 29 13:55:15 2009 (r201197) +++ head/sys/dev/mge/if_mge.c Tue Dec 29 14:00:17 2009 (r201198) @@ -611,6 +611,7 @@ static int mge_attach(device_t dev) { struct mge_softc *sc; + struct mii_softc *miisc; struct ifnet *ifp; uint8_t hwaddr[ETHER_ADDR_LEN]; int i, error ; @@ -689,13 +690,15 @@ mge_attach(device_t dev) error = mii_phy_probe(dev, &sc->miibus, mge_ifmedia_upd, mge_ifmedia_sts); if (error) { device_printf(dev, "MII failed to find PHY\n"); - if_free(ifp); - sc->ifp = NULL; mge_detach(dev); return (error); } sc->mii = device_get_softc(sc->miibus); + /* Tell the MAC where to find the PHY so autoneg works */ + miisc = LIST_FIRST(&sc->mii->mii_phys); + MGE_WRITE(sc, MGE_REG_PHYDEV, miisc->mii_phy); + /* Attach interrupt handlers */ for (i = 0; i < 2; ++i) { error = bus_setup_intr(dev, sc->res[1 + i], @@ -704,7 +707,7 @@ mge_attach(device_t dev) if (error) { device_printf(dev, "could not setup %s\n", mge_intrs[i].description); - ether_ifdetach(sc->ifp); + mge_detach(dev); return (error); } } @@ -729,6 +732,9 @@ mge_detach(device_t dev) /* Stop and release all interrupts */ for (i = 0; i < 2; ++i) { + if (!sc->ih_cookie[i]) + continue; + error = bus_teardown_intr(dev, sc->res[1 + i], sc->ih_cookie[i]); if (error) device_printf(dev, "could not release %s\n",