net: fec: add pm runtime force suspend and resume support
Subsystems (3)
[email protected]
maintainerPATCH 1/1 net: fec: add pm runtime force suspend and resume support
From: Wei Fang <[email protected]>
Force mii bus into runtime pm suspend state during device suspends, since phydev state is already PHY_HALTED, and there is no need to access mii bus during device suspend state. Then force mii bus into runtime pm resume state when device resumes.
--- drivers/net/ethernet/freescale/fec.h | 1 + drivers/net/ethernet/freescale/fec_main.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
drivers/net/ethernet/freescale/fec.h +1 -0
@@ -579,6 +579,7 @@ struct fec_enet_private {struct device_node *phy_node;bool rgmii_txc_dly;bool rgmii_rxc_dly; +bool rpm_active;int link;int full_duplex;int speed;
drivers/net/ethernet/freescale/fec_main.c +13 -0
@@ -4092,6 +4092,7 @@ static int __maybe_unused fec_suspend(struct device *dev) {struct net_device *ndev =dev_get_drvdata (dev);struct fec_enet_private *fep =netdev_priv (ndev); +int ret;rtnl_lock ();if (netif_running (ndev)) {
@@ -4116,6 +4117,15 @@ static int __maybe_unused fec_suspend(struct device *dev) }/* It's safe to disable clocks since interrupts are masked */ fec_enet_clk_enable (ndev, false); + + fep->rpm_active = !pm_runtime_status_suspended (dev); +if (fep->rpm_active) { + ret =pm_runtime_force_suspend (dev); +if (ret <0 ) { +rtnl_unlock (); +return ret; + } + } }rtnl_unlock ();
@@ -4146,6 +4156,9 @@ static int __maybe_unused fec_resume(struct device *dev)rtnl_lock ();if (netif_running (ndev)) { +if (fep->rpm_active) +pm_runtime_force_resume (dev); + ret =fec_enet_clk_enable (ndev, true);if (ret) {rtnl_unlock ();
Signature · 1 line
2.25.1
Quoted 6 lines · On Tue, Sep 06, 2022 at 04:39:23PM +0800, [email protected] wrote:
From: Wei Fang <[email protected]>
Force mii bus into runtime pm suspend state during device suspends, since phydev state is already
PHY_HALTED, and there is no need to access mii bus during device suspend state. Then force mii bus into runtime pm resume state when device resumes.
Have you tested this with an Ethernet switch hanging off the MDIO bus? It has a life cycle of its own, and i'm not sure it is guaranteed that the switch is suspended before the FEC. That is why the MDIO read/write functions have there own runtime PM calls, they can be used when the interface itself is down.
Andrew
Wei Fang
maintainerQuoted 19 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: 2022年9月6日 22:42
To: Wei Fang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next] net: fec: add pm runtime force suspend and resume supportQuoted 6 lines · On Tue, Sep 06, 2022 at 04:39:23PM +0800, [email protected] wrote:
From: Wei Fang <[email protected]>
Force mii bus into runtime pm suspend state during device suspends, since phydev state is already
PHY_HALTED, and there is no need to access mii bus during device suspend state. Then force mii bus into runtime pm resume state when device resumes.
Quoted 6 lines
Have you tested this with an Ethernet switch hanging off the MDIO bus? It has a life cycle of its own, and i'm not sure it is guaranteed that the switch is suspended before the FEC. That is why the MDIO read/write functions have there own runtime PM calls, they can be used when the interface itself is down.
Sorry, we don't have the product that an Ethernet switch hanging off the MIDO bus of FEC. But I have tested system suspend/resume on i.MX6UL platform which has two FEC MAC and share one MDIO bus. I have confirmed that the two PHYs are suspended before the FEC. So it's safe to force the MDIO bus into runtime suspend state. In addition, this patch has been already submitted to our local repository for 3 years and our test team has test it for several times.
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 6 Sep 2022 16:39:23 +0800 you wrote:
From: Wei Fang <[email protected]>
Force mii bus into runtime pm suspend state during device suspends, since phydev state is already
PHY_HALTED, and there is no need to access mii bus during device suspend state. Then force mii bus into runtime pm resume state when device resumes.[...]
Here is the summary with links:
- [net-next] net: fec: add pm runtime force suspend and resume support
https://git.kernel.org/netdev/net-next/c/da970726ea87
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html