* [PATCH 0/2] pmdomain: amlogic: Add teardown for EE and secure power domains @ 2026-11-27 11:33 ` Tian Xuechen 0 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> Unregister the domains published by the EE and secure power controllers during removal. Tian Xuechen (2): pmdomain: amlogic: Tear down EE domains and their OF provider pmdomain: amlogic: Tear down secure domains and their OF provider base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] pmdomain: amlogic: Add teardown for EE and secure power domains @ 2026-11-27 11:33 ` Tian Xuechen 0 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> Unregister the domains published by the EE and secure power controllers during removal. Tian Xuechen (2): pmdomain: amlogic: Tear down EE domains and their OF provider pmdomain: amlogic: Tear down secure domains and their OF provider base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider 2026-11-27 11:33 ` Tian Xuechen @ 2026-11-27 11:33 ` Tian Xuechen -1 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> The Meson EE power driver leaves the provider and domains registered after freeing their backing storage. Remove the OF provider on unbind and release initialized domains during managed cleanup, including when probe fails. This issue was found by our static analysis tool under development. Fixes: eef3c2ba0a42 ("soc: amlogic: Add support for Everything-Else power domains controller") Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn> --- drivers/pmdomain/amlogic/meson-ee-pwrc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/amlogic/meson-ee-pwrc.c b/drivers/pmdomain/amlogic/meson-ee-pwrc.c index 338f70d77bf0..f108d9337e5e 100644 --- a/drivers/pmdomain/amlogic/meson-ee-pwrc.c +++ b/drivers/pmdomain/amlogic/meson-ee-pwrc.c @@ -428,6 +428,16 @@ static int meson_ee_pwrc_on(struct generic_pm_domain *domain) pwrc_domain->clks); } +static void meson_ee_pwrc_remove_domain(void *data) +{ + pm_genpd_remove(data); +} + +static void meson_ee_pwrc_remove(struct platform_device *pdev) +{ + of_genpd_del_provider(pdev->dev.of_node); +} + static int meson_ee_pwrc_init_domain(struct platform_device *pdev, struct meson_ee_pwrc *pwrc, struct meson_ee_pwrc_domain *dom) @@ -494,7 +504,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, return ret; } - return 0; + return devm_add_action_or_reset(&pdev->dev, meson_ee_pwrc_remove_domain, + &dom->base); } static int meson_ee_pwrc_probe(struct platform_device *pdev) @@ -641,6 +652,7 @@ MODULE_DEVICE_TABLE(of, meson_ee_pwrc_match_table); static struct platform_driver meson_ee_pwrc_driver = { .probe = meson_ee_pwrc_probe, + .remove = meson_ee_pwrc_remove, .shutdown = meson_ee_pwrc_shutdown, .driver = { .name = "meson_ee_pwrc", -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider @ 2026-11-27 11:33 ` Tian Xuechen 0 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> The Meson EE power driver leaves the provider and domains registered after freeing their backing storage. Remove the OF provider on unbind and release initialized domains during managed cleanup, including when probe fails. This issue was found by our static analysis tool under development. Fixes: eef3c2ba0a42 ("soc: amlogic: Add support for Everything-Else power domains controller") Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn> --- drivers/pmdomain/amlogic/meson-ee-pwrc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/amlogic/meson-ee-pwrc.c b/drivers/pmdomain/amlogic/meson-ee-pwrc.c index 338f70d77bf0..f108d9337e5e 100644 --- a/drivers/pmdomain/amlogic/meson-ee-pwrc.c +++ b/drivers/pmdomain/amlogic/meson-ee-pwrc.c @@ -428,6 +428,16 @@ static int meson_ee_pwrc_on(struct generic_pm_domain *domain) pwrc_domain->clks); } +static void meson_ee_pwrc_remove_domain(void *data) +{ + pm_genpd_remove(data); +} + +static void meson_ee_pwrc_remove(struct platform_device *pdev) +{ + of_genpd_del_provider(pdev->dev.of_node); +} + static int meson_ee_pwrc_init_domain(struct platform_device *pdev, struct meson_ee_pwrc *pwrc, struct meson_ee_pwrc_domain *dom) @@ -494,7 +504,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, return ret; } - return 0; + return devm_add_action_or_reset(&pdev->dev, meson_ee_pwrc_remove_domain, + &dom->base); } static int meson_ee_pwrc_probe(struct platform_device *pdev) @@ -641,6 +652,7 @@ MODULE_DEVICE_TABLE(of, meson_ee_pwrc_match_table); static struct platform_driver meson_ee_pwrc_driver = { .probe = meson_ee_pwrc_probe, + .remove = meson_ee_pwrc_remove, .shutdown = meson_ee_pwrc_shutdown, .driver = { .name = "meson_ee_pwrc", -- 2.43.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider 2026-11-27 11:33 ` Tian Xuechen (?) @ 2026-11-27 11:44 ` sashiko-bot 2026-11-28 9:56 ` Tian Xuechen -1 siblings, 1 reply; 8+ messages in thread From: sashiko-bot @ 2026-11-27 11:44 UTC (permalink / raw) To: Tian Xuechen; +Cc: linux-amlogic, neil.armstrong Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] pmdomain: amlogic: clock prepare/enable leak in meson_ee_pwrc_init_domain() -- commit e98fddbd00e9a83bce5020c8ad856e22d6525ccc Author: Tian Xuechen <202300460064@mail.sdu.edu.cn> pmdomain: amlogic: Tear down EE domains and their OF provider This commit removes the OF genpd provider on driver unbind and registers a devm cleanup action to remove initialized power domains on probe failure or unbind. > diff --git a/drivers/pmdomain/amlogic/meson-ee-pwrc.c b/drivers/pmdomain/amlogic/meson-ee-pwrc.c > index 338f70d77bf03..f108d9337e5e4 100644 > --- a/drivers/pmdomain/amlogic/meson-ee-pwrc.c > +++ b/drivers/pmdomain/amlogic/meson-ee-pwrc.c > @@ -428,6 +428,16 @@ static int meson_ee_pwrc_on(struct generic_pm_domain *domain) > pwrc_domain->clks); > } > > +static void meson_ee_pwrc_remove_domain(void *data) > +{ > + pm_genpd_remove(data); > +} > + > +static void meson_ee_pwrc_remove(struct platform_device *pdev) > +{ > + of_genpd_del_provider(pdev->dev.of_node); > +} > + > static int meson_ee_pwrc_init_domain(struct platform_device *pdev, > struct meson_ee_pwrc *pwrc, > struct meson_ee_pwrc_domain *dom) > @@ -494,7 +504,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, > return ret; > } > > - return 0; > + return devm_add_action_or_reset(&pdev->dev, meson_ee_pwrc_remove_domain, > + &dom->base); > } [Severity: Medium] Does this leak the prepare and enable references on dom->clks when an already-powered-on domain is torn down or fails to initialize? In meson_ee_pwrc_init_domain(), a domain with clocks that is already powered on calls clk_bulk_prepare_enable() and sets GENPD_FLAG_ALWAYS_ON: drivers/pmdomain/amlogic/meson-ee-pwrc.c:meson_ee_pwrc_init_domain() { if (dom->num_clks && dom->desc.is_powered_off && !dom->desc.is_powered_off(dom)) { ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks); if (ret) return ret; dom->base.flags = GENPD_FLAG_ALWAYS_ON; ret = pm_genpd_init(&dom->base, NULL, false); if (ret) return ret; } } Neither a failure in pm_genpd_init() nor meson_ee_pwrc_remove_domain() calls clk_bulk_disable_unprepare(), and devm_clk_bulk_get_all() only puts the clock handles on release, leaving their prepare and enable counts elevated on probe failure or driver unbind. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127113326.390398-1-202300460064@mail.sdu.edu.cn?part=1 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider 2026-11-27 11:44 ` sashiko-bot @ 2026-11-28 9:56 ` Tian Xuechen 0 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-28 9:56 UTC (permalink / raw) To: sashiko-reviews; +Cc: linux-amlogic Hi all, During probe, the driver takes clock references for a VPU that is already powered on. Dropping the last reference can turn off its clocks. Should the driver keep those clocks running if probe fails? If we can release the references, I would do so if pm_genpd_init() fails, or after pm_genpd_remove() succeeds for a registered domain. Should the clocks stay on during normal unbind? Can the driver rely on all consumers detaching before pm_genpd_remove() runs? Thanks, Tian _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] pmdomain: amlogic: Tear down secure domains and their OF provider 2026-11-27 11:33 ` Tian Xuechen @ 2026-11-27 11:33 ` Tian Xuechen -1 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> The secure power driver leaves the OF provider and domain hierarchy registered after its memory is released. Remove the provider on unbind and unwind subdomain links before the domains they connect. Use the same cleanup when probe fails midway. This issue was found by our static analysis tool under development. Fixes: b3dde5013e13 ("soc: amlogic: Add support for Secure power domains controller") Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn> --- drivers/pmdomain/amlogic/meson-secure-pwrc.c | 36 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/pmdomain/amlogic/meson-secure-pwrc.c b/drivers/pmdomain/amlogic/meson-secure-pwrc.c index c424a1e76174..53e3fa10328e 100644 --- a/drivers/pmdomain/amlogic/meson-secure-pwrc.c +++ b/drivers/pmdomain/amlogic/meson-secure-pwrc.c @@ -392,9 +392,26 @@ static const struct meson_secure_pwrc_domain_desc t7_pwrc_domains[] = { SEC_PD(T7_AUDIO, 0), }; +static void meson_secure_pwrc_remove_domain(void *data) +{ + pm_genpd_remove(data); +} + +static void meson_secure_pwrc_remove_subdomain(void *data) +{ + struct meson_secure_pwrc_domain *dom = data; + + pm_genpd_remove_subdomain(&dom->pwrc->domains[dom->parent].base, &dom->base); +} + +static void meson_secure_pwrc_remove(struct platform_device *pdev) +{ + of_genpd_del_provider(pdev->dev.of_node); +} + static int meson_secure_pwrc_probe(struct platform_device *pdev) { - int i; + int i, ret; struct device_node *sm_np; struct meson_secure_pwrc *pwrc; const struct meson_secure_pwrc_domain_data *match; @@ -453,7 +470,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev) if (match->domains[i].is_off(dom) && (dom->base.flags & GENPD_FLAG_ALWAYS_ON)) meson_secure_pwrc_on(&dom->base); - pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom)); + ret = pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom)); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_domain, + &dom->base); + if (ret) + return ret; pwrc->xlate.domains[i] = &dom->base; } @@ -464,7 +487,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev) if (!match->domains[i].name || match->domains[i].parent == PWRC_NO_PARENT) continue; - pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base); + ret = pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_subdomain, + &dom[i]); + if (ret) + return ret; } return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate); @@ -567,6 +596,7 @@ MODULE_DEVICE_TABLE(of, meson_secure_pwrc_match_table); static struct platform_driver meson_secure_pwrc_driver = { .probe = meson_secure_pwrc_probe, + .remove = meson_secure_pwrc_remove, .driver = { .name = "meson_secure_pwrc", .of_match_table = meson_secure_pwrc_match_table, -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] pmdomain: amlogic: Tear down secure domains and their OF provider @ 2026-11-27 11:33 ` Tian Xuechen 0 siblings, 0 replies; 8+ messages in thread From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw) To: ulfh, neil.armstrong, khilman, jianxin.pan Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel, linux-amlogic From: Tian Xuechen <202300460064@mail.sdu.edu.cn> The secure power driver leaves the OF provider and domain hierarchy registered after its memory is released. Remove the provider on unbind and unwind subdomain links before the domains they connect. Use the same cleanup when probe fails midway. This issue was found by our static analysis tool under development. Fixes: b3dde5013e13 ("soc: amlogic: Add support for Secure power domains controller") Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn> --- drivers/pmdomain/amlogic/meson-secure-pwrc.c | 36 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/pmdomain/amlogic/meson-secure-pwrc.c b/drivers/pmdomain/amlogic/meson-secure-pwrc.c index c424a1e76174..53e3fa10328e 100644 --- a/drivers/pmdomain/amlogic/meson-secure-pwrc.c +++ b/drivers/pmdomain/amlogic/meson-secure-pwrc.c @@ -392,9 +392,26 @@ static const struct meson_secure_pwrc_domain_desc t7_pwrc_domains[] = { SEC_PD(T7_AUDIO, 0), }; +static void meson_secure_pwrc_remove_domain(void *data) +{ + pm_genpd_remove(data); +} + +static void meson_secure_pwrc_remove_subdomain(void *data) +{ + struct meson_secure_pwrc_domain *dom = data; + + pm_genpd_remove_subdomain(&dom->pwrc->domains[dom->parent].base, &dom->base); +} + +static void meson_secure_pwrc_remove(struct platform_device *pdev) +{ + of_genpd_del_provider(pdev->dev.of_node); +} + static int meson_secure_pwrc_probe(struct platform_device *pdev) { - int i; + int i, ret; struct device_node *sm_np; struct meson_secure_pwrc *pwrc; const struct meson_secure_pwrc_domain_data *match; @@ -453,7 +470,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev) if (match->domains[i].is_off(dom) && (dom->base.flags & GENPD_FLAG_ALWAYS_ON)) meson_secure_pwrc_on(&dom->base); - pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom)); + ret = pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom)); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_domain, + &dom->base); + if (ret) + return ret; pwrc->xlate.domains[i] = &dom->base; } @@ -464,7 +487,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev) if (!match->domains[i].name || match->domains[i].parent == PWRC_NO_PARENT) continue; - pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base); + ret = pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_subdomain, + &dom[i]); + if (ret) + return ret; } return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate); @@ -567,6 +596,7 @@ MODULE_DEVICE_TABLE(of, meson_secure_pwrc_match_table); static struct platform_driver meson_secure_pwrc_driver = { .probe = meson_secure_pwrc_probe, + .remove = meson_secure_pwrc_remove, .driver = { .name = "meson_secure_pwrc", .of_match_table = meson_secure_pwrc_match_table, -- 2.43.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-28 9:56 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 11:33 [PATCH 0/2] pmdomain: amlogic: Add teardown for EE and secure power domains Tian Xuechen 2026-11-27 11:33 ` Tian Xuechen 2026-11-27 11:33 ` [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider Tian Xuechen 2026-11-27 11:33 ` Tian Xuechen 2026-11-27 11:44 ` sashiko-bot 2026-11-28 9:56 ` Tian Xuechen 2026-11-27 11:33 ` [PATCH 2/2] pmdomain: amlogic: Tear down secure " Tian Xuechen 2026-11-27 11:33 ` Tian Xuechen
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.