From nobody Mon Feb 9 19:38:14 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 A58CC35DD05 for ; Tue, 27 Jan 2026 15:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769529469; cv=none; b=Y3n4CQ1YkANo/qH5vn2WF976IxJAOHKS/mVbagvqr3wVLI+1DqZcQGtDnHCrwi6THIbo6rr5pNAeyyRefPSTXfcZeWol+MtGUbTQtNart5abU5wo89YwH29FYHyb4RHT+2xr2KzYUK4QiOVRZdKXucdSQl5xxLZ7GKbhpYiFcjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769529469; c=relaxed/simple; bh=YyaNXeWaLIKpWzCU/L/ILFdXN/+iun4frf5IkoJMhJ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NdN5UST9P5ob5zef8P/2ND5QibLHu2Eo6hYsRT2V0blJSw6a2nuOnjse9EJzePLCWDphe1nGNE1xVtUI+kB/LbkE3PCQNAytkbXA1NJ2H3gMYLaQ9zAmRErovdH3Re1D5v0IeaPoi4PaYwQglYvjdNj+9wet+hQ6m/URUcY4QA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=e2MEiGrY; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NGt0XGFm; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="e2MEiGrY"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NGt0XGFm" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60RDlFeF658425 for ; Tue, 27 Jan 2026 15:57:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=5nar1uSCNy/ fyhypcdwInxOup3xqwfDAP5lnvImXQmk=; b=e2MEiGrYMzVHg7YLNP3oMczkud3 GomERdLlTL9e/zdasrlSxwni6xGMxXr0jaWX8wFaDuy677NeREJCVz3xiNv+Rfab MXB6Uh/FRD2G4V55i1DBkRx4kNG23GIw+Qsbb4WpO2uNNNXbrPGagZHjPfemBX0K l3v4bdceC8owTYTA3+tshUUORYcDgmhpes8+xtF4NbfeRWHq+juVBBYjC/nammJ7 ffgAiSFk29FEh/wXM91uTDAYgQLVzTQn8+NOJuuCOeVXPBUjIbWj0Tkr97zf5t4C fPr2P/9dc1UAASMKTasobnwyfsvATn7PLOjfxwO3gyKLEg2rKfpj6Cmq5Tg== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bxryn9ptm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 27 Jan 2026 15:57:46 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-29f1f69eec6so55312935ad.1 for ; Tue, 27 Jan 2026 07:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769529466; x=1770134266; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5nar1uSCNy/fyhypcdwInxOup3xqwfDAP5lnvImXQmk=; b=NGt0XGFmucQoYulaecA6hWVSISy44oSTR30LqbQAdoFeMCOnr5JMfzbFuxNjTuW1f+ IhMJrAFmZSCffvkz9KEehKdKitoqMNbAbqT2SVM+r2RssBVzTNe3BHbQtBdEAN+3qEBt Wgc5UqHJfGIkQdzVyIT1jfYUYhxw3Pm7852PPWssOWw/TehYrqhfzLcpFeOm/217WlsM NM78hW6Rw3cYioL0uNXASgK+R8pkcIsZ2X+/hwZnsd9CWt27bwBj+GbpKSbIbwsgMHHN qJlGQjkFBad97UAvzZHTNsTedNBTRT4ibgoFcj/CYjSQA4dugMqus5gpKne77/f/gP1L uOKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769529466; x=1770134266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5nar1uSCNy/fyhypcdwInxOup3xqwfDAP5lnvImXQmk=; b=sODkD8k9sdBBGhfMLIz8gdWsHzCokkVg5HpVes4ItgaKKlaOaz7kQATOVNUZgZKcc9 PLmDJRzLGRn0XwbdIPpmfnmwtVn0jceg9GuWZTdOnB3EKDcK6GtXO4cilyso+lQPCUmt 6IQnQngaHLnY0b8nLq3Lt+kTSgi5p9TF60zkS1YGstNUqwxu3DukMSG9eDSEj6VrLegL +nLz5tnctHeJMqx/NRoNnSRJaRu28WFbWtMkB9+FX+AitchG/EdxVwJ6/VAyn3YEeY+f If1S0GdV1B4epo7oy3jZp86NLyQhCiTTKrLK8Ra3F7Yr/fYdv7LqNZ7Qcq99UIc1eZgo 8eSQ== X-Forwarded-Encrypted: i=1; AJvYcCWQKMYEY78lVJnvqxOTiB3iqIo2VjlLhYXssCphcuqzkdQzlmso8RoH6VPAoQ3VQhk+AzSvJA4p+qX98aM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7OO6iAXMbdBTW3wgphqWJCRiVdih452/CE9G4KH1eXuDEc5sC UBUPxllTjvnKyrnWdSTULm5OZhv14oWdlkzvR0K08bhXaSXfVl3GJpa7+Xfgcn1a1voI1/T2I9v vP47zEc9K5AST3NyaI0j7pwc4BLFpez3y18IjMHq7o9iY/ahJj0cUDGb67kB7EVTaUuU= X-Gm-Gg: AZuq6aL6TpqPfQ7lqzlYAopSZ8YwvD8K0sMTiWeqMLN5Pmn/ykho3jrmfOal0bc4hHv 8Hq6tzfH0Njg9yyA14oNN3Frl3Zxr82JMjIwzxs64irSSOiRt05Yw1IaWa2NmvVVMwAuCsBxBed XzSrWX1CZBeGHWq5BUXGxCV2o4IIAUVdIsA3nGG+pi31Foj/M89rGX2nHCcSkrpShl5gxQriWId 9iqJdwr9xd2RY0yGrD1z6/pr5c8BfxrNzhi95mx2cTccZMNRYsspA/IWVdOj7zcFcDd5XOasYVK 46X7D52zK6tKU7RZOLijdwGMIcrQO/tMJwsxqvWPWsc+n2wI9Wh7+sTgmzRG+kp4YtgaoD68udD HFN4rFkw+rwPgOFwDcS0xdHtyBbc3+TUOWWWEsgE= X-Received: by 2002:a17:902:f68b:b0:2a1:243:94a8 with SMTP id d9443c01a7336-2a870ddd7b6mr26852485ad.49.1769529465600; Tue, 27 Jan 2026 07:57:45 -0800 (PST) X-Received: by 2002:a17:902:f68b:b0:2a1:243:94a8 with SMTP id d9443c01a7336-2a870ddd7b6mr26852185ad.49.1769529465015; Tue, 27 Jan 2026 07:57:45 -0800 (PST) Received: from hu-gkohli-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a802ede745sm120577465ad.44.2026.01.27.07.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 07:57:44 -0800 (PST) From: Gaurav Kohli To: andersson@kernel.org, mathieu.poirier@linaro.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com, konradybcio@kernel.org, mani@kernel.org, casey.connolly@linaro.org, amit.kucheria@oss.qualcomm.com Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, gaurav.kohli@oss.qualcomm.com, manaf.pallikunhi@oss.qualcomm.com Subject: [PATCH v2 1/8] thermal: Add Remote Proc cooling driver Date: Tue, 27 Jan 2026 21:27:15 +0530 Message-Id: <20260127155722.2797783-2-gaurav.kohli@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260127155722.2797783-1-gaurav.kohli@oss.qualcomm.com> References: <20260127155722.2797783-1-gaurav.kohli@oss.qualcomm.com> 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-Proofpoint-ORIG-GUID: XojSHQWxTVgQs8JLABkVuRaiM0BM8zu1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI3MDEzMCBTYWx0ZWRfX0tqqftOQexjT 7RwCX95OOIhX3THP/pQju7SQSoC420ESX5p30PQwm6KNGzF0eGL+pxrot/Wg4yJ38vd4hlZfxn3 nJoIH4efocbH6mwTXLDfvmuMxBz7bNMugddNfibEaoBWEVWkIEFoN9IdyAusTu5xKEVJ5eS0hxj h15ejFHfDi5BA0FYrNetdt7sW8McCJhGucSVkBShEKfOFbGa1Ts9WWT+EsDXV4WW48Cg9GkyRG0 zHlmJbJr1dHbpZQWeA2KeYxZaN9+BwCyTi/yH0MOTjLbBxoy/NOVSaQw+F7YoHjAThz4Hn9MNX2 e8+SamC1a0D/HviQtecbVCsgn56Cx9Zs0r5fMPS6Qj9NZp9Lis/tEe65936OI0l4xeolII8isAS ybpYKv1L/EBhNjPoBfo5s/BnnRglbGn9MgRfBZdm1hAm4X7NnWgWwTczzFLiRHoHydo3Nde3MPU bmy6OZAAu6x76OuOswg== X-Proofpoint-GUID: XojSHQWxTVgQs8JLABkVuRaiM0BM8zu1 X-Authority-Analysis: v=2.4 cv=FsEIPmrq c=1 sm=1 tr=0 ts=6978e07a cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=7CQSdrXTAAAA:8 a=2qJnY-jACA4cO-adHyEA:9 a=uG9DUKGECoFWVXl0Dc02:22 a=a-qgeE7W1pNrGK8U0ZQC:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-01-27_03,2026-01-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 malwarescore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601270130 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gaurav Kohli --- 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 =20 +THERMAL/REMOTEPROC_COOLING +M: Gaurav Kohli +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 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 =20 If you want this support, you should say Y here. =20 +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) +=3D devfreq_coolin= g.o =20 thermal_sys-$(CONFIG_PCIE_THERMAL) +=3D pcie_cooling.o =20 +thermal_sys-$(CONFIG_REMOTEPROC_THERMAL) +=3D remoteproc_cooling.o + obj-$(CONFIG_K3_THERMAL) +=3D k3_bandgap.o k3_j72xx_bandgap.o # platform thermal drivers obj-y +=3D broadcom/ diff --git a/drivers/thermal/remoteproc_cooling.c b/drivers/thermal/remotep= roc_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 +#include +#include +#include +#include +#include +#include + +#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 =3D cdev->devdata; + int ret; + + mutex_lock(&rproc_cdev->lock); + ret =3D 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 =3D cdev->devdata; + int ret; + + mutex_lock(&rproc_cdev->lock); + ret =3D 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 =3D cdev->devdata; + int ret; + + mutex_lock(&rproc_cdev->lock); + ret =3D 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 =3D { + .get_max_state =3D remoteproc_get_max_state, + .get_cur_state =3D remoteproc_get_cur_state, + .set_cur_state =3D 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 =3D kzalloc(sizeof(*rproc_cdev), GFP_KERNEL); + if (!rproc_cdev) + return ERR_PTR(-ENOMEM); + + rproc_cdev->ops =3D ops; + rproc_cdev->devdata =3D devdata; + mutex_init(&rproc_cdev->lock); + + char *rproc_name __free(kfree) =3D + kasprintf(GFP_KERNEL, REMOTEPROC_PREFIX "%s", name); + /* Register with thermal framework */ + if (np) + cdev =3D thermal_of_cooling_device_register(np, rproc_name, rproc_cdev, + &remoteproc_cooling_ops); + else + cdev =3D thermal_cooling_device_register(rproc_name, rproc_cdev, + &remoteproc_cooling_ops); + + if (IS_ERR(cdev)) { + ret =3D PTR_ERR(cdev); + goto free_rproc_cdev; + } + + rproc_cdev->cdev =3D 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 + +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__ */ --=20 2.34.1