* [PATCH net-next 1/3] net: ethernet: ave: Add suspend/resume support
2018-11-29 8:06 [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver Kunihiko Hayashi
@ 2018-11-29 8:06 ` Kunihiko Hayashi
2018-11-29 8:06 ` [PATCH net-next 2/3] net: ethernet: ave: Set initial wol state to disabled Kunihiko Hayashi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Kunihiko Hayashi @ 2018-11-29 8:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Kunihiko Hayashi
This patch introduces suspend and resume functions to ave driver.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/net/ethernet/socionext/sni_ave.c | 44 ++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c
index 6732f5c..64115b1 100644
--- a/drivers/net/ethernet/socionext/sni_ave.c
+++ b/drivers/net/ethernet/socionext/sni_ave.c
@@ -1734,6 +1734,49 @@ static int ave_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int ave_suspend(struct device *dev)
+{
+ struct net_device *ndev = dev_get_drvdata(dev);
+ struct ave_private *priv = netdev_priv(ndev);
+ int ret = 0;
+
+ if (netif_running(ndev)) {
+ ret = ave_stop(ndev);
+ netif_device_detach(ndev);
+ }
+
+ return ret;
+}
+
+static int ave_resume(struct device *dev)
+{
+ struct net_device *ndev = dev_get_drvdata(dev);
+ struct ave_private *priv = netdev_priv(ndev);
+ int ret = 0;
+
+ ave_global_reset(ndev);
+
+ if (ndev->phydev) {
+ ret = phy_resume(ndev->phydev);
+ if (ret)
+ return ret;
+ }
+
+ if (netif_running(ndev)) {
+ ret = ave_open(ndev);
+ netif_device_attach(ndev);
+ }
+
+ return ret;
+}
+
+static SIMPLE_DEV_PM_OPS(ave_pm_ops, ave_suspend, ave_resume);
+#define AVE_PM_OPS (&ave_pm_ops)
+#else
+#define AVE_PM_OPS NULL
+#endif
+
static int ave_pro4_get_pinmode(struct ave_private *priv,
phy_interface_t phy_mode, u32 arg)
{
@@ -1908,6 +1951,7 @@ static struct platform_driver ave_driver = {
.remove = ave_remove,
.driver = {
.name = "ave",
+ .pm = AVE_PM_OPS,
.of_match_table = of_ave_match,
},
};
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/3] net: ethernet: ave: Set initial wol state to disabled
2018-11-29 8:06 [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver Kunihiko Hayashi
2018-11-29 8:06 ` [PATCH net-next 1/3] net: ethernet: ave: Add suspend/resume support Kunihiko Hayashi
@ 2018-11-29 8:06 ` Kunihiko Hayashi
2018-11-29 8:06 ` [PATCH net-next 3/3] net: ethernet: ave: Preserve wol state in suspend/resume sequence Kunihiko Hayashi
2018-11-29 18:35 ` [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Kunihiko Hayashi @ 2018-11-29 8:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Kunihiko Hayashi
If wol state of phy hardware is enabled after reset, phy_ethtool_get_wol()
returns that wol.wolopts is true.
However, since net_device.wol_enabled is zero and this doesn't apply wol
state until calling ethtool_set_wol(), so mdio_bus_phy_may_suspend()
returns true, that is, it's in a state where phy can suspend even though
wol state is enabled.
In this inconsistency, phy_suspend() returns -EBUSY, and at last,
suspend sequence fails with the following message:
dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x58 returns -16
PM: Device 65000000.ethernet-ffffffff:01 failed to suspend: error -16
PM: Some devices failed to suspend, or early wake event detected
In order to fix the above issue, this patch forces to set initial wol state
to disabled as default.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/net/ethernet/socionext/sni_ave.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c
index 64115b1..ac96fb9 100644
--- a/drivers/net/ethernet/socionext/sni_ave.c
+++ b/drivers/net/ethernet/socionext/sni_ave.c
@@ -1208,9 +1208,13 @@ static int ave_init(struct net_device *ndev)
priv->phydev = phydev;
- phy_ethtool_get_wol(phydev, &wol);
+ ave_ethtool_get_wol(ndev, &wol);
device_set_wakeup_capable(&ndev->dev, !!wol.supported);
+ /* set wol initial state disabled */
+ wol.wolopts = 0;
+ ave_ethtool_set_wol(ndev, &wol);
+
if (!phy_interface_is_rgmii(phydev))
phy_set_max_speed(phydev, SPEED_100);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 3/3] net: ethernet: ave: Preserve wol state in suspend/resume sequence
2018-11-29 8:06 [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver Kunihiko Hayashi
2018-11-29 8:06 ` [PATCH net-next 1/3] net: ethernet: ave: Add suspend/resume support Kunihiko Hayashi
2018-11-29 8:06 ` [PATCH net-next 2/3] net: ethernet: ave: Set initial wol state to disabled Kunihiko Hayashi
@ 2018-11-29 8:06 ` Kunihiko Hayashi
2018-11-29 18:35 ` [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Kunihiko Hayashi @ 2018-11-29 8:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Kunihiko Hayashi
Since the wol state forces to be initialized after reset, the state should
be preserved in suspend/resume sequence.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/net/ethernet/socionext/sni_ave.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c
index ac96fb9..8c1e120 100644
--- a/drivers/net/ethernet/socionext/sni_ave.c
+++ b/drivers/net/ethernet/socionext/sni_ave.c
@@ -261,6 +261,7 @@ struct ave_private {
struct regmap *regmap;
unsigned int pinmode_mask;
unsigned int pinmode_val;
+ u32 wolopts;
/* stats */
struct ave_stats stats_rx;
@@ -1741,6 +1742,7 @@ static int ave_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP
static int ave_suspend(struct device *dev)
{
+ struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
struct net_device *ndev = dev_get_drvdata(dev);
struct ave_private *priv = netdev_priv(ndev);
int ret = 0;
@@ -1750,17 +1752,25 @@ static int ave_suspend(struct device *dev)
netif_device_detach(ndev);
}
+ ave_ethtool_get_wol(ndev, &wol);
+ priv->wolopts = wol.wolopts;
+
return ret;
}
static int ave_resume(struct device *dev)
{
+ struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
struct net_device *ndev = dev_get_drvdata(dev);
struct ave_private *priv = netdev_priv(ndev);
int ret = 0;
ave_global_reset(ndev);
+ ave_ethtool_get_wol(ndev, &wol);
+ wol.wolopts = priv->wolopts;
+ ave_ethtool_set_wol(ndev, &wol);
+
if (ndev->phydev) {
ret = phy_resume(ndev->phydev);
if (ret)
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver
2018-11-29 8:06 [PATCH net-next 0/3] Add suspend/resume support for AVE ethernet driver Kunihiko Hayashi
` (2 preceding siblings ...)
2018-11-29 8:06 ` [PATCH net-next 3/3] net: ethernet: ave: Preserve wol state in suspend/resume sequence Kunihiko Hayashi
@ 2018-11-29 18:35 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-11-29 18:35 UTC (permalink / raw)
To: hayashi.kunihiko; +Cc: netdev, linux-kernel
From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Date: Thu, 29 Nov 2018 17:06:30 +0900
> This series adds support for suspend/resume to AVE ethernet driver.
>
> And to avoid the error that wol state of phy hardware is enabled by default,
> this sets initial wol state to disabled and add preservation the state in
> suspend/resume sequence.
Series applied.
^ permalink raw reply [flat|nested] 5+ messages in thread