From: sashiko-bot@kernel.org
To: "Gaurav Kohli" <gaurav.kohli@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 04/10] remoteproc: qcom: pas: add support for TMD thermal cooling devices
Date: Fri, 03 Jul 2026 05:22:04 +0000 [thread overview]
Message-ID: <20260703052205.2A7A61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703-qmi-tmd-v4-4-3882189c1f83@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] A race condition between `qmi_tmd_exit` and `qmi_tmd_new_server` can lead to a use-after-free of `qmi_tmd_cli`.
- [High] TMD sysfs cooling device callbacks can race with teardown, leading to use-after-free on the QMI transaction IDR.
- [High] Data race on `tmd->cur_state` during QMI server reconnect can result in the remote processor receiving an outdated cooling state.
- [Medium] QCOM_Q6V5_PAS unconditionally selects QCOM_QMI_TMD, which lacks a COMPILE_TEST dependency and indirectly depends on NET, leading to Kconfig unmet dependency warnings and potential build failures.
--
commit 770900471517951fb204f7c5cc18bd57f37681a8
Author: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
remoteproc: qcom: pas: add support for TMD thermal cooling devices
This commit registers Thermal Mitigation Devices (TMDs) for PAS-managed
remote processors to enable thermal throttling through QMI. It allows
the thermal framework to request mitigation when remote subsystems
contribute to thermal pressure.
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index c521c744e7dbe..4fb2163c06556 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -228,6 +228,7 @@ config QCOM_Q6V5_PAS
> select QCOM_PIL_INFO
> select QCOM_MDT_LOADER
> select QCOM_Q6V5_COMMON
> + select QCOM_QMI_TMD
[Severity: Medium]
Does this unconditionally select QCOM_QMI_TMD without fulfilling its
underlying ARCH_QCOM and NET dependencies?
According to Kconfig subsystem guidelines, selecting a config symbol without
inheriting its dependencies can cause Kconfig unmet dependency warnings and
potential build failures on architectures missing networking infrastructure
or ARCH_QCOM.
> select QCOM_RPROC_COMMON
> select QCOM_SCM
> help
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 808e9609988d3..a4756a449e64b 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
[ ... ]
> @@ -730,6 +749,66 @@ static void qcom_pas_unassign_memory_region(struct qcom_pas *pas)
[ ... ]
> +static int qcom_pas_setup_tmd(struct qcom_pas *pas, const struct qcom_pas_data *desc)
> +{
[ ... ]
> + tmd_inst = qmi_tmd_init(pas->dev, desc->tmd_instance_id, tmd_names, desc->num_tmd);
[Severity: High]
Can a data race on tmd->cur_state during a QMI server reconnect result in the
remote processor receiving an outdated cooling state?
Looking at qmi_tmd_register() in drivers/soc/qcom/qmi_tmd.c:
if (tmd->cdev)
return qmi_tmd_send_state_request(tmd, tmd->cur_state);
The current state is read locklessly without holding cdev->lock. This
introduces a data race with concurrent sysfs updates to the cooling device's
state, which could result in sending an outdated mitigation state over QMI.
> + if (IS_ERR(tmd_inst)) {
> + ret = PTR_ERR(tmd_inst);
[ ... ]
> @@ -852,12 +931,21 @@ static int qcom_pas_probe(struct platform_device *pdev)
[ ... ]
> +remove_setup_tmd:
> + if (pas->tmd_inst)
> + qmi_tmd_exit(pas->tmd_inst);
[Severity: High]
Could a race condition between qmi_tmd_exit() and qmi_tmd_new_server() lead
to a use-after-free of qmi_tmd_cli?
Looking at qmi_tmd_exit() in drivers/soc/qcom/qmi_tmd.c:
cancel_work_sync(&qmi_tmd_cli->svc_arrive_work);
qmi_handle_release(&qmi_tmd_cli->handle);
The work queue is canceled before shutting down incoming QMI notifications via
qmi_handle_release(). If qmi_tmd_new_server() is invoked concurrently, it
could re-queue svc_arrive_work on the global system_highpri_wq, which then
executes after qmi_tmd_cli has been freed.
[Severity: High]
Can TMD sysfs cooling device callbacks race with teardown, leading to a
use-after-free on the QMI transaction IDR?
In qmi_tmd_exit():
qmi_handle_release(&qmi_tmd_cli->handle);
qmi_tmd_unregister(qmi_tmd_cli);
The QMI handle (and its IDR) is released before qmi_tmd_unregister() removes
the thermal cooling devices from sysfs. Meanwhile, connection_active is still
left as true. A concurrent sysfs write to the cur_state file exactly when the
driver is being removed would attempt to call idr_alloc_cyclic() on the
destroyed IDR.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260703-qmi-tmd-v4-0-3882189c1f83@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-07-03 5:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 5:03 [PATCH v4 00/10] Add support for Qualcomm remoteproc subsystem cooling Gaurav Kohli
2026-07-03 5:03 ` [PATCH v4 01/10] dt-bindings: firmware: qcom: tmd: add TMD device type constants Gaurav Kohli
2026-07-03 7:47 ` Krzysztof Kozlowski
2026-07-03 10:14 ` Gaurav Kohli
2026-07-03 7:52 ` Krzysztof Kozlowski
2026-07-03 10:31 ` Gaurav Kohli
2026-07-03 7:53 ` Konrad Dybcio
2026-07-03 14:13 ` Gaurav Kohli
2026-07-03 15:42 ` Dmitry Baryshkov
2026-07-03 5:03 ` [PATCH v4 02/10] dt-bindings: remoteproc: qcom,pas: add #cooling-cells property Gaurav Kohli
2026-07-03 5:15 ` sashiko-bot
2026-07-03 7:49 ` Krzysztof Kozlowski
2026-07-03 5:03 ` [PATCH v4 03/10] soc: qcom: Add QMI TMD support for remote thermal mitigation Gaurav Kohli
2026-07-03 5:17 ` sashiko-bot
2026-07-03 8:03 ` Krzysztof Kozlowski
2026-07-03 18:09 ` Julian Braha
2026-07-03 5:03 ` [PATCH v4 04/10] remoteproc: qcom: pas: add support for TMD thermal cooling devices Gaurav Kohli
2026-07-03 5:22 ` sashiko-bot [this message]
2026-07-03 7:56 ` Krzysztof Kozlowski
2026-07-03 5:03 ` [PATCH v4 05/10] remoteproc: qcom_q6v5_pas: enable QMI TMD cooling support Gaurav Kohli
2026-07-03 5:23 ` sashiko-bot
2026-07-03 5:03 ` [PATCH v4 06/10] arm64: dts: qcom: kodiak: Enable CDSP & Modem cooling Gaurav Kohli
2026-07-03 7:51 ` Krzysztof Kozlowski
2026-07-03 15:48 ` Dmitry Baryshkov
2026-07-03 5:03 ` [PATCH v4 07/10] arm64: dts: qcom: lemans: Enable CDSP cooling Gaurav Kohli
2026-07-03 5:18 ` sashiko-bot
2026-07-03 5:03 ` [PATCH v4 08/10] arm64: dts: qcom: talos: " Gaurav Kohli
2026-07-03 5:03 ` [PATCH v4 09/10] arm64: dts: qcom: monaco: " Gaurav Kohli
2026-07-03 5:03 ` [PATCH v4 10/10] arm64: dts: qcom: hamoa: " Gaurav Kohli
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=20260703052205.2A7A61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gaurav.kohli@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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