Re: [PATCH net] net: mii: Fix unknown speed after link up
From: Andrew Lunn
Date: Wed Sep 30 2026 - 20:21:35 EST
On Wed, Sep 30, 2026 at 07:38:42PM +0800, Linmao Li wrote:
> mii_ethtool_get_link_ksettings() reads BMSR only once. Since
> BMSR_LSTATUS is latched low, the first query after link up can
> report SPEED_UNKNOWN even though the link is already up.
>
> This is seen with r8152, which detects carrier using a MAC register
> without clearing the BMSR latch. NetworkManager can then keep
> reporting 0 Mb/s until the next carrier change.
>
> Read BMSR twice to obtain the current link status, as mii_link_ok()
> already does.
There is a reason for this latch behaviour, so you should not ignore
it. It ensures a link down is reported, even if it is for a short
period.
I suggest you change the code to detect link based on BMSR, not a MAC
register. Better still, throw away all the mii code and port it to
phylink. A lot of code will go away because phylink/phylib and PHY
drivers will implement it.
Andrew
---
pw-bot: cr