From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5DA33F1AC6; Sat, 12 Sep 2026 09:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789206684; cv=none; b=HbynbE5X479KHSPNept1EPsSFEzzbY9Y5asUIpZW4ZGZeNzCcC5SMW7J7kCy3dyeruPGV2Dikuo89YnyhkXkXKnRxYDdJ6AkNVGandjeHKJg7ml//3O6sft1qSu0cvxN1NB2+l9sb4xLXZafgrWLz7cyCt/dGLim0vbppyzZlL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789206684; c=relaxed/simple; bh=3hFwarC1wODsQWEaVOPcjdaUK1kV3Xcg72AvuA+iB7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DEERSatIW6evzF01/O9+Jn+eXpkrwdQqLYR4CFfwe+GaV+MlQqNisKai3AWrfgGVn13Vx2jEFcRoO72C2UXaBQ1LTD8sLFv5zGvdCAKEdOIbYASxVMun0OPpyVFI52GYEfgKmQV0e2Bcq+YYnugNIrj22d2zxFu+vI5BzSq4YIQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Yq8t7zqY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Yq8t7zqY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6AAF1F000FF; Sat, 12 Sep 2026 09:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789206680; bh=dWt9QwOf475QWop2qLBqroi7mV7LDGoJyl+Rf6duak8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Yq8t7zqYKYYjwcIxG6G+7YtbE7dUGzsTRODl1jc6lvbQ7snT5PcOSu3gPQQ6nkGDa YE8m07p832XaLFx5mR1JzEWFVVATlQqSsFYjDG8mShWILSur1hV8iAGh9q/2L+HJYA NSovhvFvvwmMz0laMaF1Q8yA+MjZWnhuf+PgFNr4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Herman van Hazendonk , Dmitry Baryshkov , Bjorn Andersson , Sasha Levin Subject: [PATCH 6.18 0257/1518] clk: qcom: gdsc: tear down per-domain genpds in gdsc_unregister() Date: Sat, 12 Sep 2026 08:40:26 +0200 Message-ID: <20260912065629.296997890@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Herman van Hazendonk [ Upstream commit 86b23609d5e17a770d03037e53c6a443e742a6e6 ] gdsc_unregister() removes the OF provider entry and tears down the parent/subdomain wiring, but never calls pm_genpd_remove() on the individual generic_pm_domain structures registered by gdsc_init(): void gdsc_unregister(struct gdsc_desc *desc) { struct device *dev = desc->dev; size_t num = desc->num; gdsc_pm_subdomain_remove(desc, num); of_genpd_del_provider(dev->of_node); } That leaves dangling entries on the global gpd_list. After a provider unbind/rebind cycle (deferred-probe replay during early boot, real module unload of a clk driver that owns GDSCs, or an OF-overlay tear- down) the next gdsc_init() will end up trying to re-register a name that is still in the list and pm_genpd_init() returns -EEXIST. While we are here, flip the order so the consumer-facing OF provider entry is the first thing removed -- otherwise a fresh of_genpd_get_from_provider() call racing with the teardown could attach to a domain that is mid-removal. Iterate the scs[] array and pm_genpd_remove() each registered domain after the subdomain links are torn down. The regulators stay devm- managed (devm_regulator_get_optional() in gdsc_register()), so the release happens automatically when the underlying device is unbound; just the genpd accounting needs to be undone explicitly. Signed-off-by: Herman van Hazendonk Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs") Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20260602140934.796697-4-github.com@herrie.org Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/clk/qcom/gdsc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index a80a489763edc..71826ccbd9bd1 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -645,10 +645,18 @@ int gdsc_register(struct gdsc_desc *desc, void gdsc_unregister(struct gdsc_desc *desc) { struct device *dev = desc->dev; + struct gdsc **scs = desc->scs; size_t num = desc->num; + int i; - gdsc_pm_subdomain_remove(desc, num); of_genpd_del_provider(dev->of_node); + gdsc_pm_subdomain_remove(desc, num); + + for (i = 0; i < num; i++) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } } /* -- 2.53.0