Platform Temperature Control interface
Subsystems (2)
v2 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.
v2:
Change sysfs folder name and other cleanups
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 | 21 ++ .../thermal/intel/int340x_thermal/Makefile | 1 + .../platform_temperature_control.c | 243 ++++++++++++++++++ .../processor_thermal_device.c | 15 +- .../processor_thermal_device.h | 3 + .../processor_thermal_device_pci.c | 5 +- 6 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
Signature · 1 line
2.49.0
PATCH v2 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.
Given that this is platform temperature control, it is expected that a single user-level manager owns and manages the controls. If multiple user-level software applications attempt to write different targets, it can lead to unexpected behavior. For instance, on a Linux desktop, the Linux thermal daemon can manage these temperature controls, as it has access to all other temperature control settings.
The hardware control interface is via MMIO offsets in the processor thermal device MMIO space. There are three instances of MMIO registers. Refer to the platform_temperature_control.c for MMIO details.
Expose "enable" and "temperature_target" 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/ptc_?_control/ /sys/bus/pci/devices/0000:00:04.0/ptc_0_control/
├── enable └── temperature_target /sys/bus/pci/devices/0000:00:04.0/ptc_1_control/ ├── enable └── temperature_target /sys/bus/pci/devices/0000:00:04.0/ptc_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.
---
v2:
Rui's comments:
- Change ptc_offsets[] to ptc_offsets[PTC_MAX_INSTANCES]
Rafael's comments:
- Update commit log to remove register definition
- Moved the register definition to .c file
- Add mutex lock for concurrency
- Moved the majority of the code from macro to a function
- Use GENMASK_ULL
- Change platform_temperature_*_control to ptc_*_control for syfs folder name
.../thermal/intel/int340x_thermal/Makefile | 1 + .../platform_temperature_control.c | 243 ++++++++++++++++++ .../processor_thermal_device.c | 15 +- .../processor_thermal_device.h | 3 + 4 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
drivers/thermal/intel/int340x_thermal/Makefile +1 -0
@@ -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 +243 -0
243 lines not on this page · raw message
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +14 -1
@@ -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
@@ -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.49.0
PATCH v2 2/3 thermal: intel: int340x: Enable platform temperature control
In reply to Srinivas PandruvadaEnable platform temperature control feature for Lunar Lake and Panther Lake.
---
v2:
No change
.../intel/int340x_thermal/processor_thermal_device_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +3 -2
@@ -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_DVFS | - 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) },
@@ -497,7 +498,7 @@ static const struct pci_device_id proc_thermal_pci_ids[] = { {PCI_DEVICE_DATA (INTEL ,PTL_THERMAL ,PROC_THERMAL_FEATURE_RAPL |PROC_THERMAL_FEATURE_DLVR |PROC_THERMAL_FEATURE_DVFS |PROC_THERMAL_FEATURE_MSI_SUPPORT |PROC_THERMAL_FEATURE_WT_HINT | - PROC_THERMAL_FEATURE_POWER_FLOOR) }, + PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC) }, { }, };
Signature · 1 line
2.49.0
PATCH v2 3/3 thermal: int340x: processor_thermal: Platform temperature control documentation
In reply to Srinivas PandruvadaUpdate documentation of attributes for platform temperature control.
---
v2:
- Change the sysfs folder name
- Add comment about singe user level manager
.../driver-api/thermal/intel_dptf.rst | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
Documentation/driver-api/thermal/intel_dptf.rst +21 -0
@@ -191,6 +191,27 @@ ABI. User space can specify any one of the available workload type using this interface. +:file:`/sys/bus/pci/devices/0000\:00\:04.0/ptc_0_control` +:file:`/sys/bus/pci/devices/0000\:00\:04.0/ptc_1_control` +:file:`/sys/bus/pci/devices/0000\:00\:04.0/ptc_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. + +Given that this is platform temperature control, it is expected that a +single user-level manager owns and manages the controls. If multiple +user-level software applications attempt to write different targets, it +can lead to unexpected behavior. + + DPTF Processor thermal RFIM interface --------------------------------------------
Signature · 1 line
2.49.0
Rafael J. Wysocki
maintainerQuoted 27 lines · Srinivas Pandruvada
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.
v2:
Change sysfs folder name and other cleanupsSrinivas 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 | 21 ++ .../thermal/intel/int340x_thermal/Makefile | 1 + .../platform_temperature_control.c | 243 ++++++++++++++++++ .../processor_thermal_device.c | 15 +- .../processor_thermal_device.h | 3 + .../processor_thermal_device_pci.c | 5 +- 6 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
Quoted 1 line
--
All three patches applied as 6.16 material, thanks!