From: Niklas Söderlund niklas.soderlund+renesas@ragnatech.se
[ Upstream commit 9c02ea544ac35a9def5827d30594406947ccd81a ]
The MAC can't facilitate WoL if the system can't go to sleep. Gate the WoL support callbacks in ethtool at compile time using CONFIG_PM_SLEEP.
Signed-off-by: Niklas Söderlund niklas.soderlund+renesas@ragnatech.se Reviewed-by: Andrew Lunn andrew@lunn.ch Reviewed-by: Geert Uytterhoeven geert+renesas@glider.be Link: https://patch.msgid.link/20250909085849.3808169-1-niklas.soderlund+renesas@r... Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What it does - Gates the ethtool WoL callbacks behind `CONFIG_PM_SLEEP`, so WoL is only reported/configurable when the system can actually suspend. - Specifically wraps `sh_eth_get_wol()` and `sh_eth_set_wol()` with `#ifdef CONFIG_PM_SLEEP` and only sets the corresponding ethtool ops when sleep support is enabled.
- Code references - Function definitions are compiled only if sleep is enabled: drivers/net/ethernet/renesas/sh_eth.c:2363 and drivers/net/ethernet/renesas/sh_eth.c:2390 - Etwttool ops pointers are likewise conditioned: drivers/net/ethernet/renesas/sh_eth.c:2406 and drivers/net/ethernet/renesas/sh_eth.c:2409 - The driver’s suspend/resume path that actually uses WoL state (`mdp->wol_enabled`) is part of PM sleep handling: - `sh_eth_suspend()` checks `mdp->wol_enabled` to set up Magic Packet WoL: drivers/net/ethernet/renesas/sh_eth.c:3500 - `sh_eth_resume()` mirrors that to restore state: drivers/net/ethernet/renesas/sh_eth.c:3519 - The driver already declares PM sleep ops via `pm_sleep_ptr`, so suspend/resume are only active when `CONFIG_PM_SLEEP` is enabled, making the ethtool gating consistent: drivers/net/ethernet/renesas/sh_eth.c:3553
- Why this is a bug fix - Without system sleep support, the suspend/resume hooks that actually arm/disarm WoL are not used, so advertising WoL to userspace (`ethtool`) is misleading and non-functional. The patch prevents reporting/configuring WoL when it cannot work in practice. - This aligns the reported capability with the runtime behavior and avoids users enabling a feature that can’t take effect.
- Scope and risk - Change is small, compile-time only, and limited to `sh_eth` ethtool ops and two static helpers. - No data path changes; no architectural changes; only affects builds with `CONFIG_PM_SLEEP=n`. - When `CONFIG_PM_SLEEP=y`, behavior is unchanged.
- Stable backport criteria - Fixes a real user-visible correctness issue (capability misreporting). - Minimal and self-contained to a single driver file. - No new features or API changes; low regression risk. - Consistent with existing PM gating (`pm_sleep_ptr`) in the same driver.
Given the above, this is an appropriate, low-risk correctness fix to backport.
drivers/net/ethernet/renesas/sh_eth.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 5fc8027c92c7c..695fa3592c9a2 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -2360,6 +2360,7 @@ static int sh_eth_set_ringparam(struct net_device *ndev, return 0; }
+#ifdef CONFIG_PM_SLEEP static void sh_eth_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) { struct sh_eth_private *mdp = netdev_priv(ndev); @@ -2386,6 +2387,7 @@ static int sh_eth_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
return 0; } +#endif
static const struct ethtool_ops sh_eth_ethtool_ops = { .get_regs_len = sh_eth_get_regs_len, @@ -2401,8 +2403,10 @@ static const struct ethtool_ops sh_eth_ethtool_ops = { .set_ringparam = sh_eth_set_ringparam, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings, +#ifdef CONFIG_PM_SLEEP .get_wol = sh_eth_get_wol, .set_wol = sh_eth_set_wol, +#endif };
/* network device open function */