clk: mediatek: Unregister apmixedsys clocks on unbind
Subsystems (2)
cover clk: mediatek: Unregister apmixedsys clocks on unbind
Pair apmixedsys clock registration with removal on four MediaTek SoCs.
Guangshuo Li (4):
clk: mediatek: mt8167: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8183: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8365: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8516: Unregister apmixedsys clocks on unbind
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
PATCH 1/4 clk: mediatek: mt8167: Unregister apmixedsys clocks on unbind
The apmixedsys driver leaves the OF provider and clocks registered on unbind. The clock table is device-managed, so the provider can retain a pointer to released storage.
Remove the provider and unregister the dividers and PLLs during removal.
This issue was found by our static analysis tool under development.
--- drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +12 -0
@@ -118,6 +118,8 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)if (ret) goto unregister_dividers; +platform_set_drvdata (pdev, clk_data); +return 0 ; unregister_dividers:
@@ -128,6 +130,15 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)return ret; } +static void clk_mt8167_apmixed_remove (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (pdev->dev.of_node); +mtk_clk_unregister_dividers (adj_divs,ARRAY_SIZE (adj_divs), clk_data); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +} +static const struct of_device_id of_match_clk_mt8167_apmixed[] = { { .compatible ="mediatek,mt8167-apmixedsys" }, {/* sentinel */ }
@@ -136,6 +147,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_apmixed);static struct platform_driver clk_mt8167_apmixed_drv = { .probe = clk_mt8167_apmixed_probe, + .remove = clk_mt8167_apmixed_remove, .driver = { .name ="clk-mt8167-apmixed" , .of_match_table = of_match_clk_mt8167_apmixed,
Signature · 1 line
2.43.0
PATCH 2/4 clk: mediatek: mt8183: Unregister apmixedsys clocks on unbind
In reply to Guangshuo LiThe apmixedsys driver leaves the OF provider and clocks registered on unbind. The clock table is device-managed, so the provider can retain a pointer to released storage.
Remove the provider and unregister the gates and PLLs during removal.
This issue was found by our static analysis tool under development.
--- drivers/clk/mediatek/clk-mt8183-apmixedsys.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/clk/mediatek/clk-mt8183-apmixedsys.c +13 -0
@@ -168,6 +168,8 @@ static int clk_mt8183_apmixed_probe(struct platform_device *pdev)if (ret) goto unregister_gates; +platform_set_drvdata (pdev, clk_data); +return 0 ; unregister_gates:
@@ -178,6 +180,16 @@ static int clk_mt8183_apmixed_probe(struct platform_device *pdev)return ret; } +static void clk_mt8183_apmixed_remove (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (pdev->dev.of_node); +mtk_clk_unregister_gates (apmixed_clks,ARRAY_SIZE (apmixed_clks), + clk_data); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +} +static const struct of_device_id of_match_clk_mt8183_apmixed[] = { { .compatible ="mediatek,mt8183-apmixedsys" }, {/* sentinel */ }
@@ -186,6 +198,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_apmixed);static struct platform_driver clk_mt8183_apmixed_drv = { .probe = clk_mt8183_apmixed_probe, + .remove = clk_mt8183_apmixed_remove, .driver = { .name ="clk-mt8183-apmixed" , .of_match_table = of_match_clk_mt8183_apmixed,
Signature · 1 line
2.43.0
PATCH 3/4 clk: mediatek: mt8365: Unregister apmixedsys clocks on unbind
In reply to Guangshuo LiThe apmixedsys driver leaves the OF provider and clocks registered on unbind. The clock table is device-managed, so the provider can retain a pointer to released storage.
Remove the provider and unregister the PLLs during removal.
This issue was found by our static analysis tool under development.
--- drivers/clk/mediatek/clk-mt8365-apmixedsys.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clk/mediatek/clk-mt8365-apmixedsys.c +11 -0
@@ -141,6 +141,8 @@ static int clk_mt8365_apmixed_probe(struct platform_device *pdev)if (ret) goto unregister_plls; +platform_set_drvdata (pdev, clk_data); +return 0 ; unregister_plls:
@@ -149,6 +151,14 @@ static int clk_mt8365_apmixed_probe(struct platform_device *pdev)return ret; } +static void clk_mt8365_apmixed_remove (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (pdev->dev.of_node); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +} +static const struct of_device_id of_match_clk_mt8365_apmixed[] = { { .compatible ="mediatek,mt8365-apmixedsys" }, {/* sentinel */ }
@@ -157,6 +167,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_apmixed);static struct platform_driver clk_mt8365_apmixed_drv = { .probe = clk_mt8365_apmixed_probe, + .remove = clk_mt8365_apmixed_remove, .driver = { .name ="clk-mt8365-apmixed" , .of_match_table = of_match_clk_mt8365_apmixed,
Signature · 1 line
2.43.0
PATCH 4/4 clk: mediatek: mt8516: Unregister apmixedsys clocks on unbind
In reply to Guangshuo LiThe apmixedsys driver leaves the OF provider and clocks registered on unbind. The clock table is device-managed, so the provider can retain a pointer to released storage.
Remove the provider and unregister the PLLs during removal.
This issue was found by our static analysis tool under development.
--- drivers/clk/mediatek/clk-mt8516-apmixedsys.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clk/mediatek/clk-mt8516-apmixedsys.c +11 -0
@@ -95,6 +95,8 @@ static int clk_mt8516_apmixed_probe(struct platform_device *pdev)if (ret) goto unregister_plls; +platform_set_drvdata (pdev, clk_data); +return 0 ; unregister_plls:
@@ -103,6 +105,14 @@ static int clk_mt8516_apmixed_probe(struct platform_device *pdev)return ret; } +static void clk_mt8516_apmixed_remove (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (pdev->dev.of_node); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +} +static const struct of_device_id of_match_clk_mt8516_apmixed[] = { { .compatible ="mediatek,mt8516-apmixedsys" }, {/* sentinel */ }
@@ -111,6 +121,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_apmixed);static struct platform_driver clk_mt8516_apmixed_drv = { .probe = clk_mt8516_apmixed_probe, + .remove = clk_mt8516_apmixed_remove, .driver = { .name ="clk-mt8516-apmixed" , .of_match_table = of_match_clk_mt8516_apmixed,
Signature · 1 line
2.43.0
Quoted 2 lines · Guangshuo Li
Pair apmixedsys clock registration with removal on four MediaTek SoCs.
You are checking the wrong tree.
This series is mostly obsoleted by the following commits:
c9c2fd1a53a4 clk: mediatek: mt8516-apmixedsys: Switch to common probe/remove helpers68d1fa487766 clk: mediatek: mt8183: Switch to common probe/remove helpers 9421b0b085c0 clk: mediatek: mt8167-apmixedsys: Switch to common probe/remove helpers
Quoted 4 lines
Guangshuo Li (4):
clk: mediatek: mt8167: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8183: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8365: Unregister apmixedsys clocks on unbind
This is the only one that applies. But we probably want to convert it to the common helpers as well.
ChenYu
Quoted 4 lines
clk: mediatek: mt8516: Unregister apmixedsys clocks on unbind
base-commit:
4dce97c6c265544342e716e62fd24bbb232590c5
Hi Guangshuo,
Quoted 10 lines · Guangshuo Li
Pair apmixedsys clock registration with removal on four MediaTek SoCs.
Guangshuo Li (4):
clk: mediatek: mt8167: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8183: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8365: Unregister apmixedsys clocks on unbind
clk: mediatek: mt8516: Unregister apmixedsys clocks on unbindbase-commit:
4dce97c6c265544342e716e62fd24bbb232590c5
As ChenYu mentioned, my previous series fixed these issues. However, due to my insufficient verification,
some regressions were introduced, so I'm preparing a followup series. During the correction process, sadly I found and fixing several bugs in MediaTek CCF, so please wait a few more days...
Best regards,
Akari