On Wed, May 22, 2013 at 18:08 +0200, Mark Kettenis wrote: > > Date: Wed, 22 May 2013 17:59:19 +0200 > > From: Mike Belopuhov <m...@belopuhov.com> > > > > On Tue, May 21, 2013 at 17:16 +0200, Mike Belopuhov wrote: > > > from freebsd. ok? > > > > > > > ping! > > There are more drivers in the tree that do the same thing. And then > there lots that have the same bug. Would be nice if we could fix > those as well. Anyway, > > ok kettenis@ >
fair enough. it looks like rgephy needs to proceed to mii_phy_status and mii_phy_update, but returns instead. i'd like it to get tested. diff --git sys/dev/mii/brgphy.c sys/dev/mii/brgphy.c index 7f0bae2..461c798 100644 --- sys/dev/mii/brgphy.c +++ sys/dev/mii/brgphy.c @@ -412,8 +412,10 @@ setit: * the BMSR twice in case it's latched. */ reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) + if (reg & BMSR_LINK) { + sc->mii_ticks = 0; /* Reset autoneg timer. */ break; + } /* * Only retry autonegotiation every mii_anegticks seconds. diff --git sys/dev/mii/dcphy.c sys/dev/mii/dcphy.c index d1ad0b4..841fe3f 100644 --- sys/dev/mii/dcphy.c +++ sys/dev/mii/dcphy.c @@ -272,8 +272,10 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) break; reg = CSR_READ_4(dc_sc, DC_10BTSTAT); - if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) + if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) { + sc->mii_ticks = 0; break; + } /* * Only retry autonegotiation every mii_anegticks seconds. diff --git sys/dev/mii/mlphy.c sys/dev/mii/mlphy.c index 56858b5..fb5784b 100644 --- sys/dev/mii/mlphy.c +++ sys/dev/mii/mlphy.c @@ -306,6 +306,7 @@ mlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) msc->ml_linked = 1; mlphy_status(sc); } + sc->mii_ticks = 0; break; } /* diff --git sys/dev/mii/rgephy.c sys/dev/mii/rgephy.c index 2c1ddbb..5fe9dc6 100644 --- sys/dev/mii/rgephy.c +++ sys/dev/mii/rgephy.c @@ -251,12 +251,16 @@ setit: */ if (sc->mii_rev < 2) { reg = PHY_READ(sc, RL_GMEDIASTAT); - if (reg & RL_GMEDIASTAT_LINK) + if (reg & RL_GMEDIASTAT_LINK) { + sc->mii_ticks = 0; break; + } } else { reg = PHY_READ(sc, RGEPHY_SR); - if (reg & RGEPHY_SR_LINK) + if (reg & RGEPHY_SR_LINK) { + sc->mii_ticks = 0; break; + } } /* @@ -267,7 +271,7 @@ setit: sc->mii_ticks = 0; rgephy_mii_phy_auto(sc); - return (0); + break; } /* Update the media status. */ diff --git sys/dev/mii/urlphy.c sys/dev/mii/urlphy.c index 09df2bd..2e3b475 100644 --- sys/dev/mii/urlphy.c +++ sys/dev/mii/urlphy.c @@ -186,8 +186,10 @@ urlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* Read the status register twice; MSR_LINK is latch-low. */ reg = PHY_READ(sc, URLPHY_MSR) | PHY_READ(sc, URLPHY_MSR); - if (reg & URLPHY_MSR_LINK) - return (0); + if (reg & URLPHY_MSR_LINK) { + sc->mii_ticks = 0; + break; + } /* * Only retry autonegotiation every mii_anegticks seconds. diff --git sys/dev/mii/xmphy.c sys/dev/mii/xmphy.c index 1d3e2ea..e7687e6 100644 --- sys/dev/mii/xmphy.c +++ sys/dev/mii/xmphy.c @@ -212,8 +212,10 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) * the BMSR twice in case it's latched. */ reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) + if (reg & BMSR_LINK) { + sc->mii_ticks = 0; break; + } /* * Only retry autonegotiation every mii_anegticks seconds. diff --git sys/dev/sbus/be.c sys/dev/sbus/be.c index 1527ff0..7dc459d 100644 --- sys/dev/sbus/be.c +++ sys/dev/sbus/be.c @@ -1531,6 +1531,7 @@ be_intphy_service(struct be_softc *sc, struct mii_data *mii, int cmd) sc->sc_dev.dv_xname, (bmcr & BMCR_S100) ? "100" : "10"); } + sc->sc_mii_ticks = 0; return (0); }