Skip to contentSkip to conversation

sh_eth: PM-related cleanups

PATCH Applied Geert Uytterhoeven 5 participants 15 messages Sep 4, 2025 – Sep 29, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover sh_eth: PM-related cleanups

Hi all,

This patch series contains various cleanups related to power management for the Renesas SH Ethernet driver, as used on Renesas SH, ARM32, and ARM64 platforms.

This has been tested on various SoCs (R-Mobile A1, RZ/A1H, RZ/A2M, R-Car H1, R-Car M2-W).

Thanks for your comments!

Geert Uytterhoeven (3):
net: sh_eth: Remove dummy Runtime PM callbacks
net: sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
net: sh_eth: Use async pm_runtime_put()

 drivers/net/ethernet/renesas/sh_eth.c | 30 ++++-----------------------
 1 file changed, 4 insertions(+), 26 deletions(-)
Signature · 12 lines
2.43.0

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH 1/3 sh_eth: Remove dummy Runtime PM callbacks

Since commit 63d00be69348fda4 ("PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks"), unassigned .runtime_{suspend,resume}() callbacks are treated the same as dummy callbacks that just return zero.

---
 drivers/net/ethernet/renesas/sh_eth.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +0 -13
index 5fc8027c92c7c95b..0516db9dc946fcdb 100644
@@ -3529,21 +3529,8 @@ static int sh_eth_resume(struct device *dev)
 }
 #endif
 
-static int sh_eth_runtime_nop(struct device *dev)
-{
-	/* Runtime PM callback shared between ->runtime_suspend()
-	 * and ->runtime_resume(). Simply returns success.
-	 *
-	 * This driver re-initializes all registers after
-	 * pm_runtime_get_sync() anyway so there is no need
-	 * to save and restore registers here.
-	 */
-	return 0;
-}
-
 static const struct dev_pm_ops sh_eth_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(sh_eth_suspend, sh_eth_resume)
-	SET_RUNTIME_PM_OPS(sh_eth_runtime_nop, sh_eth_runtime_nop, NULL)
 };
 #define SH_ETH_PM_OPS (&sh_eth_dev_pm_ops)
 #else
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH net-next 1/3] sh_eth: Remove dummy Runtime PM callbacks

Quoted 6 lines · Geert Uytterhoeven

Since commit 63d00be69348fda4 ("PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks"), unassigned .runtime_{suspend,resume}() callbacks are treated the same as dummy callbacks that just return zero.

Andrew

#3 lore raw

PATCH 2/3 sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

In reply to Geert Uytterhoeven

Convert the Renesas SuperH Ethernet driver from an open-coded dev_pm_ops structure to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr(). This lets us drop the checks for CONFIG_PM and CONFIG_PM_SLEEP without impacting code size, while increasing build coverage.

---
 drivers/net/ethernet/renesas/sh_eth.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +2 -11
index 0516db9dc946fcdb..f16a350736e1aa04 100644
@@ -3443,8 +3443,6 @@ static void sh_eth_drv_remove(struct platform_device *pdev)
 	free_netdev(ndev);
 }
 
-#ifdef CONFIG_PM
-#ifdef CONFIG_PM_SLEEP
 static int sh_eth_wol_setup(struct net_device *ndev)
 {
 	struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -3527,15 +3525,8 @@ static int sh_eth_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops sh_eth_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sh_eth_suspend, sh_eth_resume)
-};
-#define SH_ETH_PM_OPS (&sh_eth_dev_pm_ops)
-#else
-#define SH_ETH_PM_OPS NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(sh_eth_dev_pm_ops, sh_eth_suspend, sh_eth_resume);
 
 static const struct platform_device_id sh_eth_id_table[] = {
 	{ "sh7619-ether", (kernel_ulong_t)&sh7619_data },
@@ -3555,7 +3546,7 @@ static struct platform_driver sh_eth_driver = {
 	.id_table = sh_eth_id_table,
 	.driver = {
 		   .name = CARDNAME,
-		   .pm = SH_ETH_PM_OPS,
+		   .pm = pm_sleep_ptr(&sh_eth_dev_pm_ops),
 		   .of_match_table = of_match_ptr(sh_eth_match_table),
 	},
 };
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Quoted 15 lines · Geert Uytterhoeven

Convert the Renesas SuperH Ethernet driver from an open-coded dev_pm_ops structure to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr(). This lets us drop the checks for CONFIG_PM and CONFIG_PM_SLEEP without impacting code size, while increasing build coverage.

---
 drivers/net/ethernet/renesas/sh_eth.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +0 -0
index 0516db9dc946fcdb..f16a350736e1aa04 100644

drivers/net/ethernet/renesas/sh_eth.c static void sh_eth_drv_remove(struct platform_device *pdev) · line 3446

Quoted 6 lines
drivers/net/ethernet/renesas/sh_eth.c +0 -2
@@ -3443,8 +3443,6 @@ static void sh_eth_drv_remove(struct platform_device *pdev)
 	free_netdev(ndev);
 }
 
-#ifdef CONFIG_PM
-#ifdef CONFIG_PM_SLEEP
 static int sh_eth_wol_setup(struct net_device *ndev)

Humm, sh_eth_wol_setup() went from conditional to always available.

Can WoL work without PM? Is the current get_wol() and set_wol() broken?

Maybe you can take a look at this, do some testing?

It is however not strictly related to this patch, so:

Andrew

#5 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Hi Andrew,

Thanks for your comments!

Quoted 19 lines · Andrew Lunn
Quoted 18 lines · Geert Uytterhoeven

Convert the Renesas SuperH Ethernet driver from an open-coded dev_pm_ops structure to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr(). This lets us drop the checks for CONFIG_PM and CONFIG_PM_SLEEP without impacting code size, while increasing build coverage.

---
 drivers/net/ethernet/renesas/sh_eth.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +0 -0
index 0516db9dc946fcdb..f16a350736e1aa04 100644
@@ -3443,8 +3443,6 @@ static void sh_eth_drv_remove(struct platform_device *pdev)
      free_netdev(ndev);
 }
 
Quoted 5 lines

drivers/net/ethernet/renesas/sh_eth.c static void sh_eth_drv_remove(struct platform_device *pdev) · line 3446

Quoted 3 lines
drivers/net/ethernet/renesas/sh_eth.c +0 -2
-#ifdef CONFIG_PM
-#ifdef CONFIG_PM_SLEEP
 static int sh_eth_wol_setup(struct net_device *ndev)

Humm, sh_eth_wol_setup() went from conditional to always available.

Its sole caller is sh_eth_suspend(). If the compiler optimizes away the latter, it should optimize away the former, too (verified with an m68k allmodconfig build).

Quoted 4 lines

Can WoL work without PM? Is the current get_wol() and set_wol() broken?

Maybe you can take a look at this, do some testing?

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Quoted 3 lines

It is however not strictly related to this patch, so:

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Quoted 2 lines

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Yet get_wol will return WoL can be used, and set_wol will allow you to configure it. It seems like EOPNOTSUPP would be better.

Andrew

#7 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Quoted 5 lines · Andrew Lunn
Quoted 2 lines

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Yet get_wol will return WoL can be used, and set_wol will allow you to configure it. It seems like EOPNOTSUPP would be better.

Out of curiosity. Are you suggesting a compile time check/construct for CONFIG_PM_SLEEP be added in the driver itself, or in ethtool_set_wol() and ethtool_get_wol() in net/ethtool/ioctl.c to complement the

    if (!dev->ethtool_ops->get_wol || !dev->ethtool_ops->set_wol)
        return -EOPNOTSUPP;

checks already there? To always return EOPNOTSUPP if PM_SLEEP is not selected?

Quoted 2 lines

Andrew

Signature · 2 lines
Kind Regards,
Niklas Söderlund
#8 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Hi Niklas,

Quoted 11 lines · Niklas Söderlund
Quoted 5 lines · Andrew Lunn
Quoted 2 lines

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Yet get_wol will return WoL can be used, and set_wol will allow you to configure it. It seems like EOPNOTSUPP would be better.

Out of curiosity. Are you suggesting a compile time check/construct for CONFIG_PM_SLEEP be added in the driver itself, or in ethtool_set_wol() and ethtool_get_wol() in net/ethtool/ioctl.c to complement the

Quoted 5 lines
    if (!dev->ethtool_ops->get_wol || !dev->ethtool_ops->set_wol)
        return -EOPNOTSUPP;

checks already there? To always return EOPNOTSUPP if PM_SLEEP is not selected?

Iff we want to go that route, I'd vote for handling it in common code. Still, there is no guarantee that WoL will actually work, as on some systems it may depend on the firmware, too. E.g. on ARM systems with PSCI, the SoC may be powered down during s2ram, so there is no guarantee that any of the wake-up sources shown in /sys/kernel/debug/wakeup_sources can actually wake up the system. I tried having a mechanism to describe that in DT, but it was rejected.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Quoted 21 lines · Geert Uytterhoeven

Hi Niklas,

Quoted 11 lines · Niklas Söderlund
Quoted 5 lines · Andrew Lunn
Quoted 2 lines

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Yet get_wol will return WoL can be used, and set_wol will allow you to configure it. It seems like EOPNOTSUPP would be better.

Out of curiosity. Are you suggesting a compile time check/construct for CONFIG_PM_SLEEP be added in the driver itself, or in ethtool_set_wol() and ethtool_get_wol() in net/ethtool/ioctl.c to complement the

Quoted 5 lines
    if (!dev->ethtool_ops->get_wol || !dev->ethtool_ops->set_wol)
        return -EOPNOTSUPP;

checks already there? To always return EOPNOTSUPP if PM_SLEEP is not selected?

Quoted 7 lines

Iff we want to go that route, I'd vote for handling it in common code. Still, there is no guarantee that WoL will actually work, as on some systems it may depend on the firmware, too. E.g. on ARM systems with PSCI, the SoC may be powered down during s2ram, so there is no guarantee that any of the wake-up sources shown in /sys/kernel/debug/wakeup_sources can actually wake up the system. I tried having a mechanism to describe that in DT, but it was rejected.

WoL is a bit of a mess. Russell has done a little cleanup for when the PHY does WoL, not the MAC.

I don't think we can check for PM_SLEEP in the core. There are some PHYs which are powered by the standby voltage, so not effected by power off. And their WoL output is connected directly to the PMIC. So they have the ability to wake the system from off, not just suspend.

For the hardware you are dealing with, the MAC does WoL. You know it cannot work without PM_SLEEP, so i think it needs to be the MAC which returns EOPNOTSUP.

Andrew

#10 lore raw

Re: [PATCH net-next 2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

In reply to Geert Uytterhoeven
Quoted 19 lines · Geert Uytterhoeven
Quoted 11 lines · Niklas Söderlund
Quoted 5 lines · Andrew Lunn
Quoted 2 lines

You cannot enter system sleep without CONFIG_PM_SLEEP, so enabling WoL would be pointless.

Yet get_wol will return WoL can be used, and set_wol will allow you to configure it. It seems like EOPNOTSUPP would be better.

Out of curiosity. Are you suggesting a compile time check/construct for CONFIG_PM_SLEEP be added in the driver itself, or in ethtool_set_wol() and ethtool_get_wol() in net/ethtool/ioctl.c to complement the

Quoted 5 lines
    if (!dev->ethtool_ops->get_wol || !dev->ethtool_ops->set_wol)
        return -EOPNOTSUPP;

checks already there? To always return EOPNOTSUPP if PM_SLEEP is not selected?

Quoted 7 lines

Iff we want to go that route, I'd vote for handling it in common code. Still, there is no guarantee that WoL will actually work, as on some systems it may depend on the firmware, too. E.g. on ARM systems with PSCI, the SoC may be powered down during s2ram, so there is no guarantee that any of the wake-up sources shown in /sys/kernel/debug/wakeup_sources can actually wake up the system. I tried having a mechanism to describe that in DT, but it was rejected.

(oops, forgot to press "send" in an old draft)

Discovering commit af8dbf9c6aa8972f ("schemas: wakeup-source:
Possibility for system states") in dt-schema.git, there seems to be hope!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#11 lore raw

PATCH 3/3 sh_eth: Use async pm_runtime_put()

In reply to Geert Uytterhoeven

There is no stringent need to power down the device immediately after a register read, or after a failed open. Relax power down handling by replacing calls to synchronous pm_runtime_put_sync() by calls to asynchronous pm_runtime_put().

---
 drivers/net/ethernet/renesas/sh_eth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +2 -2
index f16a350736e1aa04..5a367c5523bb860f 100644
@@ -2233,7 +2233,7 @@ static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
 
 	pm_runtime_get_sync(&mdp->pdev->dev);
 	__sh_eth_get_regs(ndev, buf);
-	pm_runtime_put_sync(&mdp->pdev->dev);
+	pm_runtime_put(&mdp->pdev->dev);
 }
 
 static u32 sh_eth_get_msglevel(struct net_device *ndev)
@@ -2447,7 +2447,7 @@ static int sh_eth_open(struct net_device *ndev)
 	free_irq(ndev->irq, ndev);
 out_napi_off:
 	napi_disable(&mdp->napi);
-	pm_runtime_put_sync(&mdp->pdev->dev);
+	pm_runtime_put(&mdp->pdev->dev);
 	return ret;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 3/3
#12 lore raw

Re: [PATCH net-next 3/3] sh_eth: Use async pm_runtime_put()

Quoted 6 lines · Geert Uytterhoeven

There is no stringent need to power down the device immediately after a register read, or after a failed open. Relax power down handling by replacing calls to synchronous pm_runtime_put_sync() by calls to asynchronous pm_runtime_put().

Andrew

maintainer Reviewed-by Tested-by on the v1 series
#13 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Thanks for your work.

Quoted 8 lines · Geert Uytterhoeven

Hi all,

This patch series contains various cleanups related to power management for the Renesas SH Ethernet driver, as used on Renesas SH, ARM32, and ARM64 platforms.

This has been tested on various SoCs (R-Mobile A1, RZ/A1H, RZ/A2M, R-Car H1, R-Car M2-W).

For all three patches,

And I tested it on R-Car M2 so feel free to add,

Quoted 24 lines

Thanks for your comments!

Geert Uytterhoeven (3):
net: sh_eth: Remove dummy Runtime PM callbacks
net: sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
net: sh_eth: Use async pm_runtime_put()

 drivers/net/ethernet/renesas/sh_eth.c | 30 ++++-----------------------
 1 file changed, 4 insertions(+), 26 deletions(-)
Signature · 12 lines
2.43.0

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
Signature · 2 lines
Kind Regards,
Niklas Söderlund
#14 lore raw
In reply to Geert Uytterhoeven
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 4 Sep 2025 17:18:55 +0200 you wrote:

Hi all,

This patch series contains various cleanups related to power management for the Renesas SH Ethernet driver, as used on Renesas SH, ARM32, and ARM64 platforms.

This has been tested on various SoCs (R-Mobile A1, RZ/A1H, RZ/A2M, R-Car H1, R-Car M2-W).

[...]

Here is the summary with links:
- [net-next,1/3] sh_eth: Remove dummy Runtime PM callbacks

    https://git.kernel.org/netdev/net-next/c/86e6257192c8
  - [net-next,2/3] sh_eth: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
    https://git.kernel.org/netdev/net-next/c/3406114a303e
  - [net-next,3/3] sh_eth: Use async pm_runtime_put()
    https://git.kernel.org/netdev/net-next/c/ae52c3e846e1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html