LKML Archive on
help / color / mirror / Atom feed
From: Florian Fainelli <>
	Florian Fainelli <>,
	Andrew Lunn <>,
	Heiner Kallweit <>,
	Russell King <>,
	"David S. Miller" <>,
	Fugang Duan <>, (open list)
Subject: [PATCH net] net: phy: Avoid multiple suspends
Date: Thu, 20 Feb 2020 15:34:53 -0800	[thread overview]
Message-ID: <> (raw)

It is currently possible for a PHY device to be suspended as part of a
network device driver's suspend call while it is still being attached to
that net_device, either via phy_suspend() or implicitly via phy_stop().

Later on, when the MDIO bus controller get suspended, we would attempt
to suspend again the PHY because it is still attached to a network

This is both a waste of time and creates an opportunity for improper
clock/power management bugs to creep in.

Fixes: 803dd9c77ac3 ("net: phy: avoid suspending twice a PHY")
Signed-off-by: Florian Fainelli <>
Heiner, Andrew,

I did consider adding logic that would check for phydev->suspended in
phy_suspend() and phy_resume(), but this was really the only place where
I found it to be problematic.

 drivers/net/phy/phy_device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 6a5056e0ae77..6131aca79823 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -247,7 +247,7 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
 	 * MDIO bus driver and clock gated at this point.
 	if (!netdev)
-		return !phydev->suspended;
+		goto out;
 	if (netdev->wol_enabled)
 		return false;
@@ -267,7 +267,8 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
 	if (device_may_wakeup(&netdev->dev))
 		return false;
-	return true;
+	return !phydev->suspended;
 static int mdio_bus_phy_suspend(struct device *dev)

             reply	other threads:[~2020-02-20 23:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 23:34 Florian Fainelli [this message]
2020-02-24  4:59 ` [PATCH net] net: phy: Avoid multiple suspends David Miller
2020-03-10 14:16   ` Geert Uytterhoeven
2020-03-10 16:46     ` Florian Fainelli
2020-03-10 17:34       ` Heiner Kallweit
2020-03-11  9:17       ` Geert Uytterhoeven
2020-03-11 21:22         ` Heiner Kallweit
2020-03-12  8:26           ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).