From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: "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>,
Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [PATCH net] net: phy: fix phy_uses_state_machine()
Date: Sun, 31 Aug 2025 17:38:11 +0100 [thread overview]
Message-ID: <E1usl4F-00000001M0g-1rHO@rmk-PC.armlinux.org.uk> (raw)
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@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>
---
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.
drivers/net/phy/phy_device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7556aa3dd7ee..e6a673faabe6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -288,7 +288,7 @@ static bool phy_uses_state_machine(struct phy_device *phydev)
return phydev->attached_dev && phydev->adjust_link;
/* phydev->phy_link_change is implicitly phylink_phy_change() */
- return true;
+ return !!phydev->phy_link_change;
}
static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
--
2.47.2
next reply other threads:[~2025-08-31 16:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-31 16:38 Russell King (Oracle) [this message]
2025-09-01 8:09 ` [PATCH net] net: phy: fix phy_uses_state_machine() 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)
-- strict thread matches above, loose matches on Subject: below --
2025-09-07 20:44 Russell King (Oracle)
2025-09-08 13:37 ` Vladimir Oltean
2025-09-09 23:50 ` patchwork-bot+netdevbpf
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=E1usl4F-00000001M0g-1rHO@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--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=vladimir.oltean@nxp.com \
/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).