Thermal 子系统架构与源码总览

Thermal 子系统架构与源码总览

1. 模型

1
2
3
4
5
6
7
8
9
10
11
temperature sensor
|
thermal_zone_device
|
trips + governor
|
thermal_instance
|
thermal_cooling_device
|
CPUFreq / Devfreq / fan / power actor

2. 对象

  • thermal_zone_device:温区、温度、trips、policy;
  • thermal_trip:temperature、hysteresis、type;
  • thermal_cooling_device:可调 cooling state;
  • thermal_instance:某 zone/trip与 cdev的绑定、上下限、weight、target;
  • thermal_governor:计算 target;
  • sensor ops:get_temp/set_trips等。

3. 更新链

1
2
3
4
5
6
7
8
9
poll/IRQ/driver event
-> thermal_zone_device_update()
-> thermal_zone_get_temp()
-> update trend
-> handle each trip
-> governor->throttle()
-> instance target
-> thermal_cdev_update()
-> cdev->set_cur_state()

4. Trip

  • active:主动散热;
  • passive:降频/功率限制;
  • hot:平台定义热状态;
  • critical:关机。

hysteresis避免阈值附近抖动。

5. Governors

  • step_wise;
  • fair_share;
  • bang_bang;
  • user_space;
  • power_allocator。

本树 RK3588主配置默认选择 power_allocator,不是常见默认 step_wise。

6. Interfaces

  • sysfs:zone/cdev状态和 policy;
  • generic netlink:查询与事件;
  • hwmon bridge:温度只读展示;
  • tracepoints;
  • OF thermal zones;
  • uevent。

7. RK3588

RK3588使用 rockchip_thermal.c

  • 7个 TSADC channels;
  • code-table插值;
    -高温 IRQ;
    -硬件 TSHUT;
  • CRU/GPIO模式;
  • suspend/resume;
  • panic dump。

DTS定义 soc、bigcore0、bigcore1、littlecore、center、GPU、NPU七个 zone。

8. 冷却拓扑

公共 DTS只有 soc-thermal 的 85°C target绑定:

  • little CPU;
  • big CPU cluster 0;
  • big CPU cluster 1;
  • GPU。

其它六个 zone只定义115°C critical trip,不直接绑定 cooling map。

9. 双重保护

  • 软件 critical trip:115°C,orderly poweroff;
  • TSADC hardware TSHUT:DTS 120°C,CRU reset模式。

硬件阈值高于软件 critical,形成最后防线。

10. 边界

Thermal负责控制策略;hwmon负责观测和 sensor阈值;devfreq/cpufreq实现执行动作;regulator只提供电源资源。不能把这些 sysfs接口混作同一控制平面。

文章互动

阅读 --

留言

0 条留言

正在加载留言…