Skip to contentSkip to conversation

Platform Temperature Control interface

PATCH New Srinivas Pandruvada 1 participant 4 messages Mar 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Platform Temperature Control interface

Platform Temperature Control is a dynamic control loop implemented in hardware to manage the skin or any board temperature of a device. The reported skin or board temperature is controlled by comparing to a configured target temperature and adjusting the SoC (System on Chip) performance accordingly.

This series supports optional controls from the user space.

Srinivas Pandruvada (3):
thermal: intel: int340x: Add platform temperature control interface
thermal: intel: int340x: Enable platform temperature control
thermal: int340x: processor_thermal: Platform temperature control
documentation

 .../driver-api/thermal/intel_dptf.rst         |  15 ++
 .../thermal/intel/int340x_thermal/Makefile    |   1 +
 .../platform_temperature_control.c            | 181 ++++++++++++++++++
 .../processor_thermal_device.c                |  15 +-
 .../processor_thermal_device.h                |   3 +
 .../processor_thermal_device_pci.c            |   6 +-
 6 files changed, 218 insertions(+), 3 deletions(-)
 create mode 100644 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/3 thermal: intel: int340x: Add platform temperature control interface

Platform Temperature Control is a dynamic control loop implemented in hardware to manage the skin or any board temperature of a device. The reported skin or board temperature is controlled by comparing to a configured target temperature and adjusting the SoC (System on Chip) performance accordingly. The feature supports up to three platform sensors.

OEMs (Original Equipment Manufacturers) can configure this feature through the BIOS and provide temperature input directly to the hardware via the Platform Environment Control Interface (PECI). As a result, this feature can operate independently of any OS-level control.

The OS interface can be used to further fine-tune the default OEM configuration. Here are some scenarios where the OS interface is beneficial:
Verification of Firmware Control: Check if firmware-based control is enabled. If it is, thermal controls from the OS/user space can be backed out.
Adjusting Target Limits: While OEMs can set an aggressive target limit, the OS can adjust this to a less aggressive limit based on operating modes or conditions.

The hardware control interface is via a MMIO offsets via processor thermal device. There are three instances of MMIO registers. All are 64 bit registers

Name: PLATFORM_TEMPERATURE_CONTROL
Offsets: 0x5B20, 0x5B28, 0x5B30

All values have RW access

Bits Description
7:0 TARGET_TEMP : Target temperature limit to which the control
mechanism is regulating. Units: 0.5C.
8:8 ENABLE: Read current enable status of the feature or enable
feature.
11:9 GAIN: Sets the aggressiveness of control loop from 0 to 7
7 graceful, favors performance at the expense of temperature overshoots
0 aggressive, favors tight regulation over performance
12:12 TEMPERATURE_OVERRIDE_EN
When set, hardware will use TEMPERATURE_OVERRIDE values instead of reading from corresponding sensor.
15:13 RESERVED
23:16 MIN_PERFORMANCE_LEVEL: Minimum Performance level below which the
there will be no throttling. 0 - all levels of throttling allowed including survivability actions. 255 - no throttling allowed.
31:24 TEMPERATURE_OVERRIDE: Allows SW to override the input temperature.

	hardware will use this value instead of the sensor temperature.
	Units: 0.5C.

63:32 RESERVED

Out of the above controls, only "enable" and "temperature_target" is exposed via sysfs.
There are three instances of this controls. So up to three different sensors can be controlled independently.

Sysfs interface:
tree /sys/bus/pci/devices/0000\:00\:04.0/platform_temperature_?_control/ /sys/bus/pci/devices/0000:00:04.0/platform_temperature_0_control/

├── enable
├── temperature_target
/sys/bus/pci/devices/0000:00:04.0/platform_temperature_1_control/
├── enable
├── temperature_target
/sys/bus/pci/devices/0000:00:04.0/platform_temperature_2_control/
├── enable
├── temperature_target

Description of attributes:

Enable: 1 for enable, 0 for disable. This attribute can be used to read the current status. User space can write 0 or 1 to disable or enable this feature respectively.
temperature_target: Target temperature limit to which hardware will try to limit in milli degree C.

---
 .../thermal/intel/int340x_thermal/Makefile    |   1 +
 .../platform_temperature_control.c            | 181 ++++++++++++++++++
 .../processor_thermal_device.c                |  15 +-
 .../processor_thermal_device.h                |   3 +
 4 files changed, 199 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
drivers/thermal/intel/int340x_thermal/Makefile +1 -0
index fe3f43924525..184318d1792b 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_device_pci_legacy.o
 obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_device_pci.o
 obj-$(CONFIG_PROC_THERMAL_MMIO_RAPL) += processor_thermal_rapl.o
 obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_rfim.o
+obj-$(CONFIG_INT340X_THERMAL)	+= platform_temperature_control.o
 obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_mbox.o
 obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_wt_req.o
 obj-$(CONFIG_INT340X_THERMAL)	+= processor_thermal_wt_hint.o
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c new file +181 -0

181 lines not on this page · raw message

drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +14 -1
index c868d8b7bd1c..10841a37431c 100644
@@ -399,13 +399,21 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
 		}
 	}
 
+	if (feature_mask & PROC_THERMAL_FEATURE_PTC) {
+		ret = proc_thermal_ptc_add(pdev, proc_priv);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to add PTC MMIO interface\n");
+			goto err_rem_rapl;
+		}
+	}
+
 	if (feature_mask & PROC_THERMAL_FEATURE_FIVR ||
 	    feature_mask & PROC_THERMAL_FEATURE_DVFS ||
 	    feature_mask & PROC_THERMAL_FEATURE_DLVR) {
 		ret = proc_thermal_rfim_add(pdev, proc_priv);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to add RFIM interface\n");
-			goto err_rem_rapl;
+			goto err_rem_ptc;
 		}
 	}
 
@@ -427,6 +435,8 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
 
 err_rem_rfim:
 	proc_thermal_rfim_remove(pdev);
+err_rem_ptc:
+	proc_thermal_ptc_remove(pdev);
 err_rem_rapl:
 	proc_thermal_rapl_remove();
 
@@ -439,6 +449,9 @@ void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *
 	if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_RAPL)
 		proc_thermal_rapl_remove();
 
+	if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_PTC)
+		proc_thermal_ptc_remove(pdev);
+
 	if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR ||
 	    proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS ||
 	    proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR)
drivers/thermal/intel/int340x_thermal/processor_thermal_device.h +3 -0
index ba2d89d3024c..9a6ca43b6fa2 100644
@@ -67,6 +67,7 @@ struct rapl_mmio_regs {
 #define PROC_THERMAL_FEATURE_WT_HINT	0x20
 #define PROC_THERMAL_FEATURE_POWER_FLOOR	0x40
 #define PROC_THERMAL_FEATURE_MSI_SUPPORT	0x80
+#define PROC_THERMAL_FEATURE_PTC	0x100
 
 #if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)
 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
@@ -123,4 +124,6 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
 			  struct proc_thermal_device *proc_priv,
 			  kernel_ulong_t feature_mask);
 void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
+int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
+void proc_thermal_ptc_remove(struct pci_dev *pdev);
 #endif
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/3 thermal: intel: int340x: Enable platform temperature control

In reply to Srinivas Pandruvada

Enable platform temperature control feature for Lunar Lake and Panther Lake.

---
 .../intel/int340x_thermal/processor_thermal_device_pci.c    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +4 -2
index a55aaa8cef42..f7f03159606a 100644
@@ -486,7 +486,8 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
 	  PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_REQ) },
 	{ PCI_DEVICE_DATA(INTEL, LNLM_THERMAL, PROC_THERMAL_FEATURE_MSI_SUPPORT |
 	  PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_DLVR |
-	  PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR) },
+	  PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR |
+	  PROC_THERMAL_FEATURE_PTC) },
 	{ PCI_DEVICE_DATA(INTEL, MTLP_THERMAL, PROC_THERMAL_FEATURE_RAPL |
 	  PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_DLVR |
 	  PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR) },
@@ -496,7 +497,8 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
 	  PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_REQ) },
 	{ PCI_DEVICE_DATA(INTEL, PTL_THERMAL, PROC_THERMAL_FEATURE_RAPL |
 	  PROC_THERMAL_FEATURE_DLVR | PROC_THERMAL_FEATURE_MSI_SUPPORT |
-	  PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR) },
+	  PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR |
+	  PROC_THERMAL_FEATURE_PTC) },
 	{ },
 };
 
Signature · 1 line
2.48.1
#3 lore raw

PATCH 3/3 thermal: int340x: processor_thermal: Platform temperature control documentation

In reply to Srinivas Pandruvada

Update documentation of attributes for platform temperature control.

---
 Documentation/driver-api/thermal/intel_dptf.rst | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Documentation/driver-api/thermal/intel_dptf.rst +15 -0
index 8fb8c5b2d685..e7e387d60b7e 100644
@@ -191,6 +191,21 @@ ABI.
 	User space can specify any one of the available workload type using
 	this interface.
 
+:file:`/sys/bus/pci/devices/0000\:00\:04.0/platform_temperature_0_control`
+:file:`/sys/bus/pci/devices/0000\:00\:04.0/platform_temperature_1_control`
+:file:`/sys/bus/pci/devices/0000\:00\:04.0/platform_temperature_2_control`
+
+All these controls needs admin privilege to update.
+
+``enable`` (RW)
+	1 for enable, 0 for disable. Shows the current enable status of
+	platform temperature control feature. User space can enable/disable
+	hardware controls.
+
+``temperature_target`` (RW)
+	Update a new temperature target in milli degree celsius for hardware to
+	use for the temperature control.
+
 DPTF Processor thermal RFIM interface
 --------------------------------------------
 
Signature · 1 line
2.48.1