tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Another MII PHY fix.



(2013/06/06 15:48), Masanobu SAITOH wrote:
> 
>  Hi, all.
> 
>  Without following patch. Some drivers which don't use link
> interrput check the link status only every sc->mii_anegticks.
> It's late. The patch is a part of FreeBSD's mii_physubr.c r158649:
> 
>  
> http://svnweb.freebsd.org/base/head/sys/dev/mii/mii_physubr.c?r1=150756&r2=158649
> 
>  Any objection to commit?
> 
> Index: mii_physubr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/mii/mii_physubr.c,v
> retrieving revision 1.76
> diff -u -r1.76 mii_physubr.c
> --- mii_physubr.c     6 Jun 2013 03:10:48 -0000       1.76
> +++ mii_physubr.c     6 Jun 2013 06:07:47 -0000
> @@ -324,23 +324,43 @@
>       /*
>        * If we're not doing autonegotiation, we don't need to do
>        * any extra work here.  However, we need to check the link
> -      * status so we can generate an announcement if the status
> -      * changes.
> +      * status so we can generate an announcement by returning
> +      * with 0 if the status changes.
>        */
>       if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) &&
> -     (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T))
> +         (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) {
> +             /*
> +              * Reset autonegotiation timer to 0 to make sure
> +              * the future autonegotiation start with 0.
> +              */
> +             sc->mii_tick = 0;
>               return (0);
> +     }
>  
>       /* Read the status register twice; BMSR_LINK is latch-low. */
>       reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
>       if (reg & BMSR_LINK) {
>               /*
> -              * See above.
> +              * Reset autonegotiation timer to 0 in case the link is down
> +              * in the next tick.
>                */
> +             sc->mii_tick = 0;
> +             /* See above. */
>               return (0);
>       }
>  
>       /*
> +      * mii_tick == 0 means it's the first tick after changing the media or
> +      * the link became down since the last tick (see above), so return with
> +      * 0 to update the status.
> +      */
> +     if (sc->mii_ticks == 0)
> +             return (0);
> +
> +     /* Now increment the tick */
> +     sc->mii_ticks++;
> +
> +     /*
>        * Only retry autonegotiation every N seconds.
>        */
>       KASSERT(sc->mii_anegticks != 0);

 Done.

 Some MII PHY drivers have the same problem and have been fixed now.



-- 
-----------------------------------------------
                SAITOH Masanobu (msaitoh%execsw.org@localhost
                                 msaitoh%netbsd.org@localhost)


Home | Main Index | Thread Index | Old Index