From: Jesse Casco <jesse.casco@gmail.com>
To: Bjorn Andersson <andersson@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: Abel Vesa <abelvesa@kernel.org>,
Herman van Hazendonk <github.com@herrie.org>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] clk: qcom: gdsc: unwind power domains when registration fails
Date: Tue, 10 Nov 2026 12:33:54 -0500 [thread overview]
Message-ID: <20261110173354.41274-1-jesse.casco@gmail.com> (raw)
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
reply other threads:[~2026-11-10 17:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110173354.41274-1-jesse.casco@gmail.com \
--to=jesse.casco@gmail.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=github.com@herrie.org \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=vladimir.zapolskiy@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®