Re: [PATCH net v2] net: phylink: unwind the PHY binding when bringup fails late
From: Aleksei Sviridkin
Date: Sun Sep 20 2026 - 18:21:08 EST
Yes, and v3 does it that way.
Nothing between the assignment and phy_eee_rx_clock_stop() reads
pl->phydev, and a NULL pl->phydev already means "no PHY" to the
readers. phy_request_interrupt() comes after it and cannot fail, it
falls back to polling itself. So the unwind is gone.
The fallible call itself stays where it is. phy_support_eee() can
reach drv->disable_autonomous_eee, which writes PHY registers, so
lifting phy_eee_rx_clock_stop() above the EEE block would reorder
MDIO. Only the assignment moves.
Tested on an MT7981 board whose MAC implements the LPI ops, so that
call sits on the bringup path of every port. With an MDIO error
injected there the late attach fails with -EIO and the retry brings
the port up. Without the change the box dies instead:
Unable to handle kernel execute from non-executable memory at virtual address 0000000000000000
Workqueue: events_power_efficient phy_state_machine
pc : 0x0
lr : phy_check_link_status+0xc4/0xf0
Call trace:
0x0
_phy_start_aneg+0x4c/0xa0
_phy_state_machine+0x16c/0x300
phy_state_machine+0x28/0x80
The caller detached the PHY after the failure, so phydev->drv is NULL,
but phylink still had the pointer and started it again.