diff options
author | Sameer Nanda <snanda@chromium.org> | 2012-09-27 14:46:17 -0700 |
---|---|---|
committer | Sameer Nanda <snanda@chromium.org> | 2012-10-01 15:58:46 -0700 |
commit | 0959ee772a5bddd3a1e7068c0fb778794df7a1c7 (patch) | |
tree | 1c3b9caae85d1fa007121478851925844fa95a3d | |
parent | 2249e4e1278dd6d434ce1612213afde4c77be362 (diff) | |
download | chrome-ec-0959ee772a5bddd3a1e7068c0fb778794df7a1c7.tar.gz |
Update temp_metrics to look at skin temperatures
Updated temp_metrics to take the skin temperature into account instead
of PECI CPU temperature for controlling fan speed as well as Ivy Bridge
throttling.
BUG=chrome-os-partner:9193
TEST=Vary CPU and GPU load on the system. The fan speed and CPU/GPU
limits should change as the skin temperature responds to changes in the
load.
BRANCH=link
Change-Id: Ie3d85112de1043cf5b12a78ca1fc50f5eb6c0497
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34221
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit bb66bec788c9447976d1be56f69a40b6c1ea36a3)
Reviewed-on: https://gerrit.chromium.org/gerrit/34388
-rw-r--r-- | util/temp_metrics.conf | 157 |
1 files changed, 127 insertions, 30 deletions
diff --git a/util/temp_metrics.conf b/util/temp_metrics.conf index 6a2aa3fc30..adca6850de 100644 --- a/util/temp_metrics.conf +++ b/util/temp_metrics.conf @@ -21,7 +21,6 @@ respawn script TEMP_OFFSET=273 # difference between K (reported by EC) and C (used in UMA) - PECI_TEMP_THRESHOLD=77 # CPU temperature threshold # Thermal loop fields CPU_MAX_FREQ_FIELD=1 @@ -56,7 +55,6 @@ script } get_field() { - #out=$(echo "$2" | awk -v z=$1 '{print $z}') out=$(echo "$2" | awk "{print \$$1}") echo $out } @@ -67,6 +65,47 @@ script echo $tempc } + get_sensor_temp() { + s=$1 + tempk=$(ectool temps $s | sed 's/[^0-9]//g') + tempc=$((tempk - $TEMP_OFFSET)) + echo $tempc + } + + get_sensor_list() { + # USB C-Object: 1 or 13 + # PCH D-Object: 3 + # Hinge C-Object: 5 or 15 + # Charger D-Object: 7 + if ectool tempsinfo 1 | grep -q "USB C-Object"; then + usb_c_object=1 + else + usb_c_object=13 + fi + pch_d_object=3 + charger_d_object=7 + echo $usb_c_object $pch_d_object $charger_d_object + } + + max_skin_temp=0 + sensor_temperatures="" + get_max_skin_temp() { + sensor_temperatures="" + max_skin_temp=0 + for i in $*; do + t=$(get_sensor_temp $i) + sensor_temperatures=$sensor_temperatures$i:$t: + if [ $t -gt $max_skin_temp ]; then + max_skin_temp=$t + fi + done + + # Record the PECI CPU temperature also. + i=9 + t=$(get_sensor_temp $i) + sensor_temperatures=$sensor_temperatures$i:$t: + } + set_cpu_freq() { max_freq=$1 min_freq=$2 @@ -99,23 +138,66 @@ script wrmsr 0 0x1fc 0x000000000004005e } + disable_tcc_offset() { + wrmsr 0 0x1a2 0 + } + + log_message() { + logger -t temp_metrics "$*" + } + + TEMP_THRESHOLD_1=40 + TEMP_THRESHOLD_2=45 + TEMP_THRESHOLD_3=50 + + TEMP_THRESHOLD_1_MIN_STEP=0 + TEMP_THRESHOLD_1_MAX_STEP=4 + TEMP_THRESHOLD_2_MIN_STEP=5 + TEMP_THRESHOLD_2_MAX_STEP=9 + TEMP_THRESHOLD_3_MIN_STEP=10 + TEMP_THRESHOLD_3_MAX_STEP=13 + current_step=1 new_step=0 thermal_loop() { - peci_temp=$1 - if [ $peci_temp -gt $PECI_TEMP_THRESHOLD ]; then - if [ $current_step -ne $max_steps ]; then + # Hack to reset turbo activation threshold since BIOS can change it + # underneath us. + wrmsr 0 0x64c 0x12 + + skin_temp=$1 + if [ $skin_temp -gt $TEMP_THRESHOLD_3 ]; then + temp_threshold=$TEMP_THRESHOLD_3 + min_step=$TEMP_THRESHOLD_3_MIN_STEP + max_step=$TEMP_THRESHOLD_3_MAX_STEP + elif [ $skin_temp -gt $TEMP_THRESHOLD_2 ]; then + temp_threshold=$TEMP_THRESHOLD_2 + min_step=$TEMP_THRESHOLD_2_MIN_STEP + max_step=$TEMP_THRESHOLD_2_MAX_STEP + else + temp_threshold=$TEMP_THRESHOLD_1 + min_step=$TEMP_THRESHOLD_1_MIN_STEP + max_step=$TEMP_THRESHOLD_1_MAX_STEP + fi + + if [ $skin_temp -gt $temp_threshold ]; then + if [ $current_step -ne $max_step ]; then new_step=$(($current_step + 1)) fi - elif [ $peci_temp -lt $PECI_TEMP_THRESHOLD ]; then - if [ $current_step -gt 0 ]; then + elif [ $skin_temp -lt $temp_threshold ]; then + if [ $current_step -gt $min_step ]; then new_step=$(($current_step - 1)) fi else new_step=$current_step fi + if [ $new_step -gt $max_step ]; then + new_step=$max_step + elif [ $new_step -lt $min_step ]; then + new_step=$min_step + fi + if [ $new_step -eq $current_step ]; then return fi @@ -123,6 +205,8 @@ script current_step=$new_step step=$(get_step $new_step) + log_message "Throttling (temps: $sensor_temperatures):" $step + cpu_max_freq=$(get_field $CPU_MAX_FREQ_FIELD "$step") cpu_min_freq=$(get_field $CPU_MIN_FREQ_FIELD "$step") gpu_max_freq=$(get_field $GPU_MAX_FREQ_FIELD "$step") @@ -151,28 +235,28 @@ script temp_low5=105 fan_loop() { - peci_temp=$1 + skin_temp=$1 - if [ $peci_temp -gt 77 ] || [ $peci_temp -gt $temp_low1 ]; then + if [ $skin_temp -gt 48 ] || [ $skin_temp -gt $temp_low1 ]; then rpm=9300 fan_reset_thresholds - temp_low1=68 - elif [ $peci_temp -gt 68 ] || [ $peci_temp -gt $temp_low2 ]; then - rpm=7725 + temp_low1=46 + elif [ $skin_temp -gt 45 ] || [ $skin_temp -gt $temp_low2 ]; then + rpm=7800 fan_reset_thresholds - temp_low2=61 - elif [ $peci_temp -gt 61 ] || [ $peci_temp -gt $temp_low3 ]; then - rpm=6150 + temp_low2=43 + elif [ $skin_temp -gt 42 ] || [ $skin_temp -gt $temp_low3 ]; then + rpm=6000 fan_reset_thresholds - temp_low3=54 - elif [ $peci_temp -gt 54 ] || [ $peci_temp -gt $temp_low4 ]; then - rpm=4575 + temp_low3=39 + elif [ $skin_temp -gt 38 ] || [ $skin_temp -gt $temp_low4 ]; then + rpm=4000 fan_reset_thresholds - temp_low4=47 - elif [ $peci_temp -gt 47 ] || [ $peci_temp -gt $temp_low5 ]; then + temp_low4=34 + elif [ $skin_temp -gt 33 ] || [ $skin_temp -gt $temp_low5 ]; then rpm=3000 fan_reset_thresholds - temp_low5=41 + temp_low5=30 else rpm=0 fan_reset_thresholds @@ -182,6 +266,8 @@ script return fi + log_message "Setting fan RPM (temps: $sensor_temperatures): $last_rpm -> $rpm" + last_rpm=$rpm ectool pwmsetfanrpm $rpm } @@ -189,22 +275,33 @@ script # External prochot misfires occasionally. Disable it. disable_external_prochot + # Set TCC offset to 0. + disable_tcc_offset + + # Get list of sensors to monitor. + sensor_list=$(get_sensor_list) + loop_count=0 while true; do - sleep 1 + sleep 10 loop_count=$(($loop_count + 1)) - # read the CPU temperature - cpu_temp=$(get_peci_temp) + # Read the max skin temperature. + get_max_skin_temp $sensor_list + + if [ $max_skin_temp -eq 0 ]; then + # TODO (snanda): use PECI temperature as a fallback. + log_message "Invalid max skin temp" + fi - # run the fan loop once a second - fan_loop $cpu_temp + # Run the fan loop every 10 seconds. + fan_loop $max_skin_temp - # run the thermal loop once a second - thermal_loop $cpu_temp + # Run the thermal loop every 10 seconds. + thermal_loop $max_skin_temp - # report the metrics once every 30 seconds - if [ $loop_count -lt 30 ]; then + # Report the metrics once every 30 seconds. + if [ $loop_count -lt 3 ]; then continue fi loop_count=0 |