From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net] net: phy: fix phy_uses_state_machine()
Date: Mon, 8 Sep 2025 16:37:18 +0300 [thread overview]
Message-ID: <20250908133718.mjw476wpaysj6zev@skbuf> (raw)
In-Reply-To: <E1uvMEz-00000003Aoe-3qWe@rmk-PC.armlinux.org.uk> <E1uvMEz-00000003Aoe-3qWe@rmk-PC.armlinux.org.uk>
On Sun, Sep 07, 2025 at 09:44:01PM +0100, Russell King (Oracle) wrote:
> The blamed commit changed the conditions which phylib uses to stop
> and start the state machine in the suspend and resume paths, and
> while improving it, has caused two issues.
>
> The original code used this test:
>
> phydev->attached_dev && phydev->adjust_link
>
> and if true, the paths would handle the PHY state machine. This test
> evaluates true for normal drivers that are using phylib directly
> while the PHY is attached to the network device, but false in all
> other cases, which include the following cases:
>
> - when the PHY has never been attached to a network device.
> - when the PHY has been detached from a network device (as phy_detach()
> sets phydev->attached_dev to NULL, phy_disconnect() calls
> phy_detach() and additionally sets phydev->adjust_link NULL.)
> - when phylink is using the driver (as phydev->adjust_link is NULL.)
>
> Only the third case was incorrect, and the blamed commit attempted to
> fix this by changing this test to (simplified for brevity, see
> phy_uses_state_machine()):
>
> phydev->phy_link_change == phy_link_change ?
> phydev->attached_dev && phydev->adjust_link : true
>
> However, this also incorrectly evaluates true in the first two cases.
>
> Fix the first case by ensuring that phy_uses_state_machine() returns
> false when phydev->phy_link_change is NULL.
>
> Fix the second case by ensuring that phydev->phy_link_change is set to
> NULL when phy_detach() is called.
>
> Reported-by: Xu Yang <xu.yang_2@nxp.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@armlinux.org.uk>
> ---
>
> v2: updated commit description
..and made an addition to phy_detach() which fixes the second case.
>
> drivers/net/phy/phy_device.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
next prev parent reply other threads:[~2025-09-08 13:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 20:44 [PATCH net] net: phy: fix phy_uses_state_machine() Russell King (Oracle)
2025-09-08 13:37 ` Vladimir Oltean [this message]
2025-09-09 23:50 ` patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2025-08-31 16:38 Russell King (Oracle)
2025-09-01 8:09 ` Vladimir Oltean
2025-09-01 8:42 ` Vladimir Oltean
2025-09-01 9:09 ` Russell King (Oracle)
2025-09-01 9:35 ` Vladimir Oltean
2025-09-01 10:05 ` Russell King (Oracle)
2025-09-01 10:36 ` Vladimir Oltean
2025-09-01 14:14 ` Russell King (Oracle)
2025-09-01 14:25 ` Vladimir Oltean
2025-09-01 9:34 ` Russell King (Oracle)
2025-09-01 9:39 ` Vladimir Oltean
2025-09-01 10:23 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908133718.mjw476wpaysj6zev@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).