aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mge
diff options
context:
space:
mode:
authorPhilip Paeps <philip@FreeBSD.org>2009-12-29 14:00:17 +0000
committerPhilip Paeps <philip@FreeBSD.org>2009-12-29 14:00:17 +0000
commita6eb469d8e7137a65a4eb813cb0aa80f50e5c812 (patch)
tree61dd45cfe389580d0b12db84e89e6b207e7085b4 /sys/dev/mge
parent5428776e2c3b5bd1ad6164a8a3158dabec287d57 (diff)
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
Notes
Notes: svn path=/head/; revision=201198
Diffstat (limited to 'sys/dev/mge')
-rw-r--r--sys/dev/mge/if_mge.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c
index 0188ae3b79f8..30d485ebd0c1 100644
--- a/sys/dev/mge/if_mge.c
+++ b/sys/dev/mge/if_mge.c
@@ -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",