Skip to content

Commit fba863b

Browse files
hkallweitkuba-moo
authored andcommitted
net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM
Resume callback of the PHY driver is called after the one for the MAC driver. The PHY driver resume callback calls phy_init_hw(), and this is potentially problematic if the MAC driver calls phy_start() in its resume callback. One issue was reported with the fec driver and a KSZ8081 PHY which seems to become unstable if a soft reset is triggered during aneg. The new flag allows MAC drivers to indicate that they take care of suspending/resuming the PHY. Then the MAC PM callbacks can handle any dependency between MAC and PHY PM. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a7150e3 commit fba863b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/net/phy/phy_device.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev)
273273
{
274274
struct phy_device *phydev = to_phy_device(dev);
275275

276+
if (phydev->mac_managed_pm)
277+
return 0;
278+
276279
/* We must stop the state machine manually, otherwise it stops out of
277280
* control, possibly with the phydev->lock held. Upon resume, netdev
278281
* may call phy routines that try to grab the same lock, and that may
@@ -294,6 +297,9 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
294297
struct phy_device *phydev = to_phy_device(dev);
295298
int ret;
296299

300+
if (phydev->mac_managed_pm)
301+
return 0;
302+
297303
if (!phydev->suspended_by_mdio_bus)
298304
goto no_resume;
299305

include/linux/phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ struct macsec_ops;
493493
* @loopback_enabled: Set true if this PHY has been loopbacked successfully.
494494
* @downshifted_rate: Set true if link speed has been downshifted.
495495
* @is_on_sfp_module: Set true if PHY is located on an SFP module.
496+
* @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY
496497
* @state: State of the PHY for management purposes
497498
* @dev_flags: Device-specific flags used by the PHY driver.
498499
* @irq: IRQ number of the PHY's interrupt (-1 if none)
@@ -567,6 +568,7 @@ struct phy_device {
567568
unsigned loopback_enabled:1;
568569
unsigned downshifted_rate:1;
569570
unsigned is_on_sfp_module:1;
571+
unsigned mac_managed_pm:1;
570572

571573
unsigned autoneg:1;
572574
/* The most recently read link state */

0 commit comments

Comments
 (0)