Thread (22 messages) 22 messages, 5 authors, 2023-09-06
STALE1011d
Revisions (2)
  1. rfc current
  2. v2 [diff vs current]

[RFC PATCH net-next 5/8] net: phy: balance calls to ->suspend() and ->resume()

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: 2023-08-17 15:07:45
Also in: linux-devicetree, linux-phy, lkml
Subsystem: ethernet phy library, networking drivers, the rest · Maintainers: Andrew Lunn, Heiner Kallweit, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Some future PHY drivers will need to do balanced stuff in these methods,
like phy_power_off() and phy_power_on(). Currently ->resume() is called
twice during initialization, leading to phy_power_off() not actually
doing anything during ->suspend() because the refcount in the generic
PHY core remains elevated.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/phy/phy_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 17cb3e07216a..9cb5aa04b2b5 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1882,7 +1882,7 @@ int __phy_resume(struct phy_device *phydev)
 
 	lockdep_assert_held(&phydev->lock);
 
-	if (!phydrv || !phydrv->resume)
+	if (!phydrv || !phydrv->resume || !phydev->suspended)
 		return 0;
 
 	ret = phydrv->resume(phydev);
@@ -3275,6 +3275,8 @@ static int phy_probe(struct device *dev)
 	if (phydrv->flags & PHY_IS_INTERNAL)
 		phydev->is_internal = true;
 
+	phydev->suspended = true;
+
 	/* Deassert the reset signal */
 	phy_device_reset(phydev, 0);
 
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help