Skip to contentSkip to conversation

net: fec: add missed clk_disable_unprepare in remove

PATCH Applied Chuhong Yuan 3 participants 8 messages Nov 4, 2019 – Nov 5, 2019

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

PATCH 1/1 net: fec: add missed clk_disable_unprepare in remove

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

---
 drivers/net/ethernet/freescale/fec_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +2 -0
index 22c01b224baa..a9c386b63581 100644
@@ -3645,6 +3645,8 @@ fec_drv_remove(struct platform_device *pdev)
 		regulator_disable(fep->reg_phy);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
+	clk_disable_unprepare(fep->clk_ahb);
+	clk_disable_unprepare(fep->clk_ipg);
 	if (of_phy_is_fixed_link(np))
 		of_phy_deregister_fixed_link(np);
 	of_node_put(fep->phy_node);
Signature · 1 line
2.23.0
#2 lore raw

From: David Miller <[email protected]> Sent: Tuesday, November 5, 2019 3:36 AM

Quoted 9 lines

From: Chuhong Yuan <[email protected]>
Date: Mon, 4 Nov 2019 23:50:00 +0800

Quoted 4 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

Applied.

David, the patch introduces clock count mismatch issue, please drop it.

Regards,
Andy

maintainer
#3 lore raw

From: Andy Duan <[email protected]>
Date: Tue, 5 Nov 2019 01:27:10 +0000

Quoted 4 lines

From: David Miller <[email protected]> Sent: Tuesday, November 5, 2019 3:36 AM

Quoted 3 lines

From: Chuhong Yuan <[email protected]>
Date: Mon, 4 Nov 2019 23:50:00 +0800

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

Applied.

David, the patch introduces clock count mismatch issue, please drop it.

Please send me a revert, I'm backlogged at the moment.

Thanks.

#4 lore raw

From: David Miller <[email protected]> Sent: Tuesday, November 5, 2019 9:32 AM

Quoted 13 lines

From: Andy Duan <[email protected]>
Date: Tue, 5 Nov 2019 01:27:10 +0000

Quoted 1 line

From: David Miller <[email protected]> Sent: Tuesday, November 5,

2019 3:36 AM

Quoted 8 lines
Quoted 8 lines

From: Chuhong Yuan <[email protected]>
Date: Mon, 4 Nov 2019 23:50:00 +0800

Quoted 4 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied.

David, the patch introduces clock count mismatch issue, please drop it.

Please send me a revert, I'm backlogged at the moment.

Thanks.

I already give comment to Chuhong Yuan, let's wait his response. If he will send the fixes, let's wait his patch. If not, I will send the a revert these two days.

Regards,
Andy

#5 lore raw
In reply to Chuhong Yuan

From: Chuhong Yuan <[email protected]> Sent: Monday, November 4, 2019 11:50 PM

Quoted 4 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

If runtime is enabled, the patch will introduce clock count mis-match. Probe->
Enable clk_ipg, clk_ahb clocks
...
In the end, runtime auto suspend callback disable clk_ipg, clk_ahb clocks.

You should check CONFIG_PM is enabled or not in your platform, if not, it can disable these two clocks by checking CONFIG_PM.

Regards,
Andy

Quoted 20 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +2 -1
index 22c01b224baa..a9c386b63581 100644
@@ -3645,6 +3645,8 @@ fec_drv_remove(struct platform_device *pdev)
                regulator_disable(fep->reg_phy);
        pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
        if (of_phy_is_fixed_link(np))
                of_phy_deregister_fixed_link(np);
        of_node_put(fep->phy_node);
--

2.23.0

#6 lore raw
Quoted 7 lines · Andy Duan

From: Chuhong Yuan <[email protected]> Sent: Monday, November 4, 2019 11:50 PM

Quoted 4 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

Quoted 9 lines

If runtime is enabled, the patch will introduce clock count mis-match. Probe->
Enable clk_ipg, clk_ahb clocks
...
In the end, runtime auto suspend callback disable clk_ipg, clk_ahb clocks.

You should check CONFIG_PM is enabled or not in your platform, if not, it can disable these two clocks by checking CONFIG_PM.

Thanks for your hint!
But I am still not very clear about the mechanism.
In my opinion, it means that if CONFIG_PM is disabled, runtime_suspend will be called automatically to disable clks.
Therefore, #ifdef CONFIG_PM check should be added before disabling clks in remove.
I am not sure whether this understanding is right or not?

Regards,
Chuhong

Quoted 23 lines

Regards,
Andy

Quoted 20 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +2 -1
index 22c01b224baa..a9c386b63581 100644
@@ -3645,6 +3645,8 @@ fec_drv_remove(struct platform_device *pdev)
                regulator_disable(fep->reg_phy);
        pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
        if (of_phy_is_fixed_link(np))
                of_phy_deregister_fixed_link(np);
        of_node_put(fep->phy_node);
--

2.23.0

#7 lore raw

From: Chuhong Yuan <[email protected]> Sent: Tuesday, November 5, 2019 11:34 PM

Quoted 16 lines · Andy Duan
Quoted 6 lines

From: Chuhong Yuan <[email protected]> Sent: Monday, November 4, 2019 11:50 PM

Quoted 3 lines

This driver forgets to disable and unprepare clks when remove. Add calls to clk_disable_unprepare to fix it.

Quoted 7 lines
Quoted 1 line

If runtime is enabled, the patch will introduce clock count mis-match. Probe->
Enable clk_ipg, clk_ahb clocks
...
In the end, runtime auto suspend callback disable clk_ipg, clk_ahb

clocks.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

You should check CONFIG_PM is enabled or not in your platform, if not, it can disable these two clocks by checking CONFIG_PM.

Thanks for your hint!
But I am still not very clear about the mechanism.
In my opinion, it means that if CONFIG_PM is disabled, runtime_suspend will be called automatically to disable clks.

CONFIG_PM is enabled, runtime pm works. Otherwise, it doesn't work, then it Requires .remove() to disable the clks.

Andy

Quoted 30 lines

Therefore, #ifdef CONFIG_PM check should be added before disabling clks in remove.
I am not sure whether this understanding is right or not?

Regards,
Chuhong

Quoted 23 lines

Regards,
Andy

Quoted 20 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +2 -1
index 22c01b224baa..a9c386b63581 100644
@@ -3645,6 +3645,8 @@ fec_drv_remove(struct platform_device *pdev)
                regulator_disable(fep->reg_phy);
        pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
        if (of_phy_is_fixed_link(np))
                of_phy_deregister_fixed_link(np);
        of_node_put(fep->phy_node);
--

2.23.0