节点信息解释
Thermal sysfs节点位置---/sys/class/thermal
每个thermal_zone下面代表一个sensor对应的抽象,每个节点的基本含义如下
Thermal zone device sys I/F, created once it's registered:
/sys/class/thermal/thermal_zone[0-*]:
|---type: Type of the thermal zone
|---temp: Current temperature
|---mode: Working mode of the thermal zone
|---policy: Thermal governor used for this zone
|---available_policies: Available thermal governors for this zone
|---trip_point_[0-*]_temp: Trip point temperature
|---trip_point_[0-*]_type: Trip point type
|---trip_point_[0-*]_hyst: Hysteresis value for this trip point
|---emul_temp: Emulated temperature set node
|---sustainable_power: Sustainable dissipatable power
|---k_po: Proportional term during temperature overshoot
|---k_pu: Proportional term during temperature undershoot
|---k_i: PID's integral term in the power allocator gov
|---k_d: PID's derivative term in the power allocator
|---integral_cutoff: Offset above which errors are accumulated
|---slope: Slope constant applied as linear extrapolation
|---offset: Offset constant applied as linear extrapolation
补充:
passive :(被动)默认是0,表示disabled,也可以设置以millidegrees为单位的温度值,来使能被动的trip point for this zone
policy : 一种当前thermal zone的thermal governor, mtk用的只有backward_compatible(温度大于等于设定,对应的cooling device set_cur_state=1,温度小于设定,对应的cooling device set_cur_state=0), 高通的是多种的,有 low_limits_floor low_limits_cap user_space step_wise 等
mode : [enable/disable] enabled = enable Kernel Thermal management , disabled 表示应用程序来调节thermal,内核不管(mtk默认使用私有的应用层程序来管理)
Thermal cooling device sys I/F, created once it's registered:
/sys/class/thermal/cooling_device[0-*]:
|---type: Type of the cooling device(processor/fan/...)
|---max_state: Maximum cooling state of the cooling device
|---cur_state: Current cooling state of the cooling device
Kernel thermal governor --- step_wise 分析:
step_wise --- 根据温度变化趋势来确定,如果thermal_zone温度是逐渐升高的,则对应的cooling device会采取对应的降温措施,如果thermal_zone温度是降低的,则会逐渐恢复性能限制。
对应判断的状态枚举参数如下
enum thermal_trend {
THERMAL_TREND_STABLE, /* temperature is stable */
THERMAL_TREND_RAISING, /* temperature is raising */
THERMAL_TREND_DROPPING, /* temperature is dropping */
THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
};
throttle函数
static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
{
struct thermal_instance *instance;
thermal_zone_trip_update(tz, trip); //根据当前温度和上次温度对比,得到温度趋势;然后根据温度趋势得出Cooling设备对应的state。
if (tz->forced_passive)
thermal_zone_trip_update(tz, THERMAL_TRIPS_NONE);
mutex_lock(&tz->lock);
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);//遍历cdev->thermal_instances选择最深的cooling状态。然后调用cdev->ops->set_cur_state()中
mutex_unlock(&tz->lock);
return 0;
}