From nobody Mon Jun 8 04:12:02 2026 Received: from outbound10.mail.transip.nl (outbound10.mail.transip.nl [136.144.136.17]) (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 068643E172E; Tue, 2 Jun 2026 14:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.144.136.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409383; cv=none; b=rkOvTGhXMMr4hLVEsxxS+Sx/6JK2uVtlY4gNqmxvXjQXwEfg9BLHNtsm/4dUiGG3E8+aoMaUeLPuEdEkbNmtCDhU6UYOlsy3hJL4cHdRncOlvRlsin4XvFXQNgIpaxPkSja1sKVoJmTMb1ykPgIkmX4gE9t1kg1pCKz9auvCrXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409383; c=relaxed/simple; bh=WqR7fnsz1oInQlxyyk6SblEn2J3Gti7V1XKGVgPZCOk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pjk/gwSko0saizozMWSMdN7LZER9dVLhzrS6gBC1njy9sDqrakcDMsHMTbpNMnc6fFUqvSIL6b9zbFdx2mADAfXHp5xS9PBYLB8cwKVI2MRRmHzs+4a/RWj5SJR6Rq2XiAKP6EslT3JnCsW+YvjVsfkhRQxqlo0qoTXtKBUVl7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org; spf=pass smtp.mailfrom=herrie.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b=TuTZ4PtQ; arc=none smtp.client-ip=136.144.136.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herrie.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b="TuTZ4PtQ" Received: from submission2.mail.transip.nl (unknown [10.100.4.71]) by outbound10.mail.transip.nl (Postfix) with ESMTP id 4gVCPr1KnNzTPNW2; Tue, 2 Jun 2026 16:09:36 +0200 (CEST) Received: from herrie-desktop.. (180-93-184-31.ftth.glasoperator.nl [31.184.93.180]) by submission2.mail.transip.nl (Postfix) with ESMTPA id 4gVCPq4B6QzJjhY2; Tue, 2 Jun 2026 16:09:35 +0200 (CEST) From: Herman van Hazendonk To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Herman van Hazendonk Subject: [PATCH 1/3] clk: qcom: gdsc: propagate gdsc_check_status() errors from gdsc_poll_status Date: Tue, 2 Jun 2026 16:09:32 +0200 Message-ID: <20260602140934.796697-2-github.com@herrie.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602140934.796697-1-github.com@herrie.org> References: <20260602140934.796697-1-github.com@herrie.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: ClueGetter at submission2.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=herrie.org; t=1780409375; h=from:subject:to:cc: references:in-reply-to:date:mime-version; bh=kfm4s6J4MM+FQLTeg/mMimRvdRuyF/Yx7wGvlUw9pFM=; b=TuTZ4PtQghYWZ0ykmS8f0g43VhKMAa2u5fZQNwdPVHXlE6PBCzZuPUZluienYgGVIy4CCC 0m/vfj6nsgcuFQgwW3CyHArag2h8qrOin6c6JaotIkzgggpA/JYesTcn5+MnZl/SB82cow bolTU3VVUY3vIZbKjHZ483sYaGkTgFmlYbA3KA/fZ4Wss2/1V/jhnw52xLM+RiDUJbcMpP S2sfeMXRw6muhn5ssQSofDBu12LgWA4CkotfyCgm/fmzWN01x2mvgyQ8Um4Jb99i6MWYrC CbWMllKGAtLhUlbZatJ0OzezR5pQcygVWeY2b2ocTutPpGqBMT71yVP86+1CQg== X-Report-Abuse-To: abuse@transip.nl Content-Type: text/plain; charset="utf-8" gdsc_check_status() returns negative errno when the underlying regmap_read() fails -- e.g. when a parent regmap dies during system suspend, a CSR is removed by an HW debug tool, or the bus controller goes into protection. gdsc_poll_status() treats the result as a plain boolean ("is the GDSC in the requested state?"), so any negative error return is truncated to "true" and the poll exits with success even though the rail's real state is unknown: do { if (gdsc_check_status(sc, status)) return 0; } while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US); if (gdsc_check_status(sc, status)) return 0; return -ETIMEDOUT; This silently misleads gdsc_toggle_logic() (which writes/un-writes SW_COLLAPSE on the strength of the poll succeeding) and the gdsc_init() sync path (which assumes the readback represents real silicon state). Latch the return value, propagate negative errno immediately, and only treat a strictly-positive value as "reached the target state". Make the same change in the post-timeout final check so a regmap that comes back after the deadline does not silently degrade to -ETIMEDOUT. Signed-off-by: Herman van Hazendonk --- drivers/clk/qcom/gdsc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 95aa07120245..b9b47f584f6d 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -103,14 +103,21 @@ static int gdsc_hwctrl(struct gdsc *sc, bool en) static int gdsc_poll_status(struct gdsc *sc, enum gdsc_status status) { ktime_t start; + int ret; =20 start =3D ktime_get(); do { - if (gdsc_check_status(sc, status)) + ret =3D gdsc_check_status(sc, status); + if (ret < 0) + return ret; + if (ret) return 0; } while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US); =20 - if (gdsc_check_status(sc, status)) + ret =3D gdsc_check_status(sc, status); + if (ret < 0) + return ret; + if (ret) return 0; =20 return -ETIMEDOUT; --=20 2.43.0 From nobody Mon Jun 8 04:12:02 2026 Received: from outbound2.mail.transip.nl (outbound2.mail.transip.nl [149.210.149.73]) (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 9D32D3E8C6F; Tue, 2 Jun 2026 14:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=149.210.149.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409383; cv=none; b=LwNTDAnjQZqWRC5F0HmaPU/wQ/lqYLxXbc225/3ptcC6zHNuf/tKZ1K+0JUFx+c/acPA+RbA1hE9E/slGApgCaQoXETp8IWqYDyvwCiOdQ7ooJaY6FhNd58XIcYyb1WxmqaXYccnQIRe4Qw+q9/alQXpJ5r5L1HX2SvaRqrff5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409383; c=relaxed/simple; bh=jEYAFMVR4q9BFgvwfZI1gidudx/a0P4jlxW3mjA6/74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LEXNg+jW8CLhxOPqp+RAW8yzZXzg9DMKceUCP+xh18w8njZK5AcrunD7EUuVM5i2KQLhu2JUZKKfOqq3/MtpjsUfJSU+GHW2kDrgdtBryLXUWNYoEQuVUPK2ETgVDsw5ymO4VaNVmuSQS7Lnik8YEn3zzhib3dK09S9JAiVi7GU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org; spf=pass smtp.mailfrom=herrie.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b=af23kXT6; arc=none smtp.client-ip=149.210.149.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herrie.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b="af23kXT6" Received: from submission2.mail.transip.nl (unknown [10.100.4.71]) by outbound2.mail.transip.nl (Postfix) with ESMTP id 4gVCPr5f4lzYdX5; Tue, 2 Jun 2026 16:09:36 +0200 (CEST) Received: from herrie-desktop.. (180-93-184-31.ftth.glasoperator.nl [31.184.93.180]) by submission2.mail.transip.nl (Postfix) with ESMTPA id 4gVCPr1SXczJjhXt; Tue, 2 Jun 2026 16:09:36 +0200 (CEST) From: Herman van Hazendonk To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Herman van Hazendonk Subject: [PATCH 2/3] clk: qcom: gdsc: propagate gdsc_enable() failure for ALWAYS_ON domains Date: Tue, 2 Jun 2026 16:09:33 +0200 Message-ID: <20260602140934.796697-3-github.com@herrie.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602140934.796697-1-github.com@herrie.org> References: <20260602140934.796697-1-github.com@herrie.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: ClueGetter at submission2.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=herrie.org; t=1780409376; h=from:subject:to:cc: references:in-reply-to:date:mime-version; bh=QO4+t0ZHSxRITTqc5+EzQDA+h8c/0AsbUZFLsaOlT9o=; b=af23kXT6WsDbfC67lDZsPUNBaxZR98uvBYimfdc0cVVUtxAoflaaK2QH4OHKruiLgnStWJ aF49q109S62X9NLAbSKVxQuwkYzwuJSyMwqIp81w9HUs6rcfk9XWmSZJrqJxyDzdB5yctL 8/GTaPckf5AGjJz6ns0BOzWmctoo5fIK/mk1xBTirm+UMyfWSWPmJvqCqxhhLyEeAFfn0d +iF+Y8NDmlogoIaNzB9tCLgl7bJnRLx8aNibU1V2dNjI3O+fefc/9+mHTEHl4Qun1JNg3X E0ZVQvWKbxjHVELUa48l7VY8au52Mfo1l5zCwKP8foNQo1Ii++BZ0pCPKYGr3Q== X-Report-Abuse-To: abuse@transip.nl Content-Type: text/plain; charset="utf-8" GENPD_FLAG_ALWAYS_ON requires the underlying domain to be on at genpd_init() time -- the framework will refuse to register the domain otherwise. When the cold readback in gdsc_init() finds an ALWAYS_ON GDSC powered down, the driver tries to bring it back up: } else if (sc->flags & ALWAYS_ON) { /* If ALWAYS_ON GDSCs are not ON, turn them ON */ gdsc_enable(&sc->pd); on =3D true; } but discards the return value: if gdsc_enable() fails (regmap write error, the long-form sequence's status poll times out, or the HW_CTRL hand-off errors) the code still sets on=3Dtrue and falls through to pm_genpd_init(..., !on) -- which then registers the domain in the ON state and sets GENPD_FLAG_ALWAYS_ON, even though the silicon is actually off. Subsequent consumer probes will see genpd report "on" while accessing dead registers and hang or read garbage. Catch the failure and surface it: returning the error from gdsc_init() makes the provider probe fail with the underlying errno, which propagates to consumers as -EPROBE_DEFER (or fatal if the hardware really is broken) rather than silently lying about the rail state. Signed-off-by: Herman van Hazendonk --- drivers/clk/qcom/gdsc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index b9b47f584f6d..a80a489763ed 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -481,7 +481,9 @@ static int gdsc_init(struct gdsc *sc) =20 } else if (sc->flags & ALWAYS_ON) { /* If ALWAYS_ON GDSCs are not ON, turn them ON */ - gdsc_enable(&sc->pd); + ret =3D gdsc_enable(&sc->pd); + if (ret) + return ret; on =3D true; } =20 --=20 2.43.0 From nobody Mon Jun 8 04:12:02 2026 Received: from outbound5.mail.transip.nl (outbound5.mail.transip.nl [136.144.136.9]) (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 AAEAF3E9F76; Tue, 2 Jun 2026 14:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.144.136.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409392; cv=none; b=B0fkUyWsN3wDaZjNytuMUmSzXr6yLp8W8zby+/5zcfZofESuEiTL/vAxFHtn9AFmMGrktgy/XONwElnmFDm91e1wpZaaqXJ6bi9VawjB84jABaUM8kAlbp3IsCR0/Cx/OfO6KiH1PLHM0ItELHtoLnCpj30lBNR1/gmV0P5hT1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780409392; c=relaxed/simple; bh=rYjHVseEk7q2fuVN4PVp5fpkdyQd9XxI0lYktezqe6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iRwlb1Bq8a9nVpsAlk2Y3QiSzZF/+Jgod/WaLc5tfOJIzOL7pOqp5RwOU+l9crQe5r6gdx9RDDeGCAYv3rtOJ0yluxhjFTmddC29VbbHyXtEkl9LpEDW2Z8A+Q3DGXwmtcf9AtVK8QkTQCjSk1LVzmMj6CDQ0htrP9psaZDyYd8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org; spf=pass smtp.mailfrom=herrie.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b=dIm9qE+4; arc=none smtp.client-ip=136.144.136.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=herrie.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=herrie.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=herrie.org header.i=@herrie.org header.b="dIm9qE+4" Received: from submission2.mail.transip.nl (unknown [10.100.4.71]) by outbound5.mail.transip.nl (Postfix) with ESMTP id 4gVCPs3GJMzGr9F; Tue, 2 Jun 2026 16:09:37 +0200 (CEST) Received: from herrie-desktop.. (180-93-184-31.ftth.glasoperator.nl [31.184.93.180]) by submission2.mail.transip.nl (Postfix) with ESMTPA id 4gVCPr5qRSzJjhY1; Tue, 2 Jun 2026 16:09:36 +0200 (CEST) From: Herman van Hazendonk To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Herman van Hazendonk Subject: [PATCH 3/3] clk: qcom: gdsc: tear down per-domain genpds in gdsc_unregister() Date: Tue, 2 Jun 2026 16:09:34 +0200 Message-ID: <20260602140934.796697-4-github.com@herrie.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602140934.796697-1-github.com@herrie.org> References: <20260602140934.796697-1-github.com@herrie.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: ClueGetter at submission2.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=herrie.org; t=1780409377; h=from:subject:to:cc: references:in-reply-to:date:mime-version; bh=yxHvBRpBzJac8N/xBG8/ALRzjPpG+vDneOpPAWA20jg=; b=dIm9qE+46Q/dO/NMnSlT2bsToHGES41k/cgFGCfE8sRR/dTQzKus+cJnM3kA226GSN3wg2 l7fWF1A54w2XEDabU6pHjEYSmZH/sa0XBdbXaaFGBzI3zGDak3iO3fL3rPbMxrZqhZ4lwn 1WhHrKD+OFxqc6Kx1SXRdHFwRfl+RSCRZTCUZh5Z0AHulYXqO2H9GiEucSI2JYCI/Ei9Ju p5rbSfQY4PBPKBQxA8BDXPowSLbJKctLrJ7dXYwXKbscjfnLBnTwpkJSlHTeeLatkPXniN VOcGWee5Fm4SmlEj8YZrmpwWmibzBKAzg69E5eWvTxVl1TLH+x2dEyPOFPdbBg== X-Report-Abuse-To: abuse@transip.nl Content-Type: text/plain; charset="utf-8" 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 =3D desc->dev; size_t num =3D 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 --- 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 a80a489763ed..71826ccbd9bd 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 =3D desc->dev; + struct gdsc **scs =3D desc->scs; size_t num =3D desc->num; + int i; =20 - gdsc_pm_subdomain_remove(desc, num); of_genpd_del_provider(dev->of_node); + gdsc_pm_subdomain_remove(desc, num); + + for (i =3D 0; i < num; i++) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } } =20 /* --=20 2.43.0