From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: daniel.lezcano@oss.qualcomm.com
Cc: andersson@kernel.org,
Rajendra Nayak <rajendra.nayak@oss.qualcomm.com>,
Amit Kucheria <amitk@kernel.org>,
Thara Gopinath <thara.gopinath@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
linux-pm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL
DRIVER),
linux-arm-msm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL
DRIVER), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 1/3] thermal/drivers/qcom/tsens: Release parent resources on probe failure
Date: Wed, 21 Oct 2026 10:57:46 +0200 [thread overview]
Message-ID: <20261021085749.3786101-1-daniel.lezcano@oss.qualcomm.com> (raw)
On legacy MSM8960/APQ8064 device trees without a separate TSENS child
node, the Global Clock Controller (GCC) driver creates a qcom-tsens
platform device without an OF node. TSENS consequently uses the parent
device for firmware lookups and managed resource allocations.
If probing fails, including calibration returning -EPROBE_DEFER, the
driver core releases only the child device's managed resources.
Allocations attached to the parent remain, accumulating across repeated
probe attempts.
Wrap the parent-bound allocations in a devres group and register a
cleanup action on the TSENS child. This releases the resources on probe
failure and unbind while preserving legacy firmware lookups. Keep the
group handling in a probe wrapper so the existing initialization path
remains self-contained.
Fixes: 9066073c6c27 ("thermal: qcom: tsens: Add a skeletal TSENS drivers")
Closes: https://sashiko.dev/#/bug/linux-7dc6dad0-c471-47ca-b493-8402752cf13a
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Cc: Rajendra Nayak <rajendra.nayak@oss.qualcomm.com>
---
drivers/thermal/qcom/tsens.c | 37 +++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index b5ec70201e2f..4f69ce4976d9 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1374,7 +1374,7 @@ static int tsens_register(struct tsens_priv *priv)
return ret;
}
-static int tsens_probe(struct platform_device *pdev)
+static int tsens_probe_common(struct platform_device *pdev)
{
int ret, i;
struct device *dev;
@@ -1452,6 +1452,41 @@ static int tsens_probe(struct platform_device *pdev)
return ret;
}
+static void tsens_release_resources(void *data)
+{
+ struct device *dev = data;
+
+ devres_release_group(dev->parent, dev);
+}
+
+static int tsens_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ int ret;
+
+ /*
+ * DT-backed devices own their managed resources directly. Legacy devices
+ * created by the Global Clock Controller (GCC) driver have no OF node and
+ * use the parent's firmware data and managed resources instead. Group
+ * those resources so the child releases them on probe failure or unbind.
+ */
+ if (dev->of_node)
+ return tsens_probe_common(pdev);
+
+ /* Tie resources allocated on the parent to the TSENS lifetime. */
+ if (!devres_open_group(dev->parent, dev, GFP_KERNEL))
+ return -ENOMEM;
+
+ ret = devm_add_action_or_reset(dev, tsens_release_resources, dev);
+ if (ret)
+ return ret;
+
+ ret = tsens_probe_common(pdev);
+ devres_close_group(dev->parent, dev);
+
+ return ret;
+}
+
static void tsens_remove(struct platform_device *pdev)
{
struct tsens_priv *priv = platform_get_drvdata(pdev);
--
2.43.0
next reply other threads:[~2026-10-21 8:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 8:57 Daniel Lezcano [this message]
2026-10-21 8:57 ` [PATCH 2/3] thermal/drivers/qcom/tsens: Validate the sensor count before initialization Daniel Lezcano
2026-10-21 8:57 ` [PATCH 3/3] thermal/drivers/qcom/tsens: Disable hardware on probe failure Daniel Lezcano
2026-10-21 10:27 ` Konrad Dybcio
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=20261021085749.3786101-1-daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=amitk@kernel.org \
--cc=andersson@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rajendra.nayak@oss.qualcomm.com \
--cc=rui.zhang@intel.com \
--cc=thara.gopinath@gmail.com \
/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®