All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: dwmac-rk: Add runtime PM support
@ 2021-10-08 10:24 ` hmz007
  0 siblings, 0 replies; 4+ messages in thread
From: hmz007 @ 2021-10-08 10:24 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, p.zabel, lgirdwood, broonie
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, hmz007

Commit 2d26f6e39afb ("fix unbalanced pm_runtime_enable warnings")
also enables runtime PM, which affects rk3399 with power-domain.

After an off-on switch of power-domain, the GMAC doesn't work properly,
calling rk_gmac_powerup at runtime resume fixes this issue.

Fixes: 2d26f6e39afb ("net: stmmac: dwmac-rk: fix unbalanced pm_runtime_enable warnings")
Signed-off-by: hmz007 <hmz007@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index ed817011a94a..a9eb98691a66 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/pm_runtime.h>

 #include "stmmac_platform.h"

@@ -1626,7 +1627,8 @@ static int rk_gmac_remove(struct platform_device *pdev)
 	struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
 	int ret = stmmac_dvr_remove(&pdev->dev);

-	rk_gmac_powerdown(bsp_priv);
+	if (!pm_runtime_status_suspended(&pdev->dev))
+		rk_gmac_powerdown(bsp_priv);

 	return ret;
 }
@@ -1638,7 +1640,7 @@ static int rk_gmac_suspend(struct device *dev)
 	int ret = stmmac_suspend(dev);

 	/* Keep the PHY up if we use Wake-on-Lan. */
-	if (!device_may_wakeup(dev)) {
+	if (pm_runtime_active(dev) && !device_may_wakeup(dev)) {
 		rk_gmac_powerdown(bsp_priv);
 		bsp_priv->suspended = true;
 	}
@@ -1660,7 +1662,24 @@ static int rk_gmac_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */

-static SIMPLE_DEV_PM_OPS(rk_gmac_pm_ops, rk_gmac_suspend, rk_gmac_resume);
+#ifdef CONFIG_PM
+static int rk_gmac_runtime_suspend(struct device *dev)
+{
+	rk_gmac_powerdown(get_stmmac_bsp_priv(dev));
+	return 0;
+}
+
+static int rk_gmac_runtime_resume(struct device *dev)
+{
+	rk_gmac_powerup(get_stmmac_bsp_priv(dev));
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops __maybe_unused rk_gmac_pm_ops = {
+    SET_SYSTEM_SLEEP_PM_OPS(rk_gmac_suspend, rk_gmac_resume)
+    SET_RUNTIME_PM_OPS(rk_gmac_runtime_suspend, rk_gmac_runtime_resume, NULL)
+};

 static const struct of_device_id rk_gmac_dwmac_match[] = {
 	{ .compatible = "rockchip,px30-gmac",	.data = &px30_ops   },
--
2.33.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] net: stmmac: dwmac-rk: Add runtime PM support
@ 2021-10-08 10:24 ` hmz007
  0 siblings, 0 replies; 4+ messages in thread
From: hmz007 @ 2021-10-08 10:24 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, p.zabel, lgirdwood, broonie
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, hmz007

Commit 2d26f6e39afb ("fix unbalanced pm_runtime_enable warnings")
also enables runtime PM, which affects rk3399 with power-domain.

After an off-on switch of power-domain, the GMAC doesn't work properly,
calling rk_gmac_powerup at runtime resume fixes this issue.

Fixes: 2d26f6e39afb ("net: stmmac: dwmac-rk: fix unbalanced pm_runtime_enable warnings")
Signed-off-by: hmz007 <hmz007@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index ed817011a94a..a9eb98691a66 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/pm_runtime.h>

 #include "stmmac_platform.h"

@@ -1626,7 +1627,8 @@ static int rk_gmac_remove(struct platform_device *pdev)
 	struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
 	int ret = stmmac_dvr_remove(&pdev->dev);

-	rk_gmac_powerdown(bsp_priv);
+	if (!pm_runtime_status_suspended(&pdev->dev))
+		rk_gmac_powerdown(bsp_priv);

 	return ret;
 }
@@ -1638,7 +1640,7 @@ static int rk_gmac_suspend(struct device *dev)
 	int ret = stmmac_suspend(dev);

 	/* Keep the PHY up if we use Wake-on-Lan. */
-	if (!device_may_wakeup(dev)) {
+	if (pm_runtime_active(dev) && !device_may_wakeup(dev)) {
 		rk_gmac_powerdown(bsp_priv);
 		bsp_priv->suspended = true;
 	}
@@ -1660,7 +1662,24 @@ static int rk_gmac_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */

-static SIMPLE_DEV_PM_OPS(rk_gmac_pm_ops, rk_gmac_suspend, rk_gmac_resume);
+#ifdef CONFIG_PM
+static int rk_gmac_runtime_suspend(struct device *dev)
+{
+	rk_gmac_powerdown(get_stmmac_bsp_priv(dev));
+	return 0;
+}
+
+static int rk_gmac_runtime_resume(struct device *dev)
+{
+	rk_gmac_powerup(get_stmmac_bsp_priv(dev));
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops __maybe_unused rk_gmac_pm_ops = {
+    SET_SYSTEM_SLEEP_PM_OPS(rk_gmac_suspend, rk_gmac_resume)
+    SET_RUNTIME_PM_OPS(rk_gmac_runtime_suspend, rk_gmac_runtime_resume, NULL)
+};

 static const struct of_device_id rk_gmac_dwmac_match[] = {
 	{ .compatible = "rockchip,px30-gmac",	.data = &px30_ops   },
--
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: stmmac: dwmac-rk: Add runtime PM support
  2021-10-08 10:24 ` hmz007
@ 2021-10-08 14:06   ` David Miller
  -1 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2021-10-08 14:06 UTC (permalink / raw)
  To: hmz007
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, kuba,
	mcoquelin.stm32, p.zabel, lgirdwood, broonie, netdev,
	linux-stm32, linux-arm-kernel, linux-kernel

From: hmz007 <hmz007@gmail.com>
Date: Fri,  8 Oct 2021 18:24:10 +0800

> Commit 2d26f6e39afb ("fix unbalanced pm_runtime_enable warnings")
> also enables runtime PM, which affects rk3399 with power-domain.
> 
> After an off-on switch of power-domain, the GMAC doesn't work properly,
> calling rk_gmac_powerup at runtime resume fixes this issue.
> 
> Fixes: 2d26f6e39afb ("net: stmmac: dwmac-rk: fix unbalanced pm_runtime_enable warnings")
> Signed-off-by: hmz007 <hmz007@gmail.com>

This patch does not apply to any of the networking trees.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: stmmac: dwmac-rk: Add runtime PM support
@ 2021-10-08 14:06   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2021-10-08 14:06 UTC (permalink / raw)
  To: hmz007
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, kuba,
	mcoquelin.stm32, p.zabel, lgirdwood, broonie, netdev,
	linux-stm32, linux-arm-kernel, linux-kernel

From: hmz007 <hmz007@gmail.com>
Date: Fri,  8 Oct 2021 18:24:10 +0800

> Commit 2d26f6e39afb ("fix unbalanced pm_runtime_enable warnings")
> also enables runtime PM, which affects rk3399 with power-domain.
> 
> After an off-on switch of power-domain, the GMAC doesn't work properly,
> calling rk_gmac_powerup at runtime resume fixes this issue.
> 
> Fixes: 2d26f6e39afb ("net: stmmac: dwmac-rk: fix unbalanced pm_runtime_enable warnings")
> Signed-off-by: hmz007 <hmz007@gmail.com>

This patch does not apply to any of the networking trees.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-08 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 10:24 [PATCH] net: stmmac: dwmac-rk: Add runtime PM support hmz007
2021-10-08 10:24 ` hmz007
2021-10-08 14:06 ` David Miller
2021-10-08 14:06   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.