[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLV0M2EiAnaxTxt2@shell.armlinux.org.uk>
Date: Mon, 1 Sep 2025 11:23:47 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Vladimir Oltean <vladimir.oltean@....com>
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>, netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net] net: phy: fix phy_uses_state_machine()
On Mon, Sep 01, 2025 at 12:39:57PM +0300, Vladimir Oltean wrote:
> On Mon, Sep 01, 2025 at 10:34:41AM +0100, Russell King (Oracle) wrote:
> > On Sun, Aug 31, 2025 at 05:38:11PM +0100, Russell King (Oracle) wrote:
> > > phy_uses_state_machine() is called from the resume path (see
> > > mdio_bus_phy_resume()) which will be called for all devices whether
> > > they are connected to a network device or not.
> > >
> > > phydev->phy_link_change is initialised by phy_attach_direct(), and
> > > overridden by phylink. This means that a never-connected PHY will
> > > have phydev->phy_link_change set to NULL, which causes
> > > phy_uses_state_machine() to return true. This is incorrect.
> > >
> > > Fix the case where phydev->phy_link_change is NULL.
> > >
> > > Reported-by: Xu Yang <xu.yang_2@....com>
> > > Link: https://lore.kernel.org/r/20250806082931.3289134-1-xu.yang_2@nxp.com
> > > Fixes: fc75ea20ffb4 ("net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY")
> > > Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> > > ---
> > > The provided Link: rather than Closes: is because there were two issues
> > > identified in that thread, and this patch only addresses one of them.
> > > Therefore, it is not correct to mark that issue closed.
> > >
> > > Xu Yang reported this fixed the problem for him, and it is an oversight
> > > in the phy_uses_state_machine() test.
> >
> > While looking at this after Vladimir's comments, I've realised that
> > phy_uses_state_machine() will also return true when a PHY has been
> > attached and detached by phylink - phydev->phy_link_change remains
> > set to phylink_phy_change after it has been detached. So, there will
> > definitely be a v2 for this.
> >
> > --
> > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
>
> Good point. Do you plan to modify phy_disconnect() to set
> phydev->phy_link_change = NULL?
No, I've put it in phy_detach() because this sequence:
phy_attach_direct()
phylink_bringup_phy()
phydev->phy_link_change set
error occurs
phy_detach()
would result in phydev->phy_link_change remaining set if it was
only cleared in phy_disconnect().
--
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