Date: Tue, 29 Dec 2009 14:00:17 +0000 (UTC) From: Philip Paeps <philip@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r201198 - head/sys/dev/mge Message-ID: <200912291400.nBTE0Hl1026302@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <kristof@sigsegv.be> 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",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912291400.nBTE0Hl1026302>