contrib: add surface pro 5 thermald configuration

This commit is contained in:
Yatao Li 2021-08-25 18:45:47 +08:00
parent 265bfba993
commit 914cc11a39
7 changed files with 367 additions and 0 deletions

View file

@ -0,0 +1,38 @@
# Use `udevadm monitor` to find out what's going on (e.g. unplugged)
# For example:
# monitor will print the received events for:
# UDEV - the event which udev sends out after rule processing
# KERNEL - the kernel uevent
#
# KERNEL[3565.169206] change /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1 (power_supply)
# UDEV [3565.178952] change /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1 (power_supply)
# KERNEL[3565.179618] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
# UDEV [3565.195004] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
# KERNEL[3587.183562] change /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1 (power_supply)
# UDEV [3587.190598] change /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1 (power_supply)
# KERNEL[3587.207545] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
# UDEV [3587.216793] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT1 (power_supply)
#
# Then, use `udevadm info --path /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1 to find out
# the events we can use:
# P: /devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1
# L: 0
# E: DEVPATH=/devices/LNXSYSTM:00/ACPI0003:00/power_supply/ADP1
# E: POWER_SUPPLY_NAME=ADP1
# E: POWER_SUPPLY_TYPE=Mains
# E: POWER_SUPPLY_ONLINE=0
# E: SUBSYSTEM=power_supply
# Plugged
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/logger -t surface power supply online"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/surface profile set performance"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/ln -sf /etc/thermald/thermal-conf.xml.auto.performance /etc/thermald/thermal-conf.xml.auto"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/systemctl restart thermald"
# Unplugged
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/logger -t surface power supply offline"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/surface profile set low-power"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/ln -sf /etc/thermald/thermal-conf.xml.auto.mobile /etc/thermald/thermal-conf.xml.auto"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/systemctl restart thermald"

View file

@ -0,0 +1,42 @@
# thermald configuration tweaked for Surface Pro 5
- thermald configuration starting point: https://github.com/intel/dptfxtract
- by default it uses sensor "GEN4", which is for the NVME drive, not good.
- pch_skylake is a better choice here.
- Takes care of `surface profile set {low-power|performance}` on power supply events.
- Restarts thermald on power events to load corresponding thermal profiles.
- There are 3 thermal profiles here:
- `thermal-conf.xml.auto.performance`: activated on AC power.
Runs at peak performance (~25watts) until reaching 60 degrees.
Stabilized at ~15watts under heavy load.
- `thermal-conf.xml.auto.mobile`: activated on battery.
Throttles early for ~15watts.
Throttles to ~8watts for heavy load.
Try to keep the device cool.
- `thermal-conf.xml.auto.cool`: reserved.
Basically, we are just using RAPL here to throttle the power (in watts), not
the frequency of the CPU, and it's more fine-grained and aligned with our
thermal targets.
See 40-surface-power.rules for more details on how to obtain info about sensors
and cooling devices.
## Installation
- Make sure to install `surface-control`
- Install `40-surface-power.rules` to `/usr/lib/udev/rules.d/`
- Install `thermal-conf.xml*` to `/etc/thermald/`
- `thermal-conf.xml.auto` will be linked dynamically by the udev rule file.
- Install `thermal-cpu-cdev-order.xml` to `/etc/thermald/`
- Install `thermald.service` to `/lib/systemd/system/` and overwrite the old one.
- Maybe install to `/usr/lib/systemd/system/` too.
- `systemctl daemon-reload`
- `systemctl restart udev`
- `systemctl restart thermald`
## TODO
- I tried to update cpufreq governor and turbo in udev event triggers but it
didn't work.
- You can install `cpufreqctl` for that.

View file

@ -0,0 +1,85 @@
<?xml version="1.0"?>
<!-- BEGIN -->
<ThermalConfiguration>
<Platform>
<Name> Auto generated </Name>
<ProductName>Surface Pro</ProductName>
<Preference>QUIET</Preference>
<PPCC>
<PowerLimitIndex>0</PowerLimitIndex>
<PowerLimitMinimum>3000</PowerLimitMinimum>
<PowerLimitMaximum>25000</PowerLimitMaximum>
<TimeWindowMinimum>28000</TimeWindowMinimum>
<TimeWindowMaximum>32000</TimeWindowMaximum>
<StepSize>500</StepSize>
</PPCC>
<ThermalZones>
<ThermalZone>
<Type>auto_zone_0</Type>
<TripPoints>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>46000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>20</SamplingPeriod>
<TargetState>15000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>49000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>20</SamplingPeriod>
<TargetState>13000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>52000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>20</SamplingPeriod>
<TargetState>11000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>56000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>20</SamplingPeriod>
<TargetState>9000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>59000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>15</SamplingPeriod>
<TargetState>7000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>62000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>6000000</TargetState>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
</Platform>
</ThermalConfiguration>
<!-- END -->

View file

@ -0,0 +1,95 @@
<?xml version="1.0"?>
<!-- BEGIN -->
<ThermalConfiguration>
<Platform>
<Name> Auto generated </Name>
<ProductName>Surface Pro</ProductName>
<Preference>QUIET</Preference>
<PPCC>
<PowerLimitIndex>0</PowerLimitIndex>
<PowerLimitMinimum>3000</PowerLimitMinimum>
<PowerLimitMaximum>15000</PowerLimitMaximum>
<TimeWindowMinimum>28000</TimeWindowMinimum>
<TimeWindowMaximum>32000</TimeWindowMaximum>
<StepSize>500</StepSize>
</PPCC>
<ThermalZones>
<ThermalZone>
<Type>auto_zone_0</Type>
<TripPoints>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>39000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>15000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>43000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>10000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>47000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>8000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>49000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>6000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>51000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>5000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>53000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>4000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>54000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>3000000</TargetState>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
</Platform>
</ThermalConfiguration>
<!-- END -->

View file

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<!-- BEGIN -->
<ThermalConfiguration>
<Platform>
<Name> Auto generated </Name>
<ProductName>Surface Pro</ProductName>
<Preference>QUIET</Preference>
<PPCC>
<PowerLimitIndex>0</PowerLimitIndex>
<PowerLimitMinimum>3000</PowerLimitMinimum>
<PowerLimitMaximum>15000</PowerLimitMaximum>
<TimeWindowMinimum>28000</TimeWindowMinimum>
<TimeWindowMaximum>32000</TimeWindowMaximum>
<StepSize>500</StepSize>
</PPCC>
<ThermalZones>
<ThermalZone>
<Type>auto_zone_0</Type>
<TripPoints>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>54000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>15000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>58000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>10</SamplingPeriod>
<TargetState>13000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>60000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>9000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>62000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>7000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>pch_skylake</SensorType>
<Temperature>63000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>5</SamplingPeriod>
<TargetState>6000000</TargetState>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
</Platform>
</ThermalConfiguration>
<!-- END -->

View file

@ -0,0 +1,18 @@
<!--
Specifies the order of compensation to cool CPU only.
There is a default already implemented in the code, but
this file can be used to change order
The Following cooling device can present
-->
<CoolingDeviceOrder>
<!-- Specify Cooling device order -->
<CoolingDevice>rapl_controller</CoolingDevice>
<CoolingDevice>intel_pstate</CoolingDevice>
<CoolingDevice>intel_powerclamp</CoolingDevice>
<CoolingDevice>cpufreq</CoolingDevice>
<CoolingDevice>Processor</CoolingDevice>
</CoolingDeviceOrder>

View file

@ -0,0 +1,14 @@
[Unit]
Description=Thermal Daemon Service
ConditionVirtualization=no
[Service]
Type=dbus
SuccessExitStatus=1
BusName=org.freedesktop.thermald
ExecStart=/usr/sbin/thermald --systemd --dbus-enable
[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.thermald.service