Properly remove registered genpds. Also remove the provider before breaking parent/child links, so that the system is consistent at remove time. Fixes: c2c7f0a47493 ("clk: qcom: gdsc: Add support for hierarchical power domains") Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs") Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> --- drivers/clk/qcom/gdsc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 241186d9d08c..9e16f234ce6c 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -475,14 +475,26 @@ void gdsc_unregister(struct gdsc_desc *desc) struct gdsc **scs = desc->scs; size_t num = desc->num; - /* Remove subdomains */ + /* + * Remove provider first so that we can remove the genpds without + * worrying about consumers getting them during the removal process. + */ + of_genpd_del_provider(dev->of_node); + + /* Break subdomain relationship */ for (i = 0; i < num; i++) { if (!scs[i]) continue; if (scs[i]->parent) pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); } - of_genpd_del_provider(dev->of_node); + + /* And finally remove domains themselves */ + for (i = 0; i < num; i++) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } } /* -- 2.30.2