一点点读懂thermal(一)

本文介绍了Linux Kernel的thermal子系统,主要负责温度控制。它包括thermal_core、thermal_zone_device和cooling_device三部分,分别对应核心、温度区设备和冷却设备。通过对zone_device和cooling_device的注册接口分析,阐述了它们如何关联并处理温度事件,以及governor的角色。此外,还讨论了处理critical和非critical事件的流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

1、thermal简介

2、thermal_core分析

2.1 zone_device注册相关接口

2.1.1 关键结构体

2.1.2 接口

2.2 Cooling_device注册相关接口

2.2.1关键结构体

2.2.2 接口

2.3 Governors注册相关接口

2.4 关于critial事件和非critial事件的处理流程


1、thermal简介

     thermal模块主要负责温度控制,温度低时想办法升温,温度高时想办法降温,甚至复位系统。Linux kernel有个通用的思想就是抽象分层,比如把该子系统所有资源和信息综合在一起的一层叫core层,不同的设备的操作叫device层,对设备的操作的屏蔽层叫driver层或者governor。同样thermal子系统也是采用了该思想:核心为 thermal_core,可以获取温度的设备抽象为 thermal_zone_device, 如Temp Sensor、NTC(板上的热敏电阻)等。控制温度的设备抽象为 thermal_cooling_device, 如风扇、CPU、DDR、GPU等。温控策略抽象为 thermal_governor,比如 step_wise、bang_bang 等。

       thermal_cooling_device 对应系统实施冷却措施的驱动,是温控的执行者。cooling device 维护一个 cooling 等级,即 state,一般 state 越高即系统的冷却需求越高。cooling device 根据不同等级的冷却需求进行冷却行为。cooling device 只根据 state 进行冷却操作,是实施者,而 state 的计算由 thermal governor 完成。结构 struct cpufreq_cooling_device 和 struct devfreq_cooling_device 作为对 thermal_cooling_device 的扩展,分别主要在 cpufreq_cooling.c 和 devfreq_cooling.c 中使用。

2、thermal_core分析

       thermal_core作为thermal的核心部分,负责把governor\cool device\zone_device关联在一起,因此thermal_core就需要提供注册接口和作为记录的全局变量来记录注册的信息:

2.1 zone_device注册相关接口

2.1.1 关键结构体

/**
 * struct thermal_zone_device - structure for a thermal zone
 * @id:		unique id number for each thermal zone
 * @type:	the thermal zone device type
 * @device:	&struct device for this thermal zone
 * @trip_temp_attrs:	attributes for trip points for sysfs: trip temperature
 * @trip_type_attrs:	attributes for trip points for sysfs: trip type
 * @trip_hyst_attrs:	attributes for trip points for sysfs: trip hysteresis
 * @mode:		current mode of this 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值