[PATCH net-next v3 0/5] net: phy: Fix phy_init_hw() placement and update locking
From: Biju
Date: Sun Apr 12 2026 - 10:00:44 EST
From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
This series fixes two related issues in the PHY subsystem: incorrect
placement of phy_init_hw() in the resume path, and drop/update locking
in several PHY drivers.
Patch 1 identifies that when mac_managed_pm is set, mdio_bus_phy_resume()
is skipped entirely, meaning phy_init_hw() which performs soft reset and
config_init is never called on resume for that path. To make both paths
consistent, phy_init_hw() is moved into phy_resume() so it runs
unconditionally. As a consequence, the separate phy_init_hw() +
phy_resume() call sequence in phy_attach_direct() is collapsed
into a single phy_resume() call.
Patch 2 removes the now-redundant explicit phy_init_hw() call in
rtl8169_up(), since phy_resume() already handles it.
Patch 3 removes manual mutex_lock/unlock(&phydev->lock) from four
functions in the MSCC PHY driver. In vsc85xx_edge_rate_cntl_set(),
the lock wraps a single phy_modify_paged() call, which is already a
fully locked atomic operation that acquires the MDIO bus lock
internally, so the additional phydev->lock is unnecessary. The
remaining three functions — vsc85xx_mac_if_set(),
vsc8531_pre_init_seq_set(), and vsc85xx_eee_init_seq_set() — use
phy_read(), phy_write(), phy_select_page(), and phy_restore_page(),
all of which operate under the MDIO bus lock, so taking phydev->lock
around them provides no additional serialisation. Error-path labels
are updated accordingly.
Patch 4 fixes lan937x_dsp_workaround() in the Microchip T1 driver,
which was incorrectly taking phydev->lock. The function performs raw
MDIO bus accesses and must instead hold mdio_lock. The phy_read() and
phy_write() calls are also switched to their unlocked __phy_read() and
__phy_write() variants since mdio_lock is now held explicitly.
Patch 5 refines the placement introduced in patch 1 by moving
phy_init_hw() from phy_resume() down into __phy_resume(), so that it
is called with phydev->lock already held. This is necessary because
many MAC drivers and phylink reach the resume path via phy_start() ->
__phy_resume() directly, bypassing phy_resume().
v2->v3:
* Moved all the patches into series as the order they get merged
matters, otherwise a git bisect could land on a deadlock.
* Updated commit description for patch#2 and #3.
v1->v2:
* Updated commit description.
* phy_init_hw() is moved from __phy_resume() -> phy_resume() to make it
lock-free.
* Dropped redundant phy_init_hw() call from mdio_bus_phy_resume() and
phy_attach_direct().
Biju Das (5):
net: phy: call phy_init_hw() in phy resume path
r8169: Drop redundant phy_init_hw() call in rtl8169_up()
net: phy: mscc: Drop unnecessary phydev->lock
net: phy: microchip_t1: Replace phydev->lock with mdio_lock in
net: phy: Move phy_init_hw() from phy_resume() to __phy_resume()
drivers/net/ethernet/realtek/r8169_main.c | 1 -
drivers/net/phy/microchip_t1.c | 8 ++---
drivers/net/phy/mscc/mscc_main.c | 41 +++++++----------------
drivers/net/phy/phy_device.c | 14 ++++----
4 files changed, 22 insertions(+), 42 deletions(-)
--
2.43.0