Re: [PATCH v1 4/8] thermal: qcom: add qmi-cooling driver

From: Dmitry Baryshkov

Date: Wed Dec 31 2025 - 01:33:07 EST


On 31/12/2025 08:28, Gaurav Kohli wrote:

On 12/24/2025 1:19 AM, Dmitry Baryshkov wrote:
On Tue, Dec 23, 2025 at 06:02:23PM +0530, Gaurav Kohli wrote:
From: Casey Connolly <casey.connolly@xxxxxxxxxx>

The Thermal Mitigation Device (TMD) service exposes various platform
specific thermal mitigations available on remote subsystems (ie the
modem and cdsp). The service is exposed via the QMI messaging
interface, usually over the QRTR transport.

Qualcomm QMI-based TMD cooling devices are used to mitigate thermal
conditions across multiple remote subsystems. These devices operate
based on junction temperature sensors (TSENS) associated with thermal
zones for each subsystem.

Co-developed-by: Gaurav Kohli <gaurav.kohli@xxxxxxxxxxxxxxxx>
Signed-off-by: Casey Connolly <casey.connolly@xxxxxxxxxx>
Signed-off-by: Gaurav Kohli <gaurav.kohli@xxxxxxxxxxxxxxxx>
---
  drivers/soc/qcom/Kconfig           |  13 +
  drivers/soc/qcom/Makefile          |   1 +
  drivers/soc/qcom/qmi-cooling.c     | 498 +++++++++++++++++++++++++++++
  drivers/soc/qcom/qmi-cooling.h     | 428 +++++++++++++++++++++++++
  drivers/thermal/qcom/qmi-cooling.h | 428 +++++++++++++++++++++++++
  5 files changed, 1368 insertions(+)
  create mode 100644 drivers/soc/qcom/qmi-cooling.c
  create mode 100644 drivers/soc/qcom/qmi-cooling.h
  create mode 100644 drivers/thermal/qcom/qmi-cooling.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 2caadbbcf830..905a24b42fe6 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -124,6 +124,19 @@ config QCOM_PMIC_GLINK
        Say yes here to support USB-C and battery status on modern Qualcomm
        platforms.
+config QCOM_QMI_COOLING
+    tristate "Qualcomm QMI cooling drivers"
+    depends on QCOM_RPROC_COMMON
+    depends on ARCH_QCOM || COMPILE_TEST
+    select QCOM_QMI_HELPERS
+    help
+       This enables the remote subsystem cooling devices. These cooling
+       devices will be used by Qualcomm chipset to place various remote
+       subsystem mitigations like remote processor passive mitigation,
+       remote subsystem voltage restriction at low temperatures etc.
+       The QMI cooling device will interface with remote subsystem
+       using Qualcomm remoteproc interface.
+
  config QCOM_QMI_HELPERS
      tristate
      depends on NET
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index b7f1d2a57367..b6728f54944b 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_PMIC_GLINK)    += pmic_glink.o
  obj-$(CONFIG_QCOM_PMIC_GLINK)    += pmic_glink_altmode.o
  obj-$(CONFIG_QCOM_PMIC_PDCHARGER_ULOG)    += pmic_pdcharger_ulog.o
  CFLAGS_pmic_pdcharger_ulog.o    :=  -I$(src)
+obj-$(CONFIG_QCOM_QMI_COOLING) += qmi-cooling.o
  obj-$(CONFIG_QCOM_QMI_HELPERS)    += qmi_helpers.o
  qmi_helpers-y    += qmi_encdec.o qmi_interface.o
  obj-$(CONFIG_QCOM_RAMP_CTRL)    += ramp_controller.o
diff --git a/drivers/soc/qcom/qmi-cooling.c b/drivers/soc/qcom/qmi- cooling.c
new file mode 100644
index 000000000000..1a6afcb96bf6
--- /dev/null
+++ b/drivers/soc/qcom/qmi-cooling.c
@@ -0,0 +1,498 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017, The Linux Foundation
+ * Copyright (c) 2025, Linaro Limited
+ *
+ * QMI Thermal Mitigation Device (TMD) client driver.
+ * This driver provides an in-kernel client to handle hot and cold thermal
+ * mitigations for remote subsystems (modem and DSPs) running the TMD service.
+ * It doesn't implement any handling of reports from remote subsystems.
+ */
+
+#include <linux/cleanup.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/net.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/remoteproc/qcom_rproc.h>
+#include <linux/remoteproc_cooling.h>
+#include <linux/slab.h>
+#include <linux/soc/qcom/qmi.h>
+#include <linux/thermal.h>
+
+#include "qmi-cooling.h"
+
+#define MODEM0_INSTANCE_ID    0x0
+#define ADSP_INSTANCE_ID    0x1
+#define CDSP_INSTANCE_ID    0x43
Will CDSP1 also use instance ID? What are instance IDs for GPDSP?


In Leman's there are two different cdsp subsytem, i will add new instance id for that also.

What is GPdsp, you mean gpu ?


No, I mean general purpose DSP aka GPDSP aka GDSP.

--
With best wishes
Dmitry