netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: rk: put the PHY clock on remove
@ 2025-08-07  8:48 Russell King (Oracle)
  2025-08-07 18:33 ` Simon Horman
  2025-08-08  0:00 ` kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-08-07  8:48 UTC (permalink / raw)
  To: Andrew Lunn, David Wu, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, David Wu,
	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.

Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")
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.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 79b92130a03f..4a315c87c4d0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1770,6 +1770,9 @@ static void rk_gmac_remove(struct platform_device *pdev)
 	stmmac_dvr_remove(&pdev->dev);
 
 	rk_gmac_powerdown(bsp_priv);
+
+	if (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] 5+ messages in thread

* Re: [PATCH net] net: stmmac: rk: put the PHY clock on remove
  2025-08-07  8:48 [PATCH net] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
@ 2025-08-07 18:33 ` Simon Horman
  2025-08-07 19:15   ` Russell King (Oracle)
  2025-08-08  0:00 ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2025-08-07 18:33 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 Thu, Aug 07, 2025 at 09:48:30AM +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.
> 
> Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")
> 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.
> 
>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 79b92130a03f..4a315c87c4d0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1770,6 +1770,9 @@ static void rk_gmac_remove(struct platform_device *pdev)
>  	stmmac_dvr_remove(&pdev->dev);
>  
>  	rk_gmac_powerdown(bsp_priv);
> +
> +	if (plat->phy_node && bsp_priv->integrated_phy)
> +		clk_put(bsp_priv->clk_phy);

Hi Russell,

Something seems a little off here.
I don't see plat in this context in net.

>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> -- 
> 2.30.2
> 

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

* Re: [PATCH net] net: stmmac: rk: put the PHY clock on remove
  2025-08-07 18:33 ` Simon Horman
@ 2025-08-07 19:15   ` Russell King (Oracle)
  2025-08-08 13:09     ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King (Oracle) @ 2025-08-07 19:15 UTC (permalink / raw)
  To: Simon Horman
  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 Thu, Aug 07, 2025 at 07:33:59PM +0100, Simon Horman wrote:
> On Thu, Aug 07, 2025 at 09:48:30AM +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.
> > 
> > Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")
> > 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.
> > 
> >  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > index 79b92130a03f..4a315c87c4d0 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > @@ -1770,6 +1770,9 @@ static void rk_gmac_remove(struct platform_device *pdev)
> >  	stmmac_dvr_remove(&pdev->dev);
> >  
> >  	rk_gmac_powerdown(bsp_priv);
> > +
> > +	if (plat->phy_node && bsp_priv->integrated_phy)
> > +		clk_put(bsp_priv->clk_phy);
> 
> Hi Russell,
> 
> Something seems a little off here.
> I don't see plat in this context in net.

Already have a fix for it, thanks anyway. Today ended up going awol
due to dentistry stuff. :(

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net] net: stmmac: rk: put the PHY clock on remove
  2025-08-07  8:48 [PATCH net] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
  2025-08-07 18:33 ` Simon Horman
@ 2025-08-08  0:00 ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-08-08  0:00 UTC (permalink / raw)
  To: Russell King (Oracle), Andrew Lunn, David Wu, Heiner Kallweit
  Cc: llvm, oe-kbuild-all, Alexandre Torgue, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Paolo Abeni

Hi Russell,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Russell-King-Oracle/net-stmmac-rk-put-the-PHY-clock-on-remove/20250807-165054
base:   net/main
patch link:    https://lore.kernel.org/r/E1ujwIY-007qKa-Ka%40rmk-PC.armlinux.org.uk
patch subject: [PATCH net] net: stmmac: rk: put the PHY clock on remove
config: arm-defconfig (https://download.01.org/0day-ci/archive/20250808/202508080746.BIDlKMy5-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 7b8dea265e72c3037b6b1e54d5ab51b7e14f328b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250808/202508080746.BIDlKMy5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508080746.BIDlKMy5-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c:1774:6: error: use of undeclared identifier 'plat'
    1774 |         if (plat->phy_node && bsp_priv->integrated_phy)
         |             ^~~~
   1 error generated.


vim +/plat +1774 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

  1765	
  1766	static void rk_gmac_remove(struct platform_device *pdev)
  1767	{
  1768		struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
  1769	
  1770		stmmac_dvr_remove(&pdev->dev);
  1771	
  1772		rk_gmac_powerdown(bsp_priv);
  1773	
> 1774		if (plat->phy_node && bsp_priv->integrated_phy)
  1775			clk_put(bsp_priv->clk_phy);
  1776	}
  1777	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH net] net: stmmac: rk: put the PHY clock on remove
  2025-08-07 19:15   ` Russell King (Oracle)
@ 2025-08-08 13:09     ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-08-08 13:09 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 Thu, Aug 07, 2025 at 08:15:13PM +0100, Russell King (Oracle) wrote:
> On Thu, Aug 07, 2025 at 07:33:59PM +0100, Simon Horman wrote:
> > On Thu, Aug 07, 2025 at 09:48:30AM +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.
> > > 
> > > Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")
> > > 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.
> > > 
> > >  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > > index 79b92130a03f..4a315c87c4d0 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > > @@ -1770,6 +1770,9 @@ static void rk_gmac_remove(struct platform_device *pdev)
> > >  	stmmac_dvr_remove(&pdev->dev);
> > >  
> > >  	rk_gmac_powerdown(bsp_priv);
> > > +
> > > +	if (plat->phy_node && bsp_priv->integrated_phy)
> > > +		clk_put(bsp_priv->clk_phy);
> > 
> > Hi Russell,
> > 
> > Something seems a little off here.
> > I don't see plat in this context in net.
> 
> Already have a fix for it, thanks anyway. Today ended up going awol
> due to dentistry stuff. :(

Thanks, I see the fix now.
Hope your AFK mission went well.

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07  8:48 [PATCH net] net: stmmac: rk: put the PHY clock on remove Russell King (Oracle)
2025-08-07 18:33 ` Simon Horman
2025-08-07 19:15   ` Russell King (Oracle)
2025-08-08 13:09     ` Simon Horman
2025-08-08  0:00 ` kernel test robot

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).