[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aKg7nf8YczCT6N0O@shell.armlinux.org.uk>
Date: Fri, 22 Aug 2025 10:42:53 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
kernel@...gutronix.de, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/1] net: phy: Clear link-specific data on
link down
On Fri, Aug 22, 2025 at 11:29:01AM +0200, Oleksij Rempel wrote:
> On Fri, Aug 22, 2025 at 10:19:24AM +0100, Russell King (Oracle) wrote:
> > On Fri, Aug 22, 2025 at 11:09:47AM +0200, Oleksij Rempel wrote:
> > > When a network interface is brought down, the associated PHY is stopped.
> > > However, several link-specific parameters within the phy_device struct
> > > are not cleared. This leads to userspace tools like ethtool reporting
> > > stale information from the last active connection, which is misleading
> > > as the link is no longer active.
> >
> > This is not a good idea. Consider the case where the PHY has been
> > configured with autoneg disabled, and phydev->speed etc specifies
> > the desired speed.
> >
> > When the link goes down, all that state gets cleared, and we lose
> > the user's settings.
> >
> > So no, I don't think this is appropriate.
> >
> > I think it is appropriate to clear some of the state, but anything that
> > the user can configure (such as ->speed and ->duplex) must not be
> > cleared.
>
> Hm... should it be cleared conditionally? If autoneg is used, clear the
> speed and duplex?
Actually no, you can't do any of this here.
Look at phy_ethtool_set_eee_noneg(). If the LPI configuration changes,
it needs to inform the MAC of the change, and it does that by
_simulating_ a brief loss of link by calling phy_link_down() followed
by phy_link_up() - expecting all state to be preserved except that
which needs to be modified.
Maybe we should do something in the PHY_HALTED state in
_phy_state_machine() ?
Note that in the usual case of link down, it is the responsibility of
phy_read_status() to update most of what you're clearing, the
exception is phydev->eee_active and phydev->enable_tx_lpi which are
managed by phylib itself.
I think that both the PHY_HALTED and PHY_ERROR states should be
clearing phydev->eee_active and phydev->enable_tx_lpi, so that
should be in the existing if().
I'm not sure we want to clear out the remainder of the state on
PHY_ERROR, as this would aid debugging when something goes wrong.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists