[PATCH net v9 3/5] net: phy: stop postponing PHY interrupts when phy_suspend() fails
netdev-bot+sashiko at kernel.org
netdev-bot+sashiko at kernel.org
Mon Nov 30 23:30:48 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new failure branch in mdio_bus_phy_suspend()
(drivers/net/phy/phy_device.c) undoes only the phylib side of the…
--
net: phy: stop postponing PHY interrupts when phy_suspend() fails
When phy_suspend() fails in mdio_bus_phy_suspend(), the patch now undoes
the interrupt postponing and restarts the state machine. It also sets
suspended_by_mdio_bus only once phy_suspend() has succeeded. The error
paths of mdio_bus_phy_resume() are left as they were.
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index f2e2370b4be7c..2d2058c29f300 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
[ ... ]
> @@ -385,9 +386,20 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev)
> if (!mdio_bus_phy_may_suspend(phydev))
> return 0;
>
> + ret = phy_suspend(phydev);
> + if (ret) {
> + /* The PM core skips the resume callback of a device whose
> + * suspend callback failed.
> + */
> + mdio_bus_phy_resume_irq(phydev);
> + if (phy_uses_state_machine(phydev))
> + phy_start_machine(phydev);
> + return ret;
> + }
[Severity: Medium]
This branch undoes the phylib side of the suspend. Does it also undo what
phydrv->suspend() may have done to the hardware before it failed?
phy_suspend() doesn't roll anything back. On error it only skips setting
phydev->suspended.
Some PHY drivers mask their own interrupt sources first and then do a
power-down MDIO write that can fail. For example:
drivers/net/phy/marvell-88q2xxx.c:mv88q2xxx_suspend() {
...
if (phy_interrupt_is_valid(phydev)) {
phydev->interrupts = PHY_INTERRUPT_DISABLED;
ret = mv88q2xxx_config_intr(phydev);
if (ret)
return ret;
}
return phy_set_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1,
MDIO_CTRL1_LPOWER);
}
kszphy_suspend() in micrel.c follows the same pattern through
drv->config_intr() and then kszphy_generic_suspend()->genphy_suspend().
So does dp83867_suspend(), through dp83867_config_intr() and then
genphy_suspend().
Suppose the final power-down write fails, for example with an MDIO timeout
or -EIO. The PHY's interrupt generation is then masked in hardware and
phydev->interrupts is still PHY_INTERRUPT_DISABLED. Only the drivers'
resume callbacks, such as mv88q2xxx_resume() and kszphy_resume(), turn it
back on. This branch calls neither phy_resume() nor phy_init_hw().
phydev->irq is still valid, so phy_polling_mode() returns false. After the
restarted state machine runs once, phylib waits for PHY interrupts the
hardware no longer generates. Would link up/down changes then be lost
until ifdown/ifup or the next successful suspend/resume cycle?
Would calling phy_resume() here help? __phy_resume() calls
phydrv->resume() whether or not phydev->suspended is set. The other option
would be for these drivers' suspend callbacks to undo their interrupt
masking on error.
> +
> phydev->suspended_by_mdio_bus = 1;
>
> - return phy_suspend(phydev);
> + return 0;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-phylib-mac-pm-irq-v3-v9-0-7b9c3c9ac9f7%40iav.lv
More information about the Linux-rockchip
mailing list