net: bcmgenet: fix aborted suspend
Subsystems (3)
Doug Berger
maintainercover net: bcmgenet: fix aborted suspend
It is not enough to return an error code from the driver suspend routine. The driver must also restore the device functionality.
This commit corrects the issue introduced by commit 0db55093b566 ("net: bcmgenet: return correct value 'ret' from bcmgenet_power_down") by calling the driver resume function if the suspend function returns an error.
Doug Berger (2):
net: bcmgenet: code movement
net: bcmgenet: abort suspend on error
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 63 +++++++++++----------- drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 6 +++ 2 files changed, 39 insertions(+), 30 deletions(-)
Signature · 1 line
2.7.4
Doug Berger
maintainerPATCH 1/2 net: bcmgenet: code movement
This commit switches the order of bcmgenet_suspend and bcmgenet_resume in the file to prevent the need for a forward declaration in the next commit and to make the review of that commit easier.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 60 +++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +30 -30
@@ -3612,36 +3612,6 @@ static int bcmgenet_remove(struct platform_device *pdev) }#ifdef CONFIG_PM_SLEEP -static int bcmgenet_suspend (struct device *d) -{ -struct net_device *dev =dev_get_drvdata (d); -struct bcmgenet_priv *priv =netdev_priv (dev); -int ret =0 ; - -if (!netif_running (dev)) -return 0 ; - -netif_device_detach (dev); - -bcmgenet_netif_stop (dev); - -if (!device_may_wakeup (d)) -phy_suspend (dev->phydev); - -/* Prepare the device for Wake-on-LAN and switch to the slow clock */ -if (device_may_wakeup (d) && priv->wolopts) { - ret =bcmgenet_power_down (priv,GENET_POWER_WOL_MAGIC ); -clk_prepare_enable (priv->clk_wol); - }else if (priv->internal_phy) { - ret =bcmgenet_power_down (priv,GENET_POWER_PASSIVE ); - } - -/* Turn off the clocks */ -clk_disable_unprepare (priv->clk); - -return ret; -} -static int bcmgenet_resume (struct device *d) {struct net_device *dev =dev_get_drvdata (d);
@@ -3719,6 +3689,36 @@ static int bcmgenet_resume(struct device *d)clk_disable_unprepare (priv->clk);return ret; } + +static int bcmgenet_suspend (struct device *d) +{ +struct net_device *dev =dev_get_drvdata (d); +struct bcmgenet_priv *priv =netdev_priv (dev); +int ret =0 ; + +if (!netif_running (dev)) +return 0 ; + +netif_device_detach (dev); + +bcmgenet_netif_stop (dev); + +if (!device_may_wakeup (d)) +phy_suspend (dev->phydev); + +/* Prepare the device for Wake-on-LAN and switch to the slow clock */ +if (device_may_wakeup (d) && priv->wolopts) { + ret =bcmgenet_power_down (priv,GENET_POWER_WOL_MAGIC ); +clk_prepare_enable (priv->clk_wol); + }else if (priv->internal_phy) { + ret =bcmgenet_power_down (priv,GENET_POWER_PASSIVE ); + } + +/* Turn off the clocks */ +clk_disable_unprepare (priv->clk); + +return ret; +}#endif /* CONFIG_PM_SLEEP */ static SIMPLE_DEV_PM_OPS(bcmgenet_pm_ops, bcmgenet_suspend, bcmgenet_resume);
Signature · 1 line
2.7.4
Re: [PATCH net-next 1/2] net: bcmgenet: code movement
Quoted 5 lines · Doug Berger
This commit switches the order of
bcmgenet_suspendandbcmgenet_resumein the file to prevent the need for a forward declaration in the next commit and to make the review of that commit easier.Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
Doug Berger
maintainerPATCH 2/2 net: bcmgenet: abort suspend on error
In reply to Doug BergerIf an error occurs during suspension of the driver the driver should restore the hardware configuration and return an error to force the system to resume.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +++ drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 6 ++++++ 2 files changed, 9 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +3 -0
@@ -3717,6 +3717,9 @@ static int bcmgenet_suspend(struct device *d)/* Turn off the clocks */ clk_disable_unprepare (priv->clk); +if (ret) +bcmgenet_resume (d); + return ret; }#endif /* CONFIG_PM_SLEEP */
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +6 -0
@@ -186,9 +186,15 @@ void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, } reg =bcmgenet_umac_readl (priv,UMAC_MPD_CTRL ); +if (!(reg &MPD_EN )) +return ;/* already powered up so skip the rest */ reg &= ~MPD_EN ;bcmgenet_umac_writel (priv, reg,UMAC_MPD_CTRL ); + reg =bcmgenet_hfb_reg_readl (priv,HFB_CTRL ); + reg &= ~(RBUF_HFB_EN |RBUF_ACPI_EN ); +bcmgenet_hfb_reg_writel (priv, reg,HFB_CTRL ); +/* Disable CRC Forward */ reg =bcmgenet_umac_readl (priv,UMAC_CMD ); reg &= ~CMD_CRC_FWD ;
Signature · 1 line
2.7.4
Re: [PATCH net-next 2/2] net: bcmgenet: abort suspend on error
Quoted 6 lines · Doug Berger
If an error occurs during suspension of the driver the driver should restore the hardware configuration and return an error to force the system to resume.
Fixes 0db55093b566 ("net: bcmgenet: return correct value 'ret' from bcmgenet_power_down")Signed-off-by Doug Berger <[email protected]>
Signature · 1 line
Florian
David Miller
maintainerFrom: Doug Berger <[email protected]>
Date: Fri, 16 Nov 2018 18:00:20 -0800
Quoted 7 lines
It is not enough to return an error code from the driver suspend routine. The driver must also restore the device functionality.
This commit corrects the issue introduced by commit
0db55093b566("net: bcmgenet: return correct value 'ret' frombcmgenet_power_down") by calling the driver resume function if the suspend function returns an error.
Series applied.