net: stmmac: stm32: Do not suspend downed interface
Subsystems (4)
PATCH 1/1 net: stmmac: stm32: Do not suspend downed interface
If an interface is down, the ETHnSTP clock are not running. Suspending such an interface will attempt to stop already stopped ETHnSTP clock, and produce a warning in the kernel log about this.
STM32MP25xx that is booted from NFS root via its first ethernet MAC (also the consumer of ck_ker_eth1stp) and with its second ethernet MAC downed produces the following warnings during suspend resume cycle. This can be provoked even using pm_test:
"
$ echo devices > /sys/power/pm_test $ echo mem > /sys/power/state ... ck_ker_eth2stp already disabled ... ck_ker_eth2stp already unprepared ... "
Fix this by not manipulating with the clock during suspend resume of interfaces which are downed.
---
Cc: "David S. Miller" <[email protected]>
Cc: "Russell King (Oracle)" <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Christophe Roullier <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Simon Horman <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +10 -0
@@ -618,11 +618,21 @@ static void stm32_dwmac_remove(struct platform_device *pdev)static int stm32mp1_suspend (struct stm32_dwmac *dwmac) { +struct net_device *ndev =dev_get_drvdata (dwmac->dev); + +if (!ndev || !netif_running (ndev)) +return 0 ; +return clk_prepare_enable (dwmac->clk_ethstp); }static void stm32mp1_resume (struct stm32_dwmac *dwmac) { +struct net_device *ndev =dev_get_drvdata (dwmac->dev); + +if (!ndev || !netif_running (ndev)) +return ; +clk_disable_unprepare (dwmac->clk_ethstp); }
Signature · 1 line
2.51.0
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c static void stm32_dwmac_remove(struct platform_device *pdev) · line 626
Quoted 12 lines · Marek Vasut
If an interface is down, the ETHnSTP clock are not running. Suspending such an interface will attempt to stop already stopped ETHnSTP clock, and produce a warning in the kernel log about this.
static int
stm32mp1_suspend(struct stm32_dwmac *dwmac){drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +5
-0+struct net_device *ndev =dev_get_drvdata (dwmac->dev); + +if (!ndev || !netif_running (ndev)) +return 0 ; +return clk_prepare_enable (dwmac->clk_ethstp);
The commit message might be missing some explanation. The suspend method enables the clock, not disables it.
Andrew
Quoted 19 lines · Marek Vasut
If an interface is down, the ETHnSTP clock are not running. Suspending such an interface will attempt to stop already stopped ETHnSTP clock, and produce a warning in the kernel log about this.
STM32MP25xx that is booted from NFS root via its first ethernet MAC (also the consumer of
ck_ker_eth1stp) and with its second ethernet MAC downed produces the following warnings during suspend resume cycle. This can be provoked even usingpm_test:"
$ echo devices > /sys/power/pm_test $ echo mem > /sys/power/state ... ck_ker_eth2stp already disabled ... ck_ker_eth2stp already unprepared ... "
Quoted 2 lines
Fix this by not manipulating with the clock during suspend resume of interfaces which are downed.
I don't think this is the correct fix. Looking back at my commits:b51f34bc85e3 net: stmmac: platform: legacy hooks for suspend()/resume() methods 07bbbfe7addf net: stmmac: add suspend()/resume() platform ops
I think I changed the behaviour of the suspend/resume callbacks unintentionally. Sorry, I don't have time to complete this email (meeting.)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 23 lines · Russell King (Oracle)
Quoted 19 lines · Marek Vasut
If an interface is down, the ETHnSTP clock are not running. Suspending such an interface will attempt to stop already stopped ETHnSTP clock, and produce a warning in the kernel log about this.
STM32MP25xx that is booted from NFS root via its first ethernet MAC (also the consumer of
ck_ker_eth1stp) and with its second ethernet MAC downed produces the following warnings during suspend resume cycle. This can be provoked even usingpm_test:"
$ echo devices > /sys/power/pm_test $ echo mem > /sys/power/state ... ck_ker_eth2stp already disabled ... ck_ker_eth2stp already unprepared ... "Quoted 2 lines
Fix this by not manipulating with the clock during suspend resume of interfaces which are downed.
Quoted 7 lines
I don't think this is the correct fix. Looking back at my commits:
b51f34bc85e3net: stmmac: platform: legacy hooks for suspend()/resume() methods07bbbfe7addfnet: stmmac: add suspend()/resume() platform opsI think I changed the behaviour of the suspend/resume callbacks unintentionally. Sorry, I don't have time to complete this email (meeting.)
I think I'm going to start over, trying to figure out what happened.
c7308b2f3d0d net: stmmac: stm32: convert to suspend()/resume() methods
Did the conversion, and it always called stm32_dwmac_clk_disable() and where it exists, dwmac->ops->suspend() on suspend, provided stmmac_suspend() returns zero (which it will do, even if the interface is down. On resume, it always calls dwmac->ops->resume() and stm32_dwmac_init() before calling stmmac_resume().
The conversion added hooks into ny new ->suspend() and ->resume() methods to handle the stm32_dwmac_clk_disable(), dwmac->ops->suspend(), dwmac->ops->resume() and stm32_dwmac_init() steps.
However, in 07bbbfe7addf I failed to realise that, in order to keep things compatible with how stuff works, we need to call priv->plat->suspend() even if the interface is down. This is where the bug is, not in your glue driver.
Please try this:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -8066,7 +8066,7 @@ int stmmac_suspend(struct device *dev)u32 chan;if (!ndev || !netif_running (ndev)) -return 0 ; + goto suspend_bsp;mutex_lock (&priv->lock);
@@ -8106,6 +8106,7 @@ int stmmac_suspend(struct device *dev)if (stmmac_fpe_supported (priv))ethtool_mmsv_stop (&priv->fpe_cfg.mmsv); +suspend_bsp:if (priv->plat->suspend)return priv->plat->suspend (dev, priv->plat->bsp_priv);
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 67 lines · Russell King (Oracle)
Quoted 23 lines · Russell King (Oracle)
Quoted 19 lines · Marek Vasut
If an interface is down, the ETHnSTP clock are not running. Suspending such an interface will attempt to stop already stopped ETHnSTP clock, and produce a warning in the kernel log about this.
STM32MP25xx that is booted from NFS root via its first ethernet MAC (also the consumer of
ck_ker_eth1stp) and with its second ethernet MAC downed produces the following warnings during suspend resume cycle. This can be provoked even usingpm_test:"
$ echo devices > /sys/power/pm_test $ echo mem > /sys/power/state ... ck_ker_eth2stp already disabled ... ck_ker_eth2stp already unprepared ... "Quoted 2 lines
Fix this by not manipulating with the clock during suspend resume of interfaces which are downed.
Quoted 7 lines
I don't think this is the correct fix. Looking back at my commits:
b51f34bc85e3net: stmmac: platform: legacy hooks for suspend()/resume() methods07bbbfe7addfnet: stmmac: add suspend()/resume() platform opsI think I changed the behaviour of the suspend/resume callbacks unintentionally. Sorry, I don't have time to complete this email (meeting.)
I think I'm going to start over, trying to figure out what happened.
c7308b2f3d0dnet: stmmac: stm32: convert to suspend()/resume() methodsDid the conversion, and it always called
stm32_dwmac_clk_disable()and where it exists,dwmac->ops->suspend()on suspend, providedstmmac_suspend()returns zero (which it will do, even if the interface is down. On resume, it always callsdwmac->ops->resume()andstm32_dwmac_init()before callingstmmac_resume().The conversion added hooks into ny new ->suspend() and ->resume() methods to handle the
stm32_dwmac_clk_disable(),dwmac->ops->suspend(),dwmac->ops->resume()andstm32_dwmac_init()steps.However, in
07bbbfe7addfI failed to realise that, in order to keep things compatible with how stuff works, we need to callpriv->plat->suspend()even if the interface is down. This is where the bug is, not in your glue driver.Please try this:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -8066,7 +8066,7 @@ int stmmac_suspend(struct device *dev)u32 chan;if (!ndev || !netif_running (ndev)) -return 0 ; + goto suspend_bsp;mutex_lock (&priv->lock);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_suspend(struct device *dev) · line 8112
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0@@ -8106,6 +8106,7 @@ int stmmac_suspend(struct device *dev)if (stmmac_fpe_supported (priv))ethtool_mmsv_stop (&priv->fpe_cfg.mmsv); +suspend_bsp:if (priv->plat->suspend)return priv->plat->suspend (dev, priv->plat->bsp_priv);
This works too, thank you.
Will you send this fix ?
Quoted 40 lines · Marek Vasut
Quoted 32 lines · Russell King (Oracle)
I think I'm going to start over, trying to figure out what happened.
c7308b2f3d0dnet: stmmac: stm32: convert to suspend()/resume() methodsDid the conversion, and it always called
stm32_dwmac_clk_disable()and where it exists,dwmac->ops->suspend()on suspend, providedstmmac_suspend()returns zero (which it will do, even if the interface is down. On resume, it always callsdwmac->ops->resume()andstm32_dwmac_init()before callingstmmac_resume().The conversion added hooks into ny new ->suspend() and ->resume() methods to handle the
stm32_dwmac_clk_disable(),dwmac->ops->suspend(),dwmac->ops->resume()andstm32_dwmac_init()steps.However, in
07bbbfe7addfI failed to realise that, in order to keep things compatible with how stuff works, we need to callpriv->plat->suspend()even if the interface is down. This is where the bug is, not in your glue driver.Please try this:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -8066,7 +8066,7 @@ int stmmac_suspend(struct device *dev)u32 chan;if (!ndev || !netif_running (ndev)) -return 0 ; + goto suspend_bsp;mutex_lock (&priv->lock);drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_suspend(struct device *dev) · line 8110
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0@@ -8106,6 +8106,7 @@ int stmmac_suspend(struct device *dev)if (stmmac_fpe_supported (priv))ethtool_mmsv_stop (&priv->fpe_cfg.mmsv); +suspend_bsp:if (priv->plat->suspend)return priv->plat->suspend (dev, priv->plat->bsp_priv);This works too, thank you.
Quoted 1 line
Will you send this fix ?
Sorry, I appear to have dropped this patch on the floor, and just tripped over it. I'm just build testing it and will send it later today.
This problem affects every user of the platform ->suspend/resume() stuff, so is not just a stm32 issue.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 41 lines · Russell King (Oracle)
Quoted 40 lines · Marek Vasut
Quoted 32 lines · Russell King (Oracle)
I think I'm going to start over, trying to figure out what happened.
c7308b2f3d0dnet: stmmac: stm32: convert to suspend()/resume() methodsDid the conversion, and it always called
stm32_dwmac_clk_disable()and where it exists,dwmac->ops->suspend()on suspend, providedstmmac_suspend()returns zero (which it will do, even if the interface is down. On resume, it always callsdwmac->ops->resume()andstm32_dwmac_init()before callingstmmac_resume().The conversion added hooks into ny new ->suspend() and ->resume() methods to handle the
stm32_dwmac_clk_disable(),dwmac->ops->suspend(),dwmac->ops->resume()andstm32_dwmac_init()steps.However, in
07bbbfe7addfI failed to realise that, in order to keep things compatible with how stuff works, we need to callpriv->plat->suspend()even if the interface is down. This is where the bug is, not in your glue driver.Please try this:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -8066,7 +8066,7 @@ int stmmac_suspend(struct device *dev)u32 chan;if (!ndev || !netif_running (ndev)) -return 0 ; + goto suspend_bsp;mutex_lock (&priv->lock);drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_suspend(struct device *dev) · line 8110
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0@@ -8106,6 +8106,7 @@ int stmmac_suspend(struct device *dev)if (stmmac_fpe_supported (priv))ethtool_mmsv_stop (&priv->fpe_cfg.mmsv); +suspend_bsp:if (priv->plat->suspend)return priv->plat->suspend (dev, priv->plat->bsp_priv);This works too, thank you.
Quoted 8 lines
Quoted 1 line
Will you send this fix ?
Sorry, I appear to have dropped this patch on the floor, and just tripped over it. I'm just build testing it and will send it later today.
This problem affects every user of the platform ->suspend/resume() stuff, so is not just a stm32 issue.
ACK, thank you.