* [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management @ 2026-11-27 14:01 Markus Elfring 2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring 2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring 0 siblings, 2 replies; 6+ messages in thread From: Markus Elfring @ 2026-11-27 14:01 UTC (permalink / raw) To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 27 Nov 2026 13:50:43 +0100 Two update suggestions were taken into account from source code analysis. Markus Elfring (2): Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Use devm_clk_get_enabled() in two probe functions V2: An initial patch was converted into a small patch series. drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++--------------- 1 file changed, 8 insertions(+), 23 deletions(-) -- 2.56.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() 2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring @ 2026-11-27 14:03 ` Markus Elfring 2026-11-27 14:14 ` netdev-bot+sinfo 2026-11-27 14:26 ` Jonas Gorski 2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring 1 sibling, 2 replies; 6+ messages in thread From: Markus Elfring @ 2026-11-27 14:03 UTC (permalink / raw) To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 27 Nov 2026 11:52:23 +0100 A clk_prepare_enable(priv->phy_clk) call was specified within an if branch in the implementation of the function “bcm_enet_probe” while a clk_disable_unprepare(priv->phy_clk) call was unconditionally performed in the implementation of the function “bcm_enet_remove”. Move this clk_disable_unprepare() call into a corresponding if branch. Fixes: 7e697ce99ceb09538cdc1dfa9ebb3db60236b0a7 ("bcm63xx_enet: use managed functions for clock/ioremap") Cc: stable@vger.kernel.org Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index f6595fdc888d..cc9a5cd2a2a3 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -1915,6 +1915,9 @@ static void bcm_enet_remove(struct platform_device *pdev) enet_writel(priv, 0, ENET_MIISC_REG); if (priv->has_phy) { + if (!priv->use_external_mii) + clk_disable_unprepare(priv->phy_clk); + mdiobus_unregister(priv->mii_bus); mdiobus_free(priv->mii_bus); } else { @@ -1927,7 +1930,6 @@ static void bcm_enet_remove(struct platform_device *pdev) } /* disable hw block clocks */ - clk_disable_unprepare(priv->phy_clk); clk_disable_unprepare(priv->mac_clk); free_netdev(dev); -- 2.56.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() 2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring @ 2026-11-27 14:14 ` netdev-bot+sinfo 2026-11-27 14:26 ` Jonas Gorski 1 sibling, 0 replies; 6+ messages in thread From: netdev-bot+sinfo @ 2026-11-27 14:14 UTC (permalink / raw) To: Markus Elfring Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman, LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. - What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() 2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring 2026-11-27 14:14 ` netdev-bot+sinfo @ 2026-11-27 14:26 ` Jonas Gorski 2026-11-27 14:33 ` [v2 " Markus Elfring 1 sibling, 1 reply; 6+ messages in thread From: Jonas Gorski @ 2026-11-27 14:26 UTC (permalink / raw) To: Markus Elfring Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Paolo Abeni, Simon Horman, LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall On Fri, Nov 27, 2026 at 3:04 PM Markus Elfring <Markus.Elfring@web.de> wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Fri, 27 Nov 2026 11:52:23 +0100 > > A clk_prepare_enable(priv->phy_clk) call was specified within an if branch > in the implementation of the function “bcm_enet_probe” while > a clk_disable_unprepare(priv->phy_clk) call was unconditionally performed > in the implementation of the function “bcm_enet_remove”. > Move this clk_disable_unprepare() call into a corresponding if branch. > > Fixes: 7e697ce99ceb09538cdc1dfa9ebb3db60236b0a7 ("bcm63xx_enet: use managed functions for clock/ioremap") > Cc: stable@vger.kernel.org > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c > index f6595fdc888d..cc9a5cd2a2a3 100644 > --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c > +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c > @@ -1915,6 +1915,9 @@ static void bcm_enet_remove(struct platform_device *pdev) > enet_writel(priv, 0, ENET_MIISC_REG); > > if (priv->has_phy) { > + if (!priv->use_external_mii) > + clk_disable_unprepare(priv->phy_clk); > + > mdiobus_unregister(priv->mii_bus); > mdiobus_free(priv->mii_bus); > } else { > @@ -1927,7 +1930,6 @@ static void bcm_enet_remove(struct platform_device *pdev) > } > > /* disable hw block clocks */ > - clk_disable_unprepare(priv->phy_clk); clk_disable_unprepare() is NULL-safe, so it's fine to call it unconditionally. This change fixes nothing, just adds potential breakage (disabling the phy clock before unregistering the mdio bus feels risky). > clk_disable_unprepare(priv->mac_clk); Best regards, Jonas ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() 2026-11-27 14:26 ` Jonas Gorski @ 2026-11-27 14:33 ` Markus Elfring 0 siblings, 0 replies; 6+ messages in thread From: Markus Elfring @ 2026-11-27 14:33 UTC (permalink / raw) To: Jonas Gorski, netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Paolo Abeni, Simon Horman Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall > clk_disable_unprepare() is NULL-safe, so it's fine to call it > unconditionally. Where is such an API property documented? > This change fixes nothing, just adds potential > breakage (disabling the phy clock before unregistering the mdio bus > feels risky). Will involved software dependencies be clarified in more desirable ways? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions 2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring 2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring @ 2026-11-27 14:07 ` Markus Elfring 1 sibling, 0 replies; 6+ messages in thread From: Markus Elfring @ 2026-11-27 14:07 UTC (permalink / raw) To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam, Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li, Julia Lawall From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 27 Nov 2026 13:30:17 +0100 * Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code. * Delete a clk_disable_unprepare() call on error handling paths and in the implementation of two remove functions. * Omit two labels. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 27 ++++---------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index cc9a5cd2a2a3..d9466609e7c1 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -1751,14 +1751,11 @@ static int bcm_enet_probe(struct platform_device *pdev) priv->irq_rx = irq_rx; priv->irq_tx = irq_tx; - priv->mac_clk = devm_clk_get(&pdev->dev, "enet"); + priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enet"); if (IS_ERR(priv->mac_clk)) { ret = PTR_ERR(priv->mac_clk); goto out; } - ret = clk_prepare_enable(priv->mac_clk); - if (ret) - goto out; /* initialize default and fetch platform data */ priv->rx_ring_size = BCMENET_DEF_RX_DESC; @@ -1792,11 +1789,11 @@ static int bcm_enet_probe(struct platform_device *pdev) if (IS_ERR(priv->phy_clk)) { ret = PTR_ERR(priv->phy_clk); priv->phy_clk = NULL; - goto out_disable_clk_mac; + goto out; } ret = clk_prepare_enable(priv->phy_clk); if (ret) - goto out_disable_clk_mac; + goto out; } /* do minimal hardware init to be able to probe mii bus */ @@ -1890,8 +1887,6 @@ static int bcm_enet_probe(struct platform_device *pdev) enet_writel(priv, 0, ENET_MIISC_REG); clk_disable_unprepare(priv->phy_clk); -out_disable_clk_mac: - clk_disable_unprepare(priv->mac_clk); out: free_netdev(dev); return ret; @@ -1929,9 +1924,6 @@ static void bcm_enet_remove(struct platform_device *pdev) bcm_enet_mdio_write_mii); } - /* disable hw block clocks */ - clk_disable_unprepare(priv->mac_clk); - free_netdev(dev); } @@ -2694,14 +2686,11 @@ static int bcm_enetsw_probe(struct platform_device *pdev) goto out; } - priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw"); + priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enetsw"); if (IS_ERR(priv->mac_clk)) { ret = PTR_ERR(priv->mac_clk); goto out; } - ret = clk_prepare_enable(priv->mac_clk); - if (ret) - goto out; priv->rx_chan = 0; priv->tx_chan = 1; @@ -2720,7 +2709,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev) ret = register_netdev(dev); if (ret) - goto out_disable_clk; + goto out; netif_carrier_off(dev); platform_set_drvdata(pdev, dev); @@ -2729,8 +2718,6 @@ static int bcm_enetsw_probe(struct platform_device *pdev) return 0; -out_disable_clk: - clk_disable_unprepare(priv->mac_clk); out: free_netdev(dev); return ret; @@ -2740,16 +2727,12 @@ static int bcm_enetsw_probe(struct platform_device *pdev) /* exit func, stops hardware and unregisters netdevice */ static void bcm_enetsw_remove(struct platform_device *pdev) { - struct bcm_enet_priv *priv; struct net_device *dev; /* stop netdevice */ dev = platform_get_drvdata(pdev); - priv = netdev_priv(dev); unregister_netdev(dev); - clk_disable_unprepare(priv->mac_clk); - free_netdev(dev); } -- 2.56.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 14:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring 2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring 2026-11-27 14:14 ` netdev-bot+sinfo 2026-11-27 14:26 ` Jonas Gorski 2026-11-27 14:33 ` [v2 " Markus Elfring 2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox