netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: stmmac: rk: put the PHY clock on remove
@ 2025-08-08 12:16 Russell King (Oracle)
  2025-08-08 13:57 ` Simon Horman
  2025-08-12  3:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-08-08 12:16 UTC (permalink / raw)
  To: Andrew Lunn, David Wu, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which
doesn't take part in the devm release. Therefore, when a device is
unbound, this clock needs to be explicitly put. Fix this.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
Spotted this resource leak while making other changes to dwmac-rk.
Would be great if the dwmac-rk maintainers can test it.

v2: fix build error

 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 79b92130a03f..f6687c2f30f6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1765,11 +1765,15 @@ static int rk_gmac_probe(struct platform_device *pdev)
 
 static void rk_gmac_remove(struct platform_device *pdev)
 {
-	struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
+	struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev));
+	struct rk_priv_data *bsp_priv = priv->plat->bsp_priv;
 
 	stmmac_dvr_remove(&pdev->dev);
 
 	rk_gmac_powerdown(bsp_priv);
+
+	if (priv->plat->phy_node && bsp_priv->integrated_phy)
+		clk_put(bsp_priv->clk_phy);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.30.2


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

* Re: [PATCH net v2] net: stmmac: rk: put the PHY clock on remove
  2025-08-08 12:16 [PATCH net v2] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
@ 2025-08-08 13:57 ` Simon Horman
  2025-08-12  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-08-08 13:57 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, David Wu, Heiner Kallweit, Alexandre Torgue,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	linux-arm-kernel, linux-stm32, Maxime Coquelin, netdev,
	Paolo Abeni

On Fri, Aug 08, 2025 at 01:16:34PM +0100, Russell King (Oracle) wrote:
> The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which
> doesn't take part in the devm release. Therefore, when a device is
> unbound, this clock needs to be explicitly put. Fix this.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> Spotted this resource leak while making other changes to dwmac-rk.
> Would be great if the dwmac-rk maintainers can test it.
> 
> v2: fix build error

Thanks for the update Russell.

This fix looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>

And I guess it ought to be marked with.
Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")

If correct, then I don't think any further action is required as supplying
tags via email should be sufficient.


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

* Re: [PATCH net v2] net: stmmac: rk: put the PHY clock on remove
  2025-08-08 12:16 [PATCH net v2] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
  2025-08-08 13:57 ` Simon Horman
@ 2025-08-12  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-12  3:20 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, david.wu, hkallweit1, alexandre.torgue, andrew+netdev,
	davem, edumazet, kuba, linux-arm-kernel, linux-stm32,
	mcoquelin.stm32, netdev, pabeni

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 08 Aug 2025 13:16:34 +0100 you wrote:
> The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which
> doesn't take part in the devm release. Therefore, when a device is
> unbound, this clock needs to be explicitly put. Fix this.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> Spotted this resource leak while making other changes to dwmac-rk.
> Would be great if the dwmac-rk maintainers can test it.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: stmmac: rk: put the PHY clock on remove
    https://git.kernel.org/netdev/net/c/de1e963ad064

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-08-12  3:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 12:16 [PATCH net v2] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
2025-08-08 13:57 ` Simon Horman
2025-08-12  3:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).