Add a new generic driver for thermal cooling devices that control
remote processors (modem, DSP, etc.) through various communication
channels.
This driver provides an abstraction layer between the thermal
subsystem and vendor-specific remote processor communication
mechanisms.
Advantage of this to avoid duplicating vendor-specific logic
in the thermal subsystem and make it easier for different vendors
to plug in their own cooling mechanisms via callbacks.
Suggested-by: Amit Kucheria <amit.kucheria@oss.qualcomm.com>
Signed-off-by: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
---
MAINTAINERS | 7 ++
drivers/thermal/Kconfig | 10 ++
drivers/thermal/Makefile | 2 +
drivers/thermal/remoteproc_cooling.c | 143 +++++++++++++++++++++++++++
include/linux/remoteproc_cooling.h | 52 ++++++++++
5 files changed, 214 insertions(+)
create mode 100644 drivers/thermal/remoteproc_cooling.c
create mode 100644 include/linux/remoteproc_cooling.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 414f44093269..5ebc7819d2cf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26169,6 +26169,13 @@ F: drivers/thermal/cpufreq_cooling.c
F: drivers/thermal/cpuidle_cooling.c
F: include/linux/cpu_cooling.h
+THERMAL/REMOTEPROC_COOLING
+M: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
+L: linux-pm@vger.kernel.org
+S: Supported
+F: drivers/thermal/remoteproc_cooling.c
+F: include/linux/remoteproc_cooling.h
+
THERMAL/POWER_ALLOCATOR
M: Lukasz Luba <lukasz.luba@arm.com>
L: linux-pm@vger.kernel.org
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index b10080d61860..dfc52eed64de 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -229,6 +229,16 @@ config PCIE_THERMAL
If you want this support, you should say Y here.
+config REMOTEPROC_THERMAL
+ tristate "Remote processor cooling support"
+ help
+ This implements a generic cooling mechanism for remote processors
+ (modem, DSP, etc.) that allows vendor-specific implementations to
+ register thermal cooling devices and provide callbacks for thermal
+ mitigation.
+
+ If you want this support, you should say Y here.
+
config THERMAL_EMULATION
bool "Thermal emulation mode support"
help
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index bb21e7ea7fc6..ae747dde54fe 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -34,6 +34,8 @@ thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
thermal_sys-$(CONFIG_PCIE_THERMAL) += pcie_cooling.o
+thermal_sys-$(CONFIG_REMOTEPROC_THERMAL) += remoteproc_cooling.o
+
obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o k3_j72xx_bandgap.o
# platform thermal drivers
obj-y += broadcom/
diff --git a/drivers/thermal/remoteproc_cooling.c b/drivers/thermal/remoteproc_cooling.c
new file mode 100644
index 000000000000..f958efa691b3
--- /dev/null
+++ b/drivers/thermal/remoteproc_cooling.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Remote Processor Cooling Device
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#include <linux/err.h>
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/thermal.h>
+
+#define REMOTEPROC_PREFIX "rproc_"
+
+struct remoteproc_cooling_ops {
+ int (*get_max_level)(void *devdata, unsigned long *level);
+ int (*get_cur_level)(void *devdata, unsigned long *level);
+ int (*set_cur_level)(void *devdata, unsigned long level);
+};
+
+/**
+ * struct remoteproc_cdev - Remote processor cooling device
+ * @cdev: Thermal cooling device handle
+ * @ops: Vendor-specific operation callbacks
+ * @devdata: Private data for vendor implementation
+ * @np: Device tree node associated with this cooling device
+ * @lock: Mutex to protect cooling device operations
+ */
+struct remoteproc_cdev {
+ struct thermal_cooling_device *cdev;
+ const struct remoteproc_cooling_ops *ops;
+ void *devdata;
+ struct mutex lock;
+};
+
+/* Thermal cooling device callbacks */
+
+static int remoteproc_get_max_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ struct remoteproc_cdev *rproc_cdev = cdev->devdata;
+ int ret;
+
+ mutex_lock(&rproc_cdev->lock);
+ ret = rproc_cdev->ops->get_max_level(rproc_cdev->devdata, state);
+ mutex_unlock(&rproc_cdev->lock);
+
+ return ret;
+}
+
+static int remoteproc_get_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ struct remoteproc_cdev *rproc_cdev = cdev->devdata;
+ int ret;
+
+ mutex_lock(&rproc_cdev->lock);
+ ret = rproc_cdev->ops->get_cur_level(rproc_cdev->devdata, state);
+ mutex_unlock(&rproc_cdev->lock);
+
+ return ret;
+}
+
+static int remoteproc_set_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long state)
+{
+ struct remoteproc_cdev *rproc_cdev = cdev->devdata;
+ int ret;
+
+ mutex_lock(&rproc_cdev->lock);
+ ret = rproc_cdev->ops->set_cur_level(rproc_cdev->devdata, state);
+ mutex_unlock(&rproc_cdev->lock);
+
+ return ret;
+}
+
+static const struct thermal_cooling_device_ops remoteproc_cooling_ops = {
+ .get_max_state = remoteproc_get_max_state,
+ .get_cur_state = remoteproc_get_cur_state,
+ .set_cur_state = remoteproc_set_cur_state,
+};
+
+struct remoteproc_cdev *
+remoteproc_cooling_register(struct device_node *np,
+ const char *name, const struct remoteproc_cooling_ops *ops,
+ void *devdata)
+{
+ struct remoteproc_cdev *rproc_cdev;
+ struct thermal_cooling_device *cdev;
+ int ret;
+
+ if (!name || !ops)
+ return ERR_PTR(-EINVAL);
+
+ rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL);
+ if (!rproc_cdev)
+ return ERR_PTR(-ENOMEM);
+
+ rproc_cdev->ops = ops;
+ rproc_cdev->devdata = devdata;
+ mutex_init(&rproc_cdev->lock);
+
+ char *rproc_name __free(kfree) =
+ kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name);
+ /* Register with thermal framework */
+ if (np)
+ cdev = thermal_of_cooling_device_register(np, rproc_name, rproc_cdev,
+ &remoteproc_cooling_ops);
+ else
+ cdev = thermal_cooling_device_register(rproc_name, rproc_cdev,
+ &remoteproc_cooling_ops);
+
+ if (IS_ERR(cdev)) {
+ ret = PTR_ERR(cdev);
+ goto free_rproc_cdev;
+ }
+
+ rproc_cdev->cdev = cdev;
+
+ return rproc_cdev;
+
+free_rproc_cdev:
+ kfree(rproc_cdev);
+ return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(remoteproc_cooling_register);
+
+void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
+{
+ if (!rproc_cdev)
+ return;
+
+ thermal_cooling_device_unregister(rproc_cdev->cdev);
+ mutex_destroy(&rproc_cdev->lock);
+ kfree(rproc_cdev);
+}
+EXPORT_SYMBOL_GPL(remoteproc_cooling_unregister);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Remote Processor Cooling Device");
diff --git a/include/linux/remoteproc_cooling.h b/include/linux/remoteproc_cooling.h
new file mode 100644
index 000000000000..721912d1a5ec
--- /dev/null
+++ b/include/linux/remoteproc_cooling.h
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Remote Processor Cooling Device
+ *
+ * Copyright (c) 2025, Qualcomm Innovation Center
+ */
+
+#ifndef __REMOTEPROC_COOLING_H__
+#define __REMOTEPROC_COOLING_H__
+
+#include <linux/thermal.h>
+
+struct device;
+struct device_node;
+
+struct remoteproc_cooling_ops {
+ int (*get_max_level)(void *devdata, unsigned long *level);
+ int (*get_cur_level)(void *devdata, unsigned long *level);
+ int (*set_cur_level)(void *devdata, unsigned long level);
+};
+
+struct remoteproc_cdev;
+
+#ifdef CONFIG_REMOTEPROC_THERMAL
+
+struct remoteproc_cdev *
+remoteproc_cooling_register(struct device_node *np,
+ const char *name,
+ const struct remoteproc_cooling_ops *ops,
+ void *devdata);
+
+void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev);
+
+#else /* !CONFIG_REMOTEPROC_THERMAL */
+
+static inline struct remoteproc_cdev *
+remoteproc_cooling_register(struct device_node *np,
+ const char *name,
+ const struct remoteproc_cooling_ops *ops,
+ void *devdata)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline void
+remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
+{
+}
+
+#endif /* CONFIG_REMOTEPROC_THERMAL */
+
+#endif /* __REMOTEPROC_COOLING_H__ */
--
2.34.1
Hi Gaurav,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20260126]
[also build test WARNING on v6.19-rc7]
[cannot apply to robh/for-next rafael-pm/thermal remoteproc/rproc-next linus/master v6.19-rc7 v6.19-rc6 v6.19-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Gaurav-Kohli/thermal-Add-Remote-Proc-cooling-driver/20260128-000753
base: next-20260126
patch link: https://lore.kernel.org/r/20260127155722.2797783-2-gaurav.kohli%40oss.qualcomm.com
patch subject: [PATCH v2 1/8] thermal: Add Remote Proc cooling driver
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20260130/202601301416.z6Jz4P0R-lkp@intel.com/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260130/202601301416.z6Jz4P0R-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601301416.z6Jz4P0R-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/thermal/remoteproc_cooling.c:87:1: warning: no previous prototype for function 'remoteproc_cooling_register' [-Wmissing-prototypes]
remoteproc_cooling_register(struct device_node *np,
^
drivers/thermal/remoteproc_cooling.c:86:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
struct remoteproc_cdev *
^
static
>> drivers/thermal/remoteproc_cooling.c:131:6: warning: no previous prototype for function 'remoteproc_cooling_unregister' [-Wmissing-prototypes]
void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
^
drivers/thermal/remoteproc_cooling.c:131:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
^
static
2 warnings generated.
vim +/remoteproc_cooling_register +87 drivers/thermal/remoteproc_cooling.c
85
86 struct remoteproc_cdev *
> 87 remoteproc_cooling_register(struct device_node *np,
88 const char *name, const struct remoteproc_cooling_ops *ops,
89 void *devdata)
90 {
91 struct remoteproc_cdev *rproc_cdev;
92 struct thermal_cooling_device *cdev;
93 int ret;
94
95 if (!name || !ops)
96 return ERR_PTR(-EINVAL);
97
98 rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL);
99 if (!rproc_cdev)
100 return ERR_PTR(-ENOMEM);
101
102 rproc_cdev->ops = ops;
103 rproc_cdev->devdata = devdata;
104 mutex_init(&rproc_cdev->lock);
105
106 char *rproc_name __free(kfree) =
107 kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name);
108 /* Register with thermal framework */
109 if (np)
110 cdev = thermal_of_cooling_device_register(np, rproc_name, rproc_cdev,
111 &remoteproc_cooling_ops);
112 else
113 cdev = thermal_cooling_device_register(rproc_name, rproc_cdev,
114 &remoteproc_cooling_ops);
115
116 if (IS_ERR(cdev)) {
117 ret = PTR_ERR(cdev);
118 goto free_rproc_cdev;
119 }
120
121 rproc_cdev->cdev = cdev;
122
123 return rproc_cdev;
124
125 free_rproc_cdev:
126 kfree(rproc_cdev);
127 return ERR_PTR(ret);
128 }
129 EXPORT_SYMBOL_GPL(remoteproc_cooling_register);
130
> 131 void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
132 {
133 if (!rproc_cdev)
134 return;
135
136 thermal_cooling_device_unregister(rproc_cdev->cdev);
137 mutex_destroy(&rproc_cdev->lock);
138 kfree(rproc_cdev);
139 }
140 EXPORT_SYMBOL_GPL(remoteproc_cooling_unregister);
141
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Gaurav,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20260126]
[also build test WARNING on v6.19-rc7]
[cannot apply to robh/for-next rafael-pm/thermal remoteproc/rproc-next linus/master v6.19-rc7 v6.19-rc6 v6.19-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Gaurav-Kohli/thermal-Add-Remote-Proc-cooling-driver/20260128-000753
base: next-20260126
patch link: https://lore.kernel.org/r/20260127155722.2797783-2-gaurav.kohli%40oss.qualcomm.com
patch subject: [PATCH v2 1/8] thermal: Add Remote Proc cooling driver
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260130/202601301354.3ERTn2SC-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260130/202601301354.3ERTn2SC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601301354.3ERTn2SC-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/thermal/remoteproc_cooling.c:87:1: warning: no previous prototype for 'remoteproc_cooling_register' [-Wmissing-prototypes]
87 | remoteproc_cooling_register(struct device_node *np,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/thermal/remoteproc_cooling.c:131:6: warning: no previous prototype for 'remoteproc_cooling_unregister' [-Wmissing-prototypes]
131 | void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/remoteproc_cooling_register +87 drivers/thermal/remoteproc_cooling.c
85
86 struct remoteproc_cdev *
> 87 remoteproc_cooling_register(struct device_node *np,
88 const char *name, const struct remoteproc_cooling_ops *ops,
89 void *devdata)
90 {
91 struct remoteproc_cdev *rproc_cdev;
92 struct thermal_cooling_device *cdev;
93 int ret;
94
95 if (!name || !ops)
96 return ERR_PTR(-EINVAL);
97
98 rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL);
99 if (!rproc_cdev)
100 return ERR_PTR(-ENOMEM);
101
102 rproc_cdev->ops = ops;
103 rproc_cdev->devdata = devdata;
104 mutex_init(&rproc_cdev->lock);
105
106 char *rproc_name __free(kfree) =
107 kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name);
108 /* Register with thermal framework */
109 if (np)
110 cdev = thermal_of_cooling_device_register(np, rproc_name, rproc_cdev,
111 &remoteproc_cooling_ops);
112 else
113 cdev = thermal_cooling_device_register(rproc_name, rproc_cdev,
114 &remoteproc_cooling_ops);
115
116 if (IS_ERR(cdev)) {
117 ret = PTR_ERR(cdev);
118 goto free_rproc_cdev;
119 }
120
121 rproc_cdev->cdev = cdev;
122
123 return rproc_cdev;
124
125 free_rproc_cdev:
126 kfree(rproc_cdev);
127 return ERR_PTR(ret);
128 }
129 EXPORT_SYMBOL_GPL(remoteproc_cooling_register);
130
> 131 void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
132 {
133 if (!rproc_cdev)
134 return;
135
136 thermal_cooling_device_unregister(rproc_cdev->cdev);
137 mutex_destroy(&rproc_cdev->lock);
138 kfree(rproc_cdev);
139 }
140 EXPORT_SYMBOL_GPL(remoteproc_cooling_unregister);
141
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Tue, Jan 27, 2026 at 09:27:15PM +0530, Gaurav Kohli wrote: > + if (!name || !ops) > + return ERR_PTR(-EINVAL); > + > + rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL); > + if (!rproc_cdev) > + return ERR_PTR(-ENOMEM); > + > + rproc_cdev->ops = ops; > + rproc_cdev->devdata = devdata; > + mutex_init(&rproc_cdev->lock); > + > + char *rproc_name __free(kfree) = > + kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name); Ah, you keep ignoring review and sending the same buggy code. There is no point to spend any time here. It's also fastest way to get your future contributions ignored or NAKed. Well, ignoring review is obviously: NAK Best regards, Krzysztof
On 1/28/2026 5:06 PM, Krzysztof Kozlowski wrote: > On Tue, Jan 27, 2026 at 09:27:15PM +0530, Gaurav Kohli wrote: >> + if (!name || !ops) >> + return ERR_PTR(-EINVAL); >> + >> + rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL); >> + if (!rproc_cdev) >> + return ERR_PTR(-ENOMEM); >> + >> + rproc_cdev->ops = ops; >> + rproc_cdev->devdata = devdata; >> + mutex_init(&rproc_cdev->lock); >> + >> + char *rproc_name __free(kfree) = >> + kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name); > Ah, you keep ignoring review and sending the same buggy code. > > There is no point to spend any time here. It's also fastest way to get > your future contributions ignored or NAKed. Apologies for the miss, will make sure not to miss this in future version. > > Well, ignoring review is obviously: > NAK > > Best regards, > Krzysztof >
On Tue, Jan 27, 2026 at 09:27:15PM +0530, Gaurav Kohli wrote:
> Add a new generic driver for thermal cooling devices that control
There is no driver here. You did not a single driver entry point.
> remote processors (modem, DSP, etc.) through various communication
> channels.
>
> This driver provides an abstraction layer between the thermal
Please read coding style how much we like abstraction layers.
> subsystem and vendor-specific remote processor communication
> mechanisms.
>
> Advantage of this to avoid duplicating vendor-specific logic
> in the thermal subsystem and make it easier for different vendors
> to plug in their own cooling mechanisms via callbacks.
>
> Suggested-by: Amit Kucheria <amit.kucheria@oss.qualcomm.com>
> Signed-off-by: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
> ---
> MAINTAINERS | 7 ++
> drivers/thermal/Kconfig | 10 ++
> drivers/thermal/Makefile | 2 +
> drivers/thermal/remoteproc_cooling.c | 143 +++++++++++++++++++++++++++
> include/linux/remoteproc_cooling.h | 52 ++++++++++
> 5 files changed, 214 insertions(+)
> create mode 100644 drivers/thermal/remoteproc_cooling.c
> create mode 100644 include/linux/remoteproc_cooling.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 414f44093269..5ebc7819d2cf 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -26169,6 +26169,13 @@ F: drivers/thermal/cpufreq_cooling.c
> F: drivers/thermal/cpuidle_cooling.c
> F: include/linux/cpu_cooling.h
>
> +THERMAL/REMOTEPROC_COOLING
> +M: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
> +L: linux-pm@vger.kernel.org
> +S: Supported
> +F: drivers/thermal/remoteproc_cooling.c
> +F: include/linux/remoteproc_cooling.h
> +
> THERMAL/POWER_ALLOCATOR
Please beginning of this file. P < R.
> M: Lukasz Luba <lukasz.luba@arm.com>
> L: linux-pm@vger.kernel.org
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index b10080d61860..dfc52eed64de 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -229,6 +229,16 @@ config PCIE_THERMAL
>
> If you want this support, you should say Y here.
>
> +config REMOTEPROC_THERMAL
> + tristate "Remote processor cooling support"
> + help
> + This implements a generic cooling mechanism for remote processors
> + (modem, DSP, etc.) that allows vendor-specific implementations to
> + register thermal cooling devices and provide callbacks for thermal
> + mitigation.
> +
> + If you want this support, you should say Y here.
> +
> config THERMAL_EMULATION
> bool "Thermal emulation mode support"
> help
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index bb21e7ea7fc6..ae747dde54fe 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -34,6 +34,8 @@ thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
>
> thermal_sys-$(CONFIG_PCIE_THERMAL) += pcie_cooling.o
>
> +thermal_sys-$(CONFIG_REMOTEPROC_THERMAL) += remoteproc_cooling.o
> +
> obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o k3_j72xx_bandgap.o
> # platform thermal drivers
> obj-y += broadcom/
> diff --git a/drivers/thermal/remoteproc_cooling.c b/drivers/thermal/remoteproc_cooling.c
> new file mode 100644
> index 000000000000..f958efa691b3
> --- /dev/null
> +++ b/drivers/thermal/remoteproc_cooling.c
> @@ -0,0 +1,143 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Remote Processor Cooling Device
> + *
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/export.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/of.h>
Where do you use it?
> +#include <linux/slab.h>
> +#include <linux/thermal.h>
> +
> +#define REMOTEPROC_PREFIX "rproc_"
> +
> +struct remoteproc_cooling_ops {
> + int (*get_max_level)(void *devdata, unsigned long *level);
> + int (*get_cur_level)(void *devdata, unsigned long *level);
> + int (*set_cur_level)(void *devdata, unsigned long level);
> +};
> +
> +/**
> + * struct remoteproc_cdev - Remote processor cooling device
> + * @cdev: Thermal cooling device handle
> + * @ops: Vendor-specific operation callbacks
> + * @devdata: Private data for vendor implementation
> + * @np: Device tree node associated with this cooling device
> + * @lock: Mutex to protect cooling device operations
> + */
> +struct remoteproc_cdev {
> + struct thermal_cooling_device *cdev;
> + const struct remoteproc_cooling_ops *ops;
> + void *devdata;
> + struct mutex lock;
> +};
> +
> +/* Thermal cooling device callbacks */
> +
> +static int remoteproc_get_max_state(struct thermal_cooling_device *cdev,
> + unsigned long *state)
> +{
> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
> + int ret;
> +
> + mutex_lock(&rproc_cdev->lock);
> + ret = rproc_cdev->ops->get_max_level(rproc_cdev->devdata, state);
> + mutex_unlock(&rproc_cdev->lock);
> +
> + return ret;
> +}
> +
> +static int remoteproc_get_cur_state(struct thermal_cooling_device *cdev,
> + unsigned long *state)
> +{
> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
> + int ret;
> +
> + mutex_lock(&rproc_cdev->lock);
> + ret = rproc_cdev->ops->get_cur_level(rproc_cdev->devdata, state);
> + mutex_unlock(&rproc_cdev->lock);
> +
> + return ret;
> +}
> +
> +static int remoteproc_set_cur_state(struct thermal_cooling_device *cdev,
> + unsigned long state)
> +{
> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
> + int ret;
> +
> + mutex_lock(&rproc_cdev->lock);
> + ret = rproc_cdev->ops->set_cur_level(rproc_cdev->devdata, state);
> + mutex_unlock(&rproc_cdev->lock);
> +
> + return ret;
> +}
> +
> +static const struct thermal_cooling_device_ops remoteproc_cooling_ops = {
> + .get_max_state = remoteproc_get_max_state,
> + .get_cur_state = remoteproc_get_cur_state,
> + .set_cur_state = remoteproc_set_cur_state,
> +};
> +
> +struct remoteproc_cdev *
> +remoteproc_cooling_register(struct device_node *np,
> + const char *name, const struct remoteproc_cooling_ops *ops,
> + void *devdata)
> +{
> + struct remoteproc_cdev *rproc_cdev;
> + struct thermal_cooling_device *cdev;
> + int ret;
> +
> + if (!name || !ops)
> + return ERR_PTR(-EINVAL);
> +
> + rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL);
> + if (!rproc_cdev)
> + return ERR_PTR(-ENOMEM);
> +
> + rproc_cdev->ops = ops;
> + rproc_cdev->devdata = devdata;
> + mutex_init(&rproc_cdev->lock);
> +
> + char *rproc_name __free(kfree) =
> + kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name);
> + /* Register with thermal framework */
> + if (np)
> + cdev = thermal_of_cooling_device_register(np, rproc_name, rproc_cdev,
> + &remoteproc_cooling_ops);
> + else
> + cdev = thermal_cooling_device_register(rproc_name, rproc_cdev,
> + &remoteproc_cooling_ops);
> +
> + if (IS_ERR(cdev)) {
> + ret = PTR_ERR(cdev);
> + goto free_rproc_cdev;
> + }
> +
> + rproc_cdev->cdev = cdev;
> +
> + return rproc_cdev;
> +
> +free_rproc_cdev:
> + kfree(rproc_cdev);
> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL_GPL(remoteproc_cooling_register);
> +
> +void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
> +{
> + if (!rproc_cdev)
> + return;
> +
> + thermal_cooling_device_unregister(rproc_cdev->cdev);
> + mutex_destroy(&rproc_cdev->lock);
> + kfree(rproc_cdev);
> +}
> +EXPORT_SYMBOL_GPL(remoteproc_cooling_unregister);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Remote Processor Cooling Device");
I do not see any driver here, just bunch of exported functions. I do not
see point in this abstraction/wrapping layer.
Another abstraction layer, NAK.
Best regards,
Krzysztof
On 1/28/2026 5:02 PM, Krzysztof Kozlowski wrote:
> On Tue, Jan 27, 2026 at 09:27:15PM +0530, Gaurav Kohli wrote:
>> Add a new generic driver for thermal cooling devices that control
> There is no driver here. You did not a single driver entry point.
>
>> remote processors (modem, DSP, etc.) through various communication
>> channels.
>>
>> This driver provides an abstraction layer between the thermal
> Please read coding style how much we like abstraction layers.
>
>> subsystem and vendor-specific remote processor communication
>> mechanisms.
>>
>> Advantage of this to avoid duplicating vendor-specific logic
>> in the thermal subsystem and make it easier for different vendors
>> to plug in their own cooling mechanisms via callbacks.
>>
>> Suggested-by: Amit Kucheria <amit.kucheria@oss.qualcomm.com>
>> Signed-off-by: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
>> ---
>> MAINTAINERS | 7 ++
>> drivers/thermal/Kconfig | 10 ++
>> drivers/thermal/Makefile | 2 +
>> drivers/thermal/remoteproc_cooling.c | 143 +++++++++++++++++++++++++++
>> include/linux/remoteproc_cooling.h | 52 ++++++++++
>> 5 files changed, 214 insertions(+)
>> create mode 100644 drivers/thermal/remoteproc_cooling.c
>> create mode 100644 include/linux/remoteproc_cooling.h
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 414f44093269..5ebc7819d2cf 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -26169,6 +26169,13 @@ F: drivers/thermal/cpufreq_cooling.c
>> F: drivers/thermal/cpuidle_cooling.c
>> F: include/linux/cpu_cooling.h
>>
>> +THERMAL/REMOTEPROC_COOLING
>> +M: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
>> +L: linux-pm@vger.kernel.org
>> +S: Supported
>> +F: drivers/thermal/remoteproc_cooling.c
>> +F: include/linux/remoteproc_cooling.h
>> +
>> THERMAL/POWER_ALLOCATOR
> Please beginning of this file. P < R.
>
will update this ordering.
>> M: Lukasz Luba <lukasz.luba@arm.com>
>> L: linux-pm@vger.kernel.org
>> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
>> index b10080d61860..dfc52eed64de 100644
>> --- a/drivers/thermal/Kconfig
>> +++ b/drivers/thermal/Kconfig
>> @@ -229,6 +229,16 @@ config PCIE_THERMAL
>>
>> If you want this support, you should say Y here.
>>
>> +config REMOTEPROC_THERMAL
>> + tristate "Remote processor cooling support"
>> + help
>> + This implements a generic cooling mechanism for remote processors
>> + (modem, DSP, etc.) that allows vendor-specific implementations to
>> + register thermal cooling devices and provide callbacks for thermal
>> + mitigation.
>> +
>> + If you want this support, you should say Y here.
>> +
>> config THERMAL_EMULATION
>> bool "Thermal emulation mode support"
>> help
>> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
>> index bb21e7ea7fc6..ae747dde54fe 100644
>> --- a/drivers/thermal/Makefile
>> +++ b/drivers/thermal/Makefile
>> @@ -34,6 +34,8 @@ thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
>>
>> thermal_sys-$(CONFIG_PCIE_THERMAL) += pcie_cooling.o
>>
>> +thermal_sys-$(CONFIG_REMOTEPROC_THERMAL) += remoteproc_cooling.o
>> +
>> obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o k3_j72xx_bandgap.o
>> # platform thermal drivers
>> obj-y += broadcom/
>> diff --git a/drivers/thermal/remoteproc_cooling.c b/drivers/thermal/remoteproc_cooling.c
>> new file mode 100644
>> index 000000000000..f958efa691b3
>> --- /dev/null
>> +++ b/drivers/thermal/remoteproc_cooling.c
>> @@ -0,0 +1,143 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Remote Processor Cooling Device
>> + *
>> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
>> + */
>> +
>> +#include <linux/err.h>
>> +#include <linux/export.h>
>> +#include <linux/module.h>
>> +#include <linux/mutex.h>
>> +#include <linux/of.h>
> Where do you use it?
thanks for pointing this, this won't be used anymore.
We had originally plan to parse dt from here, and included was added for
that earlier approach.
Will fix this.
>> +#include <linux/slab.h>
>> +#include <linux/thermal.h>
>> +
>> +#define REMOTEPROC_PREFIX "rproc_"
>> +
>> +struct remoteproc_cooling_ops {
>> + int (*get_max_level)(void *devdata, unsigned long *level);
>> + int (*get_cur_level)(void *devdata, unsigned long *level);
>> + int (*set_cur_level)(void *devdata, unsigned long level);
>> +};
>> +
>> +/**
>> + * struct remoteproc_cdev - Remote processor cooling device
>> + * @cdev: Thermal cooling device handle
>> + * @ops: Vendor-specific operation callbacks
>> + * @devdata: Private data for vendor implementation
>> + * @np: Device tree node associated with this cooling device
>> + * @lock: Mutex to protect cooling device operations
>> + */
>> +struct remoteproc_cdev {
>> + struct thermal_cooling_device *cdev;
>> + const struct remoteproc_cooling_ops *ops;
>> + void *devdata;
>> + struct mutex lock;
>> +};
>> +
>> +/* Thermal cooling device callbacks */
>> +
>> +static int remoteproc_get_max_state(struct thermal_cooling_device *cdev,
>> + unsigned long *state)
>> +{
>> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
>> + int ret;
>> +
>> + mutex_lock(&rproc_cdev->lock);
>> + ret = rproc_cdev->ops->get_max_level(rproc_cdev->devdata, state);
>> + mutex_unlock(&rproc_cdev->lock);
>> +
>> + return ret;
>> +}
>> +
>> +static int remoteproc_get_cur_state(struct thermal_cooling_device *cdev,
>> + unsigned long *state)
>> +{
>> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
>> + int ret;
>> +
>> + mutex_lock(&rproc_cdev->lock);
>> + ret = rproc_cdev->ops->get_cur_level(rproc_cdev->devdata, state);
>> + mutex_unlock(&rproc_cdev->lock);
>> +
>> + return ret;
>> +}
>> +
>> +static int remoteproc_set_cur_state(struct thermal_cooling_device *cdev,
>> + unsigned long state)
>> +{
>> + struct remoteproc_cdev *rproc_cdev = cdev->devdata;
>> + int ret;
>> +
>> + mutex_lock(&rproc_cdev->lock);
>> + ret = rproc_cdev->ops->set_cur_level(rproc_cdev->devdata, state);
>> + mutex_unlock(&rproc_cdev->lock);
>> +
>> + return ret;
>> +}
>> +
>> +static const struct thermal_cooling_device_ops remoteproc_cooling_ops = {
>> + .get_max_state = remoteproc_get_max_state,
>> + .get_cur_state = remoteproc_get_cur_state,
>> + .set_cur_state = remoteproc_set_cur_state,
>> +};
>> +
>> +struct remoteproc_cdev *
>> +remoteproc_cooling_register(struct device_node *np,
>> + const char *name, const struct remoteproc_cooling_ops *ops,
>> + void *devdata)
>> +{
>> + struct remoteproc_cdev *rproc_cdev;
>> + struct thermal_cooling_device *cdev;
>> + int ret;
>> +
>> + if (!name || !ops)
>> + return ERR_PTR(-EINVAL);
>> +
>> + rproc_cdev = kzalloc(sizeof(*rproc_cdev), GFP_KERNEL);
>> + if (!rproc_cdev)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + rproc_cdev->ops = ops;
>> + rproc_cdev->devdata = devdata;
>> + mutex_init(&rproc_cdev->lock);
>> +
>> + char *rproc_name __free(kfree) =
>> + kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name);
>> + /* Register with thermal framework */
>> + if (np)
>> + cdev = thermal_of_cooling_device_register(np, rproc_name, rproc_cdev,
>> + &remoteproc_cooling_ops);
>> + else
>> + cdev = thermal_cooling_device_register(rproc_name, rproc_cdev,
>> + &remoteproc_cooling_ops);
>> +
>> + if (IS_ERR(cdev)) {
>> + ret = PTR_ERR(cdev);
>> + goto free_rproc_cdev;
>> + }
>> +
>> + rproc_cdev->cdev = cdev;
>> +
>> + return rproc_cdev;
>> +
>> +free_rproc_cdev:
>> + kfree(rproc_cdev);
>> + return ERR_PTR(ret);
>> +}
>> +EXPORT_SYMBOL_GPL(remoteproc_cooling_register);
>> +
>> +void remoteproc_cooling_unregister(struct remoteproc_cdev *rproc_cdev)
>> +{
>> + if (!rproc_cdev)
>> + return;
>> +
>> + thermal_cooling_device_unregister(rproc_cdev->cdev);
>> + mutex_destroy(&rproc_cdev->lock);
>> + kfree(rproc_cdev);
>> +}
>> +EXPORT_SYMBOL_GPL(remoteproc_cooling_unregister);
>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_DESCRIPTION("Remote Processor Cooling Device");
> I do not see any driver here, just bunch of exported functions. I do not
> see point in this abstraction/wrapping layer.
>
> Another abstraction layer, NAK.
Thanks Krzysztof for review.
We need this abstraction layer to provide a common interface that
multiple vendors can rely on for
their remote processor based cooling communication. If we use
QMI-cooling driver only, then solution will
be qualcomm specific only or other's can not extend that.
>
> Best regards,
> Krzysztof
>
On 30/01/2026 07:39, Gaurav Kohli wrote:
>>> +
>>> +MODULE_LICENSE("GPL");
>>> +MODULE_DESCRIPTION("Remote Processor Cooling Device");
>> I do not see any driver here, just bunch of exported functions. I do not
>> see point in this abstraction/wrapping layer.
>>
>> Another abstraction layer, NAK.
>
>
> Thanks Krzysztof for review.
>
> We need this abstraction layer to provide a common interface that
> multiple vendors can rely on for
Why do you keep inserting blank lines inside sentences?
>
> their remote processor based cooling communication. If we use
> QMI-cooling driver only, then solution will
So you just ignored my comment and repeat the same mantra. You don't
even use any arguments, just push own position. This will get you nowhere.
Read the comment again.
NAK
Best regards,
Krzysztof
© 2016 - 2026 Red Hat, Inc.