ACPI Processor Clock Throttling

ACPI specification

In the ACPI specification. The processor passive cooling threshold (_PSV) in conjunction with the processor list (_PSL) allows the platform to indicate the temperature at which a passive control, for example clock throttling, will be applied to the processor(s) residing in a given thermal zone. Unlike other cooling policies, during passive cooling of processors OSPM may take the initiative to actively monitor the temperature in order to cool the platform.

On an ACPI-compatible platform that properly implements CPU throttling, the temperature transitions will be similar to the following figure, in a coolable environment, running a coolable workload:

The following equation should be used by OSPM to assess the optimum CPU performance change necessary to lower the thermal zone’s temperature:

ΔP[%]=_TC1∗(Tn−Tn−1)+_TC2∗(Tn−Tt)

Tn = current temperature

Tt = target temperature (_PSV)

The two coefficients _TC1 and _TC2 and the sampling period _TSP are hardware-dependent constants the OEM must supply to OSPM (for more information, see Section 11.4). The _TSP object contains a time interval that OSPM uses to poll the hardware to sample the temperature. Whenever the time value returned by _TSP has elapsed, OSPM will evaluate _TMP to sample the current temperature (shown as Tn in the above equation). Then OSPM will use the sampled temperature and the passive cooling temperature trip point (_PSV) (which is the target temperature Tt) to evaluate the equation for ΔP. The granularity of ΔP is determined by the CPU duty width of the system.

Pn=Pn−1+HW[−?P]

Minimum%<=Pn<=100%
For this equation, whenever Pn-1 + ?P lies outside the range Minimum0-100%, then Pn will be truncated to Minimum0-100%. Minimum% is the _MTL limit, or 0% if _MTL is not defined. For hardware that cannot assume all possible values of Pn between Minimum0 and 100%, a hardware specific mapping function HW is used.

Current status in kernel

In the linux kernel, the implementation commit ID of Processor Clock Throttling is d9460fd227ed2ce52941b6a12ad4de05c195f6aa.

It implements ACPI Processor Clock Throttling for X86. The commit message as below.

Only supports 4 throttling states for cpufreq control, Obviously, it doesn't work with the ARM platform.

Solution

We need implement a thermal governor for standard ACPI Processor Clock Throttling. It will extend the processor cooling state form 4 to 100.

As the max_state increase in ARM64, the calculation of max_freq changes. Before this, the max_freq decreases by twenty percent for each increase in state. After this solution, the max_freq decreases by one percent for each increase in state.

The commit(ACPI Thermal: Add a new governor for Thermal (83eb2db9) · Commits · LinaroLtd / clientpc / linux · GitLab) implement the governor. In the function get_delta_performance , calculate the target delta performance:

static int get_delta_performance(struct thermal_instance *instance, int *delta_p) { int ret; unsigned int tc1, tc2; int cur_temp, pre_temp, trip_temp; struct thermal_zone_device *tz; int trip; tz = instance->tz; trip = instance->trip; ret = get_para(tz, &tc1, &tc2); if (ret) return ret; ret = get_temp(tz, &pre_temp, &cur_temp); if (ret) return ret; ret = get_trip_temp(tz, trip, &trip_temp); if (ret) return ret; *delta_p = tc1 * (cur_temp - pre_temp) + tc2 * (cur_temp - trip_temp); return 0; }

The get_target_state function using the delta performance to calculate the target state.

static int get_target_state(struct thermal_instance *instance) { int ret; unsigned long next_state; int cur_p; int delta_p; int performance; ret = get_delta_performance(instance, &delta_p); if (ret) return ret; ret = get_processor_performance(instance, &cur_p); if (ret) return ret; performance = clamp((cur_p - delta_p), MIN_PERFORMANCE, MAX_PERFORMANCE); next_state = MAX_PERFORMANCE - performance; instance->target = next_state; return 0; }

It will update the instance->target, then the system will change the cooling device’s state by the target value.

 

Reference:

11.1. Thermal Control — ACPI Specification 6.4 documentation (uefi.org)

Commits · thermal_acpi · LinaroLtd / clientpc / linux · GitLab