openbmc-风扇自动调速框架分析
Overview
openbmc散热控制实现主要是在phosphor-pid-control中完成,它使用简单的配置文件来控制系统组件内部温度。
BMC将运行一个守护程序,通过预定义的区域控制风扇。这个应用程序将使用 thermal control,并基于从本地传感器获取到的信息和ipmi oem命令,使每个定义的区域温度保持在一个范围内。
Configuring - How to configure phosphor-pid-control?
散热控制有两种方式来配置phosphor-pid-control
1、使用entity-manager解析出来的数据作为输入,该方式为默认方式,不支持动态修改参数(默认运行方式)
2、phosphor-pid-control支持重新加载配置文件,可以在串口下新增配置文件,重启服务进行解析(调试使用)
D-Bus Configuration
如果配置文件不存在,会使用dbus作为数据获取来源。 当使用entity-manager提供的pid,pid.Zone和Stepwise时,配置的key值与json文件方式是不同的,但是最终他们可以产生相同的作用。
entity-manager解析的配置是不可修改的,作为默认的配置文件供各模块使用。
JSON Configuration
phosphor-pid-control支持以入参形式修改相关配置加载方式。
默认的配置文件路径为/usr/share/swampd/config.json,它可以被--conf/-c参数进行修改。
配置文件中应该有两个关键字段,sensors和zones,sensors是传感器的集合,zones是区域的集合。
Sensors
```
"sensors" : [{"name": "fan1","type": "fan","readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1","writePath": "/sys/devices/platform/ahb/ahb:apb/1e786000.pwm-tacho-controller/hwmon/**/pwm1","min": 0,"max": 255,"ignoreDbusMinMax": true},{"name": "fan2","type": "fan","readPath": "/xyz/openbmc_project/sensors/fan_tach/fan2","writePath": "/sys/devices/platform/ahb/ahb:apb/1e786000.pwm-tacho-controller/hwmon/**/pwm2","min": 0,"max": 255,"timeout": 4,},
...
```
每个传感器下配置如下
name:传感器名称,用于和传感器配置匹配。
type:传感器类型,目前支持三种类型:fan、temp、margin
readPath(optional):传感器数值的读取路径
writePath(optional):传感器数值的写入路径
min/max(optional):当max不为0时,写入的数值应为最小值和最大值之间的最大值。
timeout(optional):用于控制传感器故障行为,如果传感器是fan类型,则默认时间为2s,否则为0s。当一个传感器的超时值为0则不会检测读取失败的情况。如果一个传感器在超时时间内读取失败,这块区域将进入故障保护状态。
Zones
"zones" : [{"id": 1,"minThermalOutput": 3000.0,"failsafePercent": 75.0,"pids": [],}
]
每个区域都有自己的控制器列表,如下
| field | type | meaning |
|---|---|---|
id | int64_t | 区域唯一标识 |
minThermalOutput | double | 通常是最小风扇转速 |
failsafePercent | double | 如果区域进入异常模式,则使用这个值设置风扇转速 |
pids | list of strings | 控制器集合 |
每个zone会收集所有的setpoint以及温度控制器中的热量上限,选择最大的setpoint,通过最小上限和minThermalOutput来控制风扇。
注意:每个zone内都最少拥有一个风扇进行控制,但是区域内的温度传感器可以共享
Controllers
一共有四种类型的控制器,如fan、temp、margin(PID)、stepwise(discrete steps)
当前我们使用的调速方式为fan和temp的两层调速,第一层输入为温度,输出为转速,第二层输入为风扇转速,输出为风扇PWM,
第一层setpoint为目标温度,第二层setpoint为第一层输出
type == fan
fan用于驱动风扇或者其他冷却设备,它是从所属区域获取setpoint,然后将风扇调速到该状态。通常它的输入为temp的输出
"name": "fan1-5",
"type": "fan",
"inputs": ["fan1", "fan5"],
"setpoint": 90.0,
"pid": {
...
}
name | string | 名称 |
|---|---|---|
type | string | fan |
inputs | `list of strings | 输入的传感器集合 |
| field | type | meaning |
setpoint | double | 暂不使用 |
pid | dictionary | PID参数集合 |
type == margin
margin用于驱动给定补偿值的设定点(值越低表示温度越高)。
"name": "fleetingpid0",
"type": "margin",
"inputs": ["fleeting0"],
"setpoint": 10,
"pid": {
...
}
| field | type | meaning |
|---|---|---|
name | string | 名称 |
type | string | margin |
inputs | list of strings | 输入传感器集合 |
setpoint | double | 补偿温度 |
pid | dictionary | PID参数集合 |
从所有输入中选择最小值,并将其用作PID回路的输入
type == temp
temp是以温度传感器作为输入进行调速,输出为目标转速
与margin完全相同,但是所有输入都应该是绝对温度,因此使用最大值作为PID回路输入
type == stepwise (线性调速?)
"name": "temp1",
"type": "stepwise",
"inputs": ["temp1"],
"setpoint": 30.0,
"pid": {"samplePeriod": 0.1,"positiveHysteresis": 1.0,"negativeHysteresis": 1.0,"isCeiling": false,"reading": {"0": 45,"1": 46,"2": 47,},"output": {"0": 5000,"1": 2400,"2": 2600,}
}
相关字段含义如下
| field | type | meaning |
|---|---|---|
name | string | 名称 |
type | string | stepwise |
inputs | list of strings | 输入传感器集合 |
pid | dictionary | PID参数集合 |
PID字段解析
if type == “stepwise”
| field | type | meaning |
|---|---|---|
samplePeriod | double | 暂未使用 |
reading | dictionary | 从0开始索引的输入值枚举列表必须单调递增,最多20个项目。 |
output | dictionary | 从0开始索引的输出值的枚举列表必须与“读取”项的数量匹配。 |
positiveHysteresis | double | 输入值必须升高多少才能切换到下一步。 |
negativeHysteresis | double | 输入值必须下降多少才能切换到上一步。 |
isCeiling | bool | 该控制器是否为区域提供设置点或上限 |
setpoint | double | 暂未使用 |
if type != “stepwise”
| field | type | meaning |
|---|---|---|
samplePeriod | double | 采样值频率,风扇为0.1,温度为1.0 |
proportionalCoeff | double | 比例系数 |
integralCoeff | double | 积分系数 |
feedFwdOffsetCoeff | double | 前馈补偿系数 |
feedFwdGainCoeff | double | 前馈增益系数 |
integralLimit_min | double | 积分最小门限 |
integralLimit_max | double | 积分最大门限 |
outLim_min | double | 最小输出门限 |
outLim_max | double | 最大输出门限 |
slewNeg | double | 抑制输出的负转换值 |
slewPos | double | 加速输出的正转换值 |
详细设计(待补充)
该软件将会使用多线程进行控制,每个区域都会有一个专门的守护进程,并且拥有一个监听dbus消息的主线程。每个区域
将需要至少一个由其专门控制的风扇,但是,区域可以共享温度传感器。
Zone Specification
每个主板都需要有一个配置文件。
每个区域必须至少有一个由其独占控制的风扇。每个区域必须至少有一个温度传感器,但它们可以共享。
指定的内部温度可以通过sysfs或dbus读取。
IPMI Access to Phosphor-pid-control
当前已支持的ipmi命令如下
OEM Set Control
主机需要能够将控制模式设置为自动或手动。
手动模式下,守护程序会等待重新设置为自动模式。
Request
| Byte | Purpose | Value |
|---|---|---|
| 00 | netfn | 0x2e |
| 01 | command | 0x04 (also using manual command) |
| 02 | oem1 | 0xcf |
| 03 | oem2 | 0xc2 |
| 04 | padding | 0x00 |
| 05 | SubCommand | Get or Set. Get == 0, Set == 1 |
| 06 | ZoneId | |
| 07 | Mode | If Set, Value 1 == Manual Mode(手动模式), 0 == Automatic Mode(自动模式) |
Response
| Byte | Purpose | Value |
|---|---|---|
| 02 | oem1 | 0xcf |
| 03 | oem2 | 0xc2 |
| 04 | padding | 0x00 |
| 07 | Mode | If Set, Value 1 == Manual Mode, 0 == Automatic Mode |
OEM Get Failsafe Mode
判断当前是否为故障保护状态
Request
| Byte | Purpose | Value |
|---|---|---|
| 00 | netfn | 0x2e |
| 01 | command | 0x04 (also using manual command) |
| 02 | oem1 | 0xcf |
| 03 | oem2 | 0xc2 |
| 04 | padding | 0x00 |
| 05 | SubCommand | Get == 2 |
| 06 | ZoneId |
Response
| Byte | Purpose | Value |
|---|---|---|
| 02 | oem1 | 0xcf |
| 03 | oem2 | 0xc2 |
| 04 | padding | 0x00 |
| 07 | failsafe | 1 == in Failsafe Mode, 0 not in failsafe mode |
Two Margin Sensors Into Three Fans (Non-Step PID)
A single zone system where multiple margin thermal sensors are fed into one PID
that generates the output RPM for a set of fans controlled by one PID.margin sensors as input to thermal pidfleeting0+---->+-------+ +-------+ Thermal PID sampled| min()+--->+ PID | slower rate.
fleeting1+---->+-------+ +---+---+||| RPM setpointCurrent RPM v+--+-----+The Fan PID fan0+---> | New PWM +-->fan0samples at a | | |faster rate fan1+---> PID +---------->--->fan1speeding up the | | |fans. fan2+---> | +-->fan2^ +--------+ +| |+-------------------------------+RPM updated by PWM.
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
