* [PATCH] clk: qcom: gdsc: unwind power domains when registration fails
@ 2026-11-10 17:33 Jesse Casco
0 siblings, 0 replies; only message in thread
From: Jesse Casco @ 2026-11-10 17:33 UTC (permalink / raw)
To: Bjorn Andersson, Stephen Boyd, Brian Masney, Jerome Brunet
Cc: Abel Vesa, Herman van Hazendonk, Vladimir Zapolskiy,
linux-arm-msm, linux-clk, linux-kernel
gdsc_register() leaves the power domains it has already initialized
registered with genpd when a later gdsc_init() or
of_genpd_add_provider_onecell() call fails. Callers only install their
gdsc_unregister() devm action after gdsc_register() returns success, so
nothing removes those domains, and a later probe attempt initializes
the same static struct generic_pm_domain objects again while they are
still on the genpd list.
Commit 86b23609d5e1 ("clk: qcom: gdsc: tear down per-domain genpds in
gdsc_unregister()") made the unregister path remove the domains, and
commit 16ba98dace9e ("clk: qcom: gdsc: Fix error path on registration
of multiple pm subdomains") fixed the subdomain part of the
registration error path. Make the rest of that error path match
gdsc_unregister(): when the provider cannot be added, remove all
subdomains and domains, and when gdsc_init() fails, remove the domains
initialized before it.
Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs")
Signed-off-by: Jesse Casco <jesse.casco@gmail.com>
---
Tested in QEMU on a 7.3-rc5 tree, running the real gdsc.c and genpd
with a synthetic DT and fake registers, with failures injected at the
first, middle and last gdsc_init(), in subdomain registration and in
provider registration, plus sparse arrays, explicit parents, a device
parent and a pd_list (52 cases). 36 of the 52 cases failed the
cleanup checks before this patch; all 52 pass with it.
Registering the same objects again after a failed attempt still
reports an existing kobject (-EEXIST), with or without this patch;
that looks like a separate genpd lifecycle issue.
drivers/clk/qcom/gdsc.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
index be9c14e..8739293 100644
--- a/drivers/clk/qcom/gdsc.c
+++ b/drivers/clk/qcom/gdsc.c
@@ -647,7 +647,7 @@ int gdsc_register(struct gdsc_desc *desc,
scs[i]->rcdev = rcdev;
ret = gdsc_init(scs[i]);
if (ret)
- return ret;
+ goto err_pm_domain_remove;
data->domains[i] = &scs[i]->pd;
}
@@ -666,10 +666,21 @@ int gdsc_register(struct gdsc_desc *desc,
goto err_pm_subdomain_remove;
}
- return of_genpd_add_provider_onecell(dev->of_node, data);
+ ret = of_genpd_add_provider_onecell(dev->of_node, data);
+ if (ret)
+ goto err_pm_subdomain_remove;
+
+ return 0;
err_pm_subdomain_remove:
gdsc_pm_subdomain_remove(desc, i);
+ i = num;
+
+err_pm_domain_remove:
+ while (i--) {
+ if (scs[i])
+ pm_genpd_remove(&scs[i]->pd);
+ }
return ret;
}
--
2.56.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-10 17:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 17:33 [PATCH] clk: qcom: gdsc: unwind power domains when registration fails Jesse Casco
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.