diff -Nru thermald-1.7.0/debian/changelog thermald-1.7.0/debian/changelog --- thermald-1.7.0/debian/changelog 2019-01-15 07:29:41.000000000 +0800 +++ thermald-1.7.0/debian/changelog 2019-08-08 19:24:30.000000000 +0800 @@ -1,3 +1,12 @@ +thermald (1.7.0-5ubuntu3) bionic; urgency=medium + + * Maintain consistent power usage under high CPU load (LP: #1811730) + - without this fix, some machines exhibit a sharp drop of power usage and + CPU frequency upon high system loading and then takes time to slowly + ramp up again. + + -- Anthony Wong Thu, 08 Aug 2019 11:24:30 +0000 + thermald (1.7.0-5ubuntu2) bionic; urgency=medium * Honor ACPI _CRT for processor thermal zone (LP: #1803360) diff -Nru thermald-1.7.0/debian/patches/0009-Simplify-RAPL-Cdev.patch thermald-1.7.0/debian/patches/0009-Simplify-RAPL-Cdev.patch --- thermald-1.7.0/debian/patches/0009-Simplify-RAPL-Cdev.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0009-Simplify-RAPL-Cdev.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,193 @@ +From 96e2d01798081395b3e278b885627e5e86c2a03b Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Tue, 12 Jun 2018 14:27:16 -0700 +Subject: [PATCH] Simplify RAPL Cdev + +Instead of using 0 as min state and have a logic to subtract from +phy_max, just have min state as the max power limit, which is +natural to RAPL (Higher number means lower power limit). +Since thermald can already account for min_state > max_state, +this should not be a major change. This will also remove map to +target interface to directly set raw power limit via target value +setting. +One new interface is added for setting curr_state when RAPL +settings are overriden by XML config. This will be min_state instead +of 0 now. + +Signed-off-by: Anthony Wong +--- + src/thd_cdev_rapl.cpp | 80 +++++++++++++------------------------------ + src/thd_cdev_rapl.h | 4 +-- + 2 files changed, 25 insertions(+), 59 deletions(-) + +diff --git a/src/thd_cdev_rapl.cpp b/src/thd_cdev_rapl.cpp +index b92ddee..1593924 100644 +--- a/src/thd_cdev_rapl.cpp ++++ b/src/thd_cdev_rapl.cpp +@@ -40,9 +40,9 @@ void cthd_sysfs_cdev_rapl::set_curr_state(int state, int arg) { + return; + + if (state < inc_dec_val) { +- curr_state = 0; ++ curr_state = min_state; + cdev_sysfs.write("enabled", "0"); +- new_state = phy_max; ++ new_state = min_state; + } else { + if (dynamic_phy_max_enable) { + if (!calculate_phy_max()) { +@@ -50,7 +50,7 @@ void cthd_sysfs_cdev_rapl::set_curr_state(int state, int arg) { + return; + } + } +- new_state = phy_max - state; ++ new_state = state; + curr_state = state; + cdev_sysfs.write("enabled", "1"); + } +@@ -68,50 +68,8 @@ void cthd_sysfs_cdev_rapl::set_curr_state(int state, int arg) { + } + } + +-int cthd_sysfs_cdev_rapl::map_target_state(int target_valid, int target_state) { +- if (!target_valid) +- return target_state; +- +- if (target_state > phy_max) +- return 0; +- +- return phy_max - target_state; +-} +- + void cthd_sysfs_cdev_rapl::set_curr_state_raw(int state, int arg) { +- std::stringstream state_str; +- std::stringstream tc_state_dev; +- int new_state, ret; +- +- if (bios_locked) +- return; +- +- if (state <= min_state) +- new_state = phy_max; +- else { +- if (dynamic_phy_max_enable) { +- if (!calculate_phy_max()) { +- curr_state = state; +- return; +- } +- } +- new_state = phy_max - state; +- } +- curr_state = state; +- state_str << new_state; +- +- tc_state_dev << "constraint_" << constraint_index << "_power_limit_uw"; +- ret = cdev_sysfs.write(tc_state_dev.str(), state_str.str()); +- if (ret < 0) { +- curr_state = (state == 0) ? 0 : max_state; +- if (ret == -ENODATA) { +- thd_log_info("powercap RAPL is BIOS locked, cannot update\n"); +- bios_locked = true; +- } +- } +- +- thd_log_debug("set cdev state raw index %d state %d wr:%d\n", index, state, +- new_state); ++ set_curr_state(state, arg); + } + + bool cthd_sysfs_cdev_rapl::calculate_phy_max() { +@@ -125,9 +83,9 @@ bool cthd_sysfs_cdev_rapl::calculate_phy_max() { + if (phy_max < curr_max_phy) { + phy_max = curr_max_phy; + set_inc_dec_value(phy_max * (float) rapl_power_dec_percent / 100); +- max_state = phy_max; +- max_state -= (float) max_state * rapl_low_limit_percent / 100; +- thd_log_debug("PHY_MAX %d, step %d, max_state %d\n", phy_max, ++ min_state = phy_max; ++ max_state -= (float) min_state * rapl_low_limit_percent / 100; ++ thd_log_debug("PHY_MAX %d, step %d, min_state %d\n", phy_max, + inc_dec_val, max_state); + } + } +@@ -174,8 +132,10 @@ int cthd_sysfs_cdev_rapl::update() { + + if (ppcc) { + phy_max = pl0_max_pwr; +- set_inc_dec_value(pl0_step_pwr); +- max_state = pl0_max_pwr - pl0_min_pwr; ++ set_inc_dec_value(-pl0_step_pwr); ++ min_state = pl0_max_pwr; ++ max_state = pl0_min_pwr; ++ + } else { + temp_str.str(std::string()); + temp_str << "constraint_" << _index << "_max_power_uw"; +@@ -191,8 +151,8 @@ int cthd_sysfs_cdev_rapl::update() { + thd_log_info("Calculate dynamically phy_max \n"); + phy_max = 0; + thd_engine->rapl_power_meter.rapl_start_measure_power(); +- max_state = rapl_min_default_step; +- set_inc_dec_value(rapl_min_default_step); ++ min_state = 0; ++ set_inc_dec_value(-rapl_min_default_step); + dynamic_phy_max_enable = true; + return THD_SUCCESS; + } +@@ -217,9 +177,10 @@ int cthd_sysfs_cdev_rapl::update() { + } + thd_log_info("powercap RAPL max power limit range %d \n", phy_max); + +- set_inc_dec_value(phy_max * (float) rapl_power_dec_percent / 100); +- max_state = phy_max; +- max_state -= (float) max_state * rapl_low_limit_percent / 100; ++ set_inc_dec_value(-phy_max * (float) rapl_power_dec_percent / 100); ++ min_state = phy_max; ++ max_state = min_state ++ - (float) min_state * rapl_low_limit_percent / 100; + } + std::stringstream time_window; + temp_str.str(std::string()); +@@ -246,7 +207,8 @@ int cthd_sysfs_cdev_rapl::update() { + + thd_log_debug("RAPL max limit %d increment: %d\n", max_state, inc_dec_val); + constraint_index = _index; +- set_pid_param(1000, 100, 10); ++ set_pid_param(-1000, 100, 10); ++ curr_state = min_state; + + return THD_SUCCESS; + } +@@ -293,3 +255,7 @@ bool cthd_sysfs_cdev_rapl::read_ppcc_power_limits() { + + return false; + } ++ ++void cthd_sysfs_cdev_rapl::thd_cdev_set_min_state_param(int arg) { ++ min_state = curr_state = arg; ++} +diff --git a/src/thd_cdev_rapl.h b/src/thd_cdev_rapl.h +index dac0a09..77ca69a 100644 +--- a/src/thd_cdev_rapl.h ++++ b/src/thd_cdev_rapl.h +@@ -49,7 +49,7 @@ public: + static const int rapl_min_default_step = 500000; //0.5W + static const int rapl_max_sane_phy_max = 100000000; // Some sane very high value in uW + +- static const int rapl_low_limit_percent = 25; ++ static const int rapl_low_limit_percent = 75; + static const int rapl_power_dec_percent = 5; + + cthd_sysfs_cdev_rapl(unsigned int _index, int package) : +@@ -64,7 +64,7 @@ public: + virtual int get_max_state(); + virtual int update(); + virtual void set_curr_state_raw(int state, int arg); +- int map_target_state(int target_valid, int target_state); ++ void thd_cdev_set_min_state_param(int arg); + }; + + #endif /* THD_CDEV_RAPL_H_ */ +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0010-Process-force-flag.patch thermald-1.7.0/debian/patches/0010-Process-force-flag.patch --- thermald-1.7.0/debian/patches/0010-Process-force-flag.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0010-Process-force-flag.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,43 @@ +From f6404ef4e8ed9e1f212b352df3de5feb03d14618 Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Sat, 14 Jul 2018 15:50:05 -0700 +Subject: [PATCH] Process force flag + +When the temperature is dropped below poll threshold. the force +is flag is set. In this case reset the device to min state fast. +Here then they need to be erased from the list immediately. + +Signed-off-by: Anthony Wong +--- + src/thd_cdev.cpp | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/thd_cdev.cpp b/src/thd_cdev.cpp +index 3f1e036..799a749 100644 +--- a/src/thd_cdev.cpp ++++ b/src/thd_cdev.cpp +@@ -220,9 +220,9 @@ int cthd_cdev::thd_cdev_set_state(int set_point, int target_temp, + + if (zone_trip_limits[i].zone == zone_id + && zone_trip_limits[i].trip == trip_id +- && target_state_valid +- == zone_trip_limits[i].target_state_valid +- && target_value == zone_trip_limits[i].target_value) { ++ && (force || target_state_valid ++ == zone_trip_limits[i].target_state_valid) ++ && (force || target_value == zone_trip_limits[i].target_value)) { + _target_state_valid = zone_trip_limits[i].target_state_valid; + zone_trip_limits.erase(zone_trip_limits.begin() + i); + thd_log_info("Erased [%d: %d %d\n", zone_id, trip_id, +@@ -256,8 +256,6 @@ int cthd_cdev::thd_cdev_set_state(int set_point, int target_temp, + if (_target_state_valid) + target_value = get_min_state(); + } +- } else { +- target_state_valid = 0; + } + } + +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0011-Update-poll-trip-for-user-overidden-temperature.patch thermald-1.7.0/debian/patches/0011-Update-poll-trip-for-user-overidden-temperature.patch --- thermald-1.7.0/debian/patches/0011-Update-poll-trip-for-user-overidden-temperature.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0011-Update-poll-trip-for-user-overidden-temperature.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,194 @@ +From c59704dd9ce298d8f812362eaeaa86eb1ddabe68 Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Sat, 14 Jul 2018 15:30:04 -0700 +Subject: [PATCH] Update poll trip for user overidden temperature + +When user overides a temperature from xml config, recalculate poll +trip. + +Signed-off-by: Anthony Wong +--- + src/thd_zone.cpp | 119 ++++++++++++++++++++++++++++------------------- + src/thd_zone.h | 2 +- + 2 files changed, 71 insertions(+), 50 deletions(-) + +diff --git a/src/thd_zone.cpp b/src/thd_zone.cpp +index 6fdd42c..f5d8310 100644 +--- a/src/thd_zone.cpp ++++ b/src/thd_zone.cpp +@@ -127,33 +127,9 @@ int cthd_zone::read_user_set_psv_temp() { + return temp; + } + +-int cthd_zone::zone_update() { +- int ret; +- +- thd_model.set_zone_type(type_str); +- thd_model.use_pid(); +- +- if (zone_bind_sensors() != THD_SUCCESS) { +- thd_log_warn("Zone update failed: unable to bind \n"); +- return THD_ERROR; +- } +- ret = read_trip_points(); +- if (ret != THD_SUCCESS) +- return THD_ERROR; +- +- int usr_psv_temp = read_user_set_psv_temp(); +- if (usr_psv_temp > 0) { +- cthd_trip_point trip_pt_passive(0, PASSIVE, usr_psv_temp, 0, index, +- DEFAULT_SENSOR_ID); +- update_trip_temp(trip_pt_passive); +- } +- +- ret = read_cdev_trip_points(); +- if (ret != THD_SUCCESS) { +- thd_log_info("No cdev trip points loaded for zone index %d\n", index); +- // Don't bail out as they may be attached by thermal relation tables +- } +- ++void cthd_zone::sort_and_update_poll_trip() { ++ thd_log_debug("sort_and_update_poll_trip: trip_points_size =%lu\n", ++ trip_points.size()); + if (trip_points.size()) { + unsigned int polling_trip = 0; + unsigned int max_trip_temp = 0; +@@ -169,7 +145,15 @@ int cthd_zone::zone_update() { + // Use that the lowest point, after that we poll + if (trip_points.size()) + polling_trip = trip_points[0].get_trip_temp(); ++ ++ int poll_trip_present = 0; ++ int poll_trip_index = 0; + for (unsigned int i = 0; i < trip_points.size(); ++i) { ++ if (trip_points[i].get_trip_type() == POLLING) { ++ thd_log_debug("polling trip already present\n"); ++ poll_trip_present = 1; ++ poll_trip_index = i; ++ } + if (polling_trip > trip_points[i].get_trip_temp()) + polling_trip = trip_points[i].get_trip_temp(); + if (trip_points[i].get_trip_type() == MAX) +@@ -185,28 +169,32 @@ int cthd_zone::zone_update() { + for (unsigned int i = 0; i < sensors.size(); ++i) { + cthd_sensor *sensor; + sensor = sensors[i]; +- if (sensor->check_async_capable()) { +- if (max_trip_temp) { +- unsigned int _polling_trip; +- // We have to guarantee MAX, so we better +- // wake up before, so that by the time +- // we are notified, temp > max temp +- thd_model.set_max_temperature(max_trip_temp); +- _polling_trip = thd_model.get_hot_zone_trigger_point(); +- if (polling_trip) { +- if (_polling_trip < polling_trip) { +- if ((polling_trip - _polling_trip) +- < def_async_trip_offset) +- polling_trip = _polling_trip +- - def_async_trip_offset; +- else +- polling_trip = _polling_trip; +- } +- } else +- polling_trip = _polling_trip; +- } +- +- sensor->set_threshold(0, polling_trip); ++ if (max_trip_temp) { ++ unsigned int _polling_trip; ++ // We have to guarantee MAX, so we better ++ // wake up before, so that by the time ++ // we are notified, temp > max temp ++ thd_model.set_max_temperature(max_trip_temp); ++ _polling_trip = thd_model.get_hot_zone_trigger_point(); ++ if (polling_trip) { ++ if (_polling_trip < polling_trip) { ++ if ((polling_trip - _polling_trip) ++ < def_async_trip_offset) ++ polling_trip = _polling_trip ++ - def_async_trip_offset; ++ else ++ polling_trip = _polling_trip; ++ } ++ } else ++ polling_trip = _polling_trip; ++ } ++ ++ sensor->set_threshold(0, polling_trip); ++ // If the poll trip is already present then simply update ++ // the trip, instead of creating a new one. ++ if (poll_trip_present) { ++ trip_points[poll_trip_index].update_trip_temp(polling_trip); ++ } else { + cthd_trip_point trip_pt_polling(trip_points.size(), POLLING, + polling_trip, 0, index, sensor->get_index()); + trip_pt_polling.thd_trip_point_set_control_type(PARALLEL); +@@ -214,6 +202,36 @@ int cthd_zone::zone_update() { + } + } + } ++} ++ ++int cthd_zone::zone_update() { ++ int ret; ++ ++ thd_model.set_zone_type(type_str); ++ thd_model.use_pid(); ++ ++ if (zone_bind_sensors() != THD_SUCCESS) { ++ thd_log_warn("Zone update failed: unable to bind \n"); ++ return THD_ERROR; ++ } ++ ret = read_trip_points(); ++ if (ret != THD_SUCCESS) ++ return THD_ERROR; ++ ++ int usr_psv_temp = read_user_set_psv_temp(); ++ if (usr_psv_temp > 0) { ++ cthd_trip_point trip_pt_passive(0, PASSIVE, usr_psv_temp, 0, index, ++ DEFAULT_SENSOR_ID); ++ update_trip_temp(trip_pt_passive); ++ } ++ ++ ret = read_cdev_trip_points(); ++ if (ret != THD_SUCCESS) { ++ thd_log_info("No cdev trip points loaded for zone index %d\n", index); ++ // Don't bail out as they may be attached by thermal relation tables ++ } ++ ++ sort_and_update_poll_trip(); + + for (unsigned int i = 0; i < trip_points.size(); ++i) { + cthd_trip_point &trip_point = trip_points[i]; +@@ -355,6 +373,8 @@ void cthd_zone::add_trip(cthd_trip_point &trip) { + } + if (add) + trip_points.push_back(trip); ++ ++ sort_and_update_poll_trip(); + } + + void cthd_zone::update_trip_temp(cthd_trip_point &trip) { +@@ -371,4 +391,5 @@ void cthd_zone::update_trip_temp(cthd_trip_point &trip) { + break; + } + } ++ sort_and_update_poll_trip(); + } +diff --git a/src/thd_zone.h b/src/thd_zone.h +index b2a0603..ac3ab48 100644 +--- a/src/thd_zone.h ++++ b/src/thd_zone.h +@@ -68,7 +68,7 @@ protected: + void thermal_zone_temp_change(int id, unsigned int temp, int pref); + + private: +- ++ void sort_and_update_poll_trip(); + public: + static const unsigned int def_async_trip_offset = 5000; + cthd_zone(int _index, std::string control_path, sensor_relate_t rel = +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0012-Fast-polling-when-near-the-trip.patch thermald-1.7.0/debian/patches/0012-Fast-polling-when-near-the-trip.patch --- thermald-1.7.0/debian/patches/0012-Fast-polling-when-near-the-trip.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0012-Fast-polling-when-near-the-trip.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,193 @@ +From bb75fc3f297517caaaa1aa45183f406bd027d5d4 Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Sat, 14 Jul 2018 15:32:04 -0700 +Subject: [PATCH] Fast polling when near the trip + +Start polling faster neare the trip, so that temperature is polled +every second. +But still the compensation used via a cooling device may have its +own hysteresis, so this doesn't mean that the temperature change +will result in immediate compensation. + +Signed-off-by: Anthony Wong +--- + src/thd_engine.cpp | 38 +++++++++++++++++++++++++++++++++++++- + src/thd_engine.h | 8 ++++++++ + src/thd_sensor.cpp | 7 +++++++ + src/thd_sensor.h | 2 ++ + src/thd_trip_point.cpp | 13 ++++++++----- + 5 files changed, 62 insertions(+), 6 deletions(-) + +diff --git a/src/thd_engine.cpp b/src/thd_engine.cpp +index a1788bf..2700587 100644 +--- a/src/thd_engine.cpp ++++ b/src/thd_engine.cpp +@@ -53,7 +53,8 @@ cthd_engine::cthd_engine() : + 0), preference(0), status(true), thz_last_uevent_time(0), thz_last_temp_ind_time( + 0), terminate(false), genuine_intel(0), has_invariant_tsc(0), has_aperf( + 0), proc_list_matched(false), poll_interval_sec(0), poll_sensor_mask( +- 0), poll_fd_cnt(0), rt_kernel(false), parser_init_done(false) { ++ 0), fast_poll_sensor_mask(0), saved_poll_interval(0), poll_fd_cnt( ++ 0), rt_kernel(false), parser_init_done(false) { + thd_engine = pthread_t(); + thd_attr = pthread_attr_t(); + +@@ -451,6 +452,25 @@ void cthd_engine::poll_enable_disable(bool status, message_capsul_t *msg) { + } + } + ++void cthd_engine::fast_poll_enable_disable(bool status, message_capsul_t *msg) { ++ unsigned int *sensor_id = (unsigned int*) msg->msg; ++ ++ if (status) { ++ fast_poll_sensor_mask |= (1 << (*sensor_id)); ++ saved_poll_interval = poll_timeout_msec; ++ poll_timeout_msec = 1000; ++ thd_log_debug("thd_engine fast polling enabled via %u \n", *sensor_id); ++ } else { ++ fast_poll_sensor_mask &= ~(1 << (*sensor_id)); ++ if (!fast_poll_sensor_mask) { ++ if (saved_poll_interval) ++ poll_timeout_msec = saved_poll_interval; ++ thd_log_debug("thd_engine polling last disabled via %u \n", ++ *sensor_id); ++ } ++ } ++} ++ + int cthd_engine::proc_message(message_capsul_t *msg) { + int ret = 0; + +@@ -487,6 +507,12 @@ int cthd_engine::proc_message(message_capsul_t *msg) { + poll_enable_disable(false, msg); + } + break; ++ case FAST_POLL_ENABLE: ++ fast_poll_enable_disable(true, msg); ++ break; ++ case FAST_POLL_DISABLE: ++ fast_poll_enable_disable(false, msg); ++ break; + default: + break; + } +@@ -585,6 +611,16 @@ void cthd_engine::thd_engine_poll_disable(int sensor_id) { + (unsigned char*) &sensor_id); + } + ++void cthd_engine::thd_engine_fast_poll_enable(int sensor_id) { ++ send_message(FAST_POLL_ENABLE, (int) sizeof(sensor_id), ++ (unsigned char*) &sensor_id); ++} ++ ++void cthd_engine::thd_engine_fast_poll_disable(int sensor_id) { ++ send_message(FAST_POLL_DISABLE, (int) sizeof(sensor_id), ++ (unsigned char*) &sensor_id); ++} ++ + void cthd_engine::thd_engine_reload_zones() { + thd_log_warn(" Reloading zones\n"); + for (unsigned int i = 0; i < zones.size(); ++i) { +diff --git a/src/thd_engine.h b/src/thd_engine.h +index 90cfd93..c9f103b 100644 +--- a/src/thd_engine.h ++++ b/src/thd_engine.h +@@ -50,6 +50,8 @@ typedef enum { + RELOAD_ZONES, + POLL_ENABLE, + POLL_DISABLE, ++ FAST_POLL_ENABLE, ++ FAST_POLL_DISABLE, + } message_name_t; + + // This defines whether the thermal control is entirey done by +@@ -100,6 +102,8 @@ private: + int poll_interval_sec; + cthd_preference thd_pref; + unsigned int poll_sensor_mask; ++ unsigned int fast_poll_sensor_mask; ++ int saved_poll_interval; + std::string config_file; + + pthread_t thd_engine; +@@ -153,6 +157,7 @@ public: + const char *user_set_point); + + void poll_enable_disable(bool status, message_capsul_t *msg); ++ void fast_poll_enable_disable(bool status, message_capsul_t *msg); + + cthd_cdev *thd_get_cdev_at_index(int index); + +@@ -163,6 +168,9 @@ public: + void thd_engine_poll_enable(int sensor_id); + void thd_engine_poll_disable(int sensor_id); + ++ void thd_engine_fast_poll_enable(int sensor_id); ++ void thd_engine_fast_poll_disable(int sensor_id); ++ + void thd_read_default_thermal_sensors(); + void thd_read_default_thermal_zones(); + void thd_read_default_cooling_devices(); +diff --git a/src/thd_sensor.cpp b/src/thd_sensor.cpp +index 131df79..8d9604c 100644 +--- a/src/thd_sensor.cpp ++++ b/src/thd_sensor.cpp +@@ -123,3 +123,10 @@ void cthd_sensor::sensor_poll_trip(bool status) { + else + thd_engine->thd_engine_poll_disable(index); + } ++ ++void cthd_sensor::sensor_fast_poll(bool status) { ++ if (status) ++ thd_engine->thd_engine_fast_poll_enable(index); ++ else ++ thd_engine->thd_engine_fast_poll_disable(index); ++} +diff --git a/src/thd_sensor.h b/src/thd_sensor.h +index 026c6ac..df84d05 100644 +--- a/src/thd_sensor.h ++++ b/src/thd_sensor.h +@@ -88,6 +88,8 @@ public: + // at critical monitoring point. Sensors can be forced to go to poll mode at that temp + void sensor_poll_trip(bool status); + ++ void sensor_fast_poll(bool status); ++ + bool is_virtual() { + return virtual_sensor; + } +diff --git a/src/thd_trip_point.cpp b/src/thd_trip_point.cpp +index 424dbb5..602520e 100644 +--- a/src/thd_trip_point.cpp ++++ b/src/thd_trip_point.cpp +@@ -169,19 +169,22 @@ bool cthd_trip_point::thd_trip_point_check(int id, unsigned int read_temp, + + if (type == POLLING && sensor_id != DEFAULT_SENSOR_ID) { + cthd_sensor *sensor = thd_engine->get_sensor(sensor_id); +- if (sensor && sensor->check_async_capable()) { ++ if (sensor) { + if (!poll_on && read_temp >= temp) { + thd_log_debug("polling trip reached, on \n"); + sensor->sensor_poll_trip(true); + poll_on = true; +- sensor->set_threshold(0, temp); ++ sensor->sensor_fast_poll(true); ++ if (sensor->check_async_capable()) ++ sensor->set_threshold(0, temp); + } else if (poll_on && read_temp < temp) { +- thd_log_debug("polling trip reached, off \n"); + sensor->sensor_poll_trip(false); +- thd_log_info("Dropped below poll threshold \n"); ++ thd_log_debug("Dropped below poll threshold \n"); + *reset = true; + poll_on = false; +- sensor->set_threshold(0, temp); ++ sensor->sensor_fast_poll(false); ++ if (sensor->check_async_capable()) ++ sensor->set_threshold(0, temp); + } + } + return true; +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0013-Increase-rapl-cooling-percent.patch thermald-1.7.0/debian/patches/0013-Increase-rapl-cooling-percent.patch --- thermald-1.7.0/debian/patches/0013-Increase-rapl-cooling-percent.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0013-Increase-rapl-cooling-percent.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,28 @@ +From 2b00c24a53e5a0e0d1060f9509b49f26286dae90 Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Sat, 14 Jul 2018 15:52:03 -0700 +Subject: [PATCH] Increase rapl cooling percent + +Upto 50% of the cooling can be from rapl. + +Signed-off-by: Anthony Wong +--- + src/thd_cdev_rapl.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/thd_cdev_rapl.h b/src/thd_cdev_rapl.h +index 6887f7e..30a5d53 100644 +--- a/src/thd_cdev_rapl.h ++++ b/src/thd_cdev_rapl.h +@@ -49,7 +49,7 @@ public: + static const int rapl_min_default_step = 500000; //0.5W + static const int rapl_max_sane_phy_max = 100000000; // Some sane very high value in uW + +- static const int rapl_low_limit_percent = 75; ++ static const int rapl_low_limit_percent = 50; + static const int rapl_power_dec_percent = 5; + + cthd_sysfs_cdev_rapl(unsigned int _index, int package) : +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0014-Add-Per-trip-PID-parameters.patch thermald-1.7.0/debian/patches/0014-Add-Per-trip-PID-parameters.patch --- thermald-1.7.0/debian/patches/0014-Add-Per-trip-PID-parameters.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0014-Add-Per-trip-PID-parameters.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,242 @@ +From 2d0f24a58c116e7911b19128e87ddcdc427691dd Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Tue, 12 Jun 2018 15:03:51 -0700 +Subject: [PATCH] Add Per trip PID parameters + +Currently the PID parameters is per cooling device. Add capability +so that each trip can have its own cooling device. + +Signed-off-by: Anthony Wong +--- + src/thd_cdev.cpp | 35 +++++++++++++++++++++++++++++++---- + src/thd_cdev.h | 3 ++- + src/thd_pid.h | 14 ++++++++++++++ + src/thd_trip_point.cpp | 19 +++++++++++++++---- + src/thd_trip_point.h | 23 +++++++++++++++-------- + 5 files changed, 77 insertions(+), 17 deletions(-) + +diff --git a/src/thd_cdev.cpp b/src/thd_cdev.cpp +index 26076a3..3f1e036 100644 +--- a/src/thd_cdev.cpp ++++ b/src/thd_cdev.cpp +@@ -59,8 +59,8 @@ int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp, + ++curr_pow; + state = base_pow_state + int_2_pow(curr_pow) * inc_dec_val; + thd_log_info( +- "cdev index:%d consecutive call, increment exponentially state %d\n", +- index, state); ++ "cdev index:%d consecutive call, increment exponentially state %d (min %d max %d)\n", ++ index, state, min_state, max_state); + if ((min_state < max_state && state >= max_state) + || (min_state > max_state && state <= max_state)) { + state = max_state; +@@ -148,7 +148,8 @@ static bool sort_clamp_values_dec(zone_trip_limits_t limit_1, + + int cthd_cdev::thd_cdev_set_state(int set_point, int target_temp, + int temperature, int state, int zone_id, int trip_id, +- int target_state_valid, int target_value, bool force) { ++ int target_state_valid, int target_value, ++ pid_param_t *pid_param, cthd_pid& pid, bool force) { + + time_t tm; + int ret; +@@ -274,7 +275,32 @@ int cthd_cdev::thd_cdev_set_state(int set_point, int target_temp, + thd_log_info("Set : %d, %d, %d, %d, %d\n", set_point, temperature, + index, get_curr_state(), max_state); + ++ } else if (pid_param && pid_param->valid) { ++ // Handle PID param unique to a trip ++ pid.set_target_temp(target_temp); ++ ret = pid.pid_output(temperature); ++ ret += get_min_state(); ++ if (get_min_state() < get_max_state()) { ++ if (ret > get_max_state()) ++ ret = get_max_state(); ++ if (ret < get_min_state()) ++ ret = get_min_state(); ++ } else { ++ if (ret < get_max_state()) ++ ret = get_max_state(); ++ if (ret > get_min_state()) ++ ret = get_min_state(); ++ } ++ set_curr_state_raw(ret, zone_id); ++ thd_log_info("Set pid : %d, %d, %d, %d, %d\n", set_point, temperature, ++ index, get_curr_state(), max_state); ++ ret = THD_SUCCESS; ++ ++ if (state == 0) ++ pid.reset(); ++ + } else if (pid_enable) { ++ // Handle PID param common to whole cooling device + pid_ctrl.set_target_temp(target_temp); + ret = pid_ctrl.pid_output(temperature); + ret += get_min_state(); +@@ -308,7 +334,8 @@ int cthd_cdev::thd_cdev_set_state(int set_point, int target_temp, + + int cthd_cdev::thd_cdev_set_min_state(int zone_id, int trip_id) { + trend_increase = false; +- thd_cdev_set_state(0, 0, 0, 0, zone_id, trip_id, 1, min_state, true); ++ cthd_pid unused; ++ thd_cdev_set_state(0, 0, 0, 0, zone_id, trip_id, 1, min_state, NULL, unused, true); + + return THD_SUCCESS; + } +diff --git a/src/thd_cdev.h b/src/thd_cdev.h +index 8c73885..17b338b 100644 +--- a/src/thd_cdev.h ++++ b/src/thd_cdev.h +@@ -93,7 +93,8 @@ public: + } + virtual int thd_cdev_set_state(int set_point, int target_temp, + int temperature, int state, int zone_id, int trip_id, +- int target_state_valid, int target_value, bool force); ++ int target_state_valid, int target_value, ++ pid_param_t *pid_param, cthd_pid& pid, bool force); + + virtual int thd_cdev_set_min_state(int zone_id, int trip_id); + +diff --git a/src/thd_pid.h b/src/thd_pid.h +index d372364..551cfae 100644 +--- a/src/thd_pid.h ++++ b/src/thd_pid.h +@@ -25,6 +25,14 @@ + #include "thermald.h" + #include + ++typedef struct ++{ ++ int valid; ++ double kp; ++ double ki; ++ double kd; ++}pid_param_t; ++ + class cthd_pid { + + private: +@@ -35,6 +43,12 @@ private: + public: + cthd_pid(); + double kp, ki, kd; ++ void set_pid_param(double _kp, double _ki, double _kd) ++ { ++ kp = _kp; ++ ki = _ki; ++ kd = _kd; ++ } + int pid_output(unsigned int curr_temp); + void set_target_temp(unsigned int temp) { + target_temp = temp; +diff --git a/src/thd_trip_point.cpp b/src/thd_trip_point.cpp +index 170adcf..e6a9aed 100644 +--- a/src/thd_trip_point.cpp ++++ b/src/thd_trip_point.cpp +@@ -1,5 +1,5 @@ + /* +- * thd_trip_point.cpp: thermal zone class implentation ++ * thd_trip_point.cpp: thermal zone class implementation + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * +@@ -167,7 +167,8 @@ bool cthd_trip_point::thd_trip_point_check(int id, unsigned int read_temp, + ret = cdev->thd_cdev_set_state(temp, temp, read_temp, 1, zone_id, + index, cdevs[i].target_state_valid, + cdev->map_target_state(cdevs[i].target_state_valid, +- cdevs[i].target_state), false); ++ cdevs[i].target_state), &cdevs[i].pid_param, ++ cdevs[i].pid, false); + if (control_type == SEQUENTIAL && ret == THD_SUCCESS) { + // Only one cdev activation + break; +@@ -189,7 +190,8 @@ bool cthd_trip_point::thd_trip_point_check(int id, unsigned int read_temp, + cdev->thd_cdev_set_state(temp, temp, read_temp, 0, zone_id, index, + cdevs[i].target_state_valid, + cdev->map_target_state(cdevs[i].target_state_valid, +- cdevs[i].target_state), false); ++ cdevs[i].target_state), &cdevs[i].pid_param, ++ cdevs[i].pid, false); + + if (control_type == SEQUENTIAL) { + // Only one cdev activation +@@ -202,7 +204,8 @@ bool cthd_trip_point::thd_trip_point_check(int id, unsigned int read_temp, + } + + void cthd_trip_point::thd_trip_point_add_cdev(cthd_cdev &cdev, int influence, +- int sampling_period, int target_state_valid, int target_state) { ++ int sampling_period, int target_state_valid, int target_state, ++ pid_param_t *pid_param) { + trip_pt_cdev_t thd_cdev; + thd_cdev.cdev = &cdev; + thd_cdev.influence = influence; +@@ -210,6 +213,14 @@ void cthd_trip_point::thd_trip_point_add_cdev(cthd_cdev &cdev, int influence, + thd_cdev.last_op_time = 0; + thd_cdev.target_state_valid = target_state_valid; + thd_cdev.target_state = target_state; ++ if (pid_param && pid_param->valid) { ++ thd_log_info("pid valid %f:%f:%f\n", pid_param->kp, pid_param->ki, ++ pid_param->kd); ++ memcpy(&thd_cdev.pid_param, pid_param, sizeof(pid_param_t)); ++ thd_cdev.pid.set_pid_param(pid_param->kp, pid_param->ki, pid_param->kd); ++ } else { ++ memset(&thd_cdev.pid_param, 0, sizeof(pid_param_t)); ++ } + trip_cdev_add(thd_cdev); + } + +diff --git a/src/thd_trip_point.h b/src/thd_trip_point.h +index da3d77a..dba1e60 100644 +--- a/src/thd_trip_point.h ++++ b/src/thd_trip_point.h +@@ -52,6 +52,8 @@ typedef struct { + time_t last_op_time; + int target_state_valid; + int target_state; ++ pid_param_t pid_param; ++ cthd_pid pid; + } trip_pt_cdev_t; + + #define DEFAULT_SENSOR_ID 0xFFFF +@@ -94,7 +96,7 @@ public: + void thd_trip_point_add_cdev(cthd_cdev &cdev, int influence, + int sampling_period = 0, int target_state_valid = 0, + int target_state = +- TRIP_PT_INVALID_TARGET_STATE); ++ TRIP_PT_INVALID_TARGET_STATE, pid_param_t *pid_param = NULL); + + void thd_trip_cdev_state_reset(); + int thd_trip_point_value() { +@@ -165,17 +167,22 @@ public: + else + _type_str = "invalid"; + thd_log_info( +- "index %d: type:%s temp:%u hyst:%u zone id:%d sensor id:%d cdev size:%lu\n", ++ "index %d: type:%s temp:%u hyst:%u zone id:%d sensor id:%d control_type:%d cdev size:%lu\n", + index, _type_str.c_str(), temp, hyst, zone_id, sensor_id, +- (unsigned long) cdevs.size()); ++ control_type, (unsigned long) cdevs.size()); + for (unsigned int i = 0; i < cdevs.size(); ++i) { ++ thd_log_info("cdev[%u] %s, Sampling period: %d\n", i, ++ cdevs[i].cdev->get_cdev_type().c_str(), ++ cdevs[i].sampling_priod); + if (cdevs[i].target_state_valid) +- thd_log_info("cdev[%u] %s target_state:%d\n", i, +- cdevs[i].cdev->get_cdev_type().c_str(), +- cdevs[i].target_state); ++ thd_log_info("\t target_state:%d\n", cdevs[i].target_state); + else +- thd_log_info("cdev[%u] %s target_state:not defined\n", i, +- cdevs[i].cdev->get_cdev_type().c_str()); ++ thd_log_info("\t target_state:not defined\n"); ++ ++ if (cdevs[i].pid_param.valid) ++ thd_log_info("\t pid: kp=%g ki=%g kd=%g\n", ++ cdevs[i].pid_param.kp, cdevs[i].pid_param.ki, ++ cdevs[i].pid_param.kd); + } + } + }; +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/0015-Fix-the-dynamic-rapl-control.patch thermald-1.7.0/debian/patches/0015-Fix-the-dynamic-rapl-control.patch --- thermald-1.7.0/debian/patches/0015-Fix-the-dynamic-rapl-control.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0015-Fix-the-dynamic-rapl-control.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,232 @@ +From 956a411e3742fce3ad4eed467ccb961c91b6d895 Mon Sep 17 00:00:00 2001 +From: Srinivas Pandruvada +Date: Sun, 15 Jul 2018 14:46:29 -0700 +Subject: [PATCH] Fix the dynamic rapl control + +When we changed the rapl cdev to actual power value instead of target +state, there was regression for the case when the rapl max limit +has to be calculated dynamically. + +This patch was refreshed to remove any fuzz. + +Signed-off-by: Anthony Wong +--- + src/thd_cdev.cpp | 18 +++++++++-------- + src/thd_cdev_rapl.cpp | 46 ++++++++++++++++++++++++++++++++----------- + src/thd_cdev_rapl.h | 4 +++- + src/thd_engine.cpp | 3 +-- + 4 files changed, 49 insertions(+), 22 deletions(-) + +Index: thermald-1.7.0/src/thd_cdev.cpp +=================================================================== +--- thermald-1.7.0.orig/src/thd_cdev.cpp ++++ thermald-1.7.0/src/thd_cdev.cpp +@@ -42,6 +42,8 @@ + int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp, + int temperature, int state, int zone_id) { + ++ int control = state; ++ + curr_state = get_curr_state(); + if ((min_state < max_state && curr_state < min_state) + || (min_state > max_state && curr_state > min_state)) +@@ -75,7 +77,7 @@ int cthd_cdev::thd_cdev_exponential_cont + || (min_state > max_state && state < max_state)) + state = max_state; + thd_log_debug("op->device:%s %d\n", type_str.c_str(), state); +- set_curr_state(state, zone_id); ++ set_curr_state(state, control); + } + } else { + curr_pow = 0; +@@ -88,11 +90,11 @@ int cthd_cdev::thd_cdev_exponential_cont + || (min_state > max_state && state > min_state)) + state = min_state; + thd_log_debug("op->device:%s %d\n", type_str.c_str(), state); +- set_curr_state(state, zone_id); ++ set_curr_state(state, control); + } else { + thd_log_debug("op->device: force min %s %d\n", type_str.c_str(), + min_state); +- set_curr_state(min_state, zone_id); ++ set_curr_state(min_state, control); + } + } + +@@ -156,9 +158,10 @@ int cthd_cdev::thd_cdev_set_state(int se + + time(&tm); + thd_log_info( +- ">>thd_cdev_set_state index:%d state:%d :%d:%d:%d:%d force:%d\n", ++ ">>thd_cdev_set_state index:%d state:%d :zone:%d trip_id:%d target_state_valid:%d target_value :%d force:%d\n", + index, state, zone_id, trip_id, target_state_valid, target_value, + force); ++ + if (!force && last_state == state && state + && (tm - last_action_time) <= debounce_interval) { + thd_log_debug( +@@ -166,7 +169,6 @@ int cthd_cdev::thd_cdev_set_state(int se + set_point, temperature, index, get_curr_state(), max_state); + return THD_SUCCESS; + } +- + last_state = state; + + if (state) { +@@ -267,7 +269,7 @@ int cthd_cdev::thd_cdev_set_state(int se + } + + if (target_state_valid) { +- set_curr_state_raw(target_value, zone_id); ++ set_curr_state_raw(target_value, state); + curr_state = target_value; + ret = THD_SUCCESS; + thd_log_info("Set : %d, %d, %d, %d, %d\n", set_point, temperature, +@@ -289,7 +291,7 @@ int cthd_cdev::thd_cdev_set_state(int se + if (ret > get_min_state()) + ret = get_min_state(); + } +- set_curr_state_raw(ret, zone_id); ++ set_curr_state_raw(ret, state); + thd_log_info("Set pid : %d, %d, %d, %d, %d\n", set_point, temperature, + index, get_curr_state(), max_state); + ret = THD_SUCCESS; +@@ -315,7 +317,7 @@ int cthd_cdev::thd_cdev_set_state(int se + ret = get_min_state(); + } + +- set_curr_state_raw(ret, zone_id); ++ set_curr_state_raw(ret, state); + thd_log_info("Set : %d, %d, %d, %d, %d\n", set_point, temperature, + index, get_curr_state(), max_state); + ret = THD_SUCCESS; +Index: thermald-1.7.0/src/thd_cdev_rapl.cpp +=================================================================== +--- thermald-1.7.0.orig/src/thd_cdev_rapl.cpp ++++ thermald-1.7.0/src/thd_cdev_rapl.cpp +@@ -29,7 +29,7 @@ + * rapl_power_dec_percent, from the max state. + * + */ +-void cthd_sysfs_cdev_rapl::set_curr_state(int state, int arg) { ++void cthd_sysfs_cdev_rapl::set_curr_state(int state, int control) { + + std::stringstream tc_state_dev; + +@@ -39,20 +39,22 @@ void cthd_sysfs_cdev_rapl::set_curr_stat + if (bios_locked) + return; + +- if (state < inc_dec_val) { ++ if (control == 0 || state >= min_state) { ++ if (power_on_constraint_0_pwr) ++ new_state = power_on_constraint_0_pwr; ++ else ++ new_state = min_state; ++ + curr_state = min_state; + cdev_sysfs.write("enabled", "0"); +- new_state = min_state; ++ constrained = false; + } else { +- if (dynamic_phy_max_enable) { +- if (!calculate_phy_max()) { +- curr_state = state; +- return; +- } ++ if (!dynamic_phy_max_enable) { ++ curr_state = state; + } + new_state = state; +- curr_state = state; + cdev_sysfs.write("enabled", "1"); ++ constrained = true; + } + state_str << new_state; + thd_log_debug("set cdev state index %d state %d wr:%d\n", index, state, +@@ -94,6 +96,13 @@ bool cthd_sysfs_cdev_rapl::calculate_phy + } + + int cthd_sysfs_cdev_rapl::get_curr_state() { ++ if (dynamic_phy_max_enable) { ++ if (constrained) ++ return thd_engine->rapl_power_meter.rapl_action_get_power( ++ PACKAGE); ++ else ++ return min_state; ++ } + return curr_state; + } + +@@ -149,11 +158,26 @@ int cthd_sysfs_cdev_rapl::update() { + thd_log_info("%s:powercap RAPL invalid max power limit range \n", + domain_name.c_str()); + thd_log_info("Calculate dynamically phy_max \n"); +- phy_max = 0; ++ ++ power_on_constraint_0_pwr = phy_max; ++ ++ phy_max = max_state = 0; ++ curr_state = min_state = rapl_max_sane_phy_max; + thd_engine->rapl_power_meter.rapl_start_measure_power(); +- min_state = 0; + set_inc_dec_value(-rapl_min_default_step); + dynamic_phy_max_enable = true; ++ ++ std::stringstream time_window; ++ temp_str.str(std::string()); ++ temp_str << "constraint_" << _index << "_time_window_us"; ++ if (!cdev_sysfs.exists(temp_str.str())) { ++ thd_log_info("powercap RAPL no time_window_us %s \n", ++ temp_str.str().c_str()); ++ return THD_ERROR; ++ } ++ time_window << def_rapl_time_window; ++ cdev_sysfs.write(temp_str.str(), time_window.str()); ++ + return THD_SUCCESS; + } + +Index: thermald-1.7.0/src/thd_cdev_rapl.h +=================================================================== +--- thermald-1.7.0.orig/src/thd_cdev_rapl.h ++++ thermald-1.7.0/src/thd_cdev_rapl.h +@@ -39,6 +39,8 @@ protected: + int pl0_min_window; + int pl0_step_pwr; + bool bios_locked; ++ bool constrained; ++ int power_on_constraint_0_pwr; + + virtual bool calculate_phy_max(); + virtual bool read_ppcc_power_limits(); +@@ -57,7 +59,7 @@ public: + "/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/"), phy_max( + 0), package_id(package), constraint_index(0), dynamic_phy_max_enable( + false), pl0_max_pwr(0), pl0_min_pwr(0), pl0_min_window(0), pl0_step_pwr( +- 0), bios_locked(false) { ++ 0), bios_locked(false), constrained(false), power_on_constraint_0_pwr(0) { + } + virtual void set_curr_state(int state, int arg); + virtual int get_curr_state(); +Index: thermald-1.7.0/src/thd_engine.cpp +=================================================================== +--- thermald-1.7.0.orig/src/thd_engine.cpp ++++ thermald-1.7.0/src/thd_engine.cpp +@@ -95,8 +95,6 @@ void cthd_engine::thd_engine_thread() { + if (terminate) + break; + +- rapl_power_meter.rapl_measure_power(); +- + n = poll(poll_fds, poll_fd_cnt, poll_timeout_msec); + thd_log_debug("poll exit %d polls_fd event %d %d\n", n, + poll_fds[0].revents, poll_fds[1].revents); +@@ -105,6 +103,7 @@ void cthd_engine::thd_engine_thread() { + continue; + } + time(&tm); ++ rapl_power_meter.rapl_measure_power(); + + if (n == 0 || (tm - thz_last_temp_ind_time) >= poll_timeout_sec) { + if (!status) { diff -Nru thermald-1.7.0/debian/patches/0016-Use-correct-format-specifier-for-size_t.patch thermald-1.7.0/debian/patches/0016-Use-correct-format-specifier-for-size_t.patch --- thermald-1.7.0/debian/patches/0016-Use-correct-format-specifier-for-size_t.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-1.7.0/debian/patches/0016-Use-correct-format-specifier-for-size_t.patch 2019-08-08 19:24:30.000000000 +0800 @@ -0,0 +1,35 @@ +From bb7631163c8f3f44d0dc83690765cdb799664fd5 Mon Sep 17 00:00:00 2001 +From: Anuj Mittal +Date: Wed, 26 Sep 2018 10:34:15 +0800 +Subject: [PATCH] Use correct format specifier for size_t + +%zu instead of %lu, otherwise on 32 bit: + +| ../git/src/thd_zone.cpp: In member function 'void cthd_zone::sort_and_update_poll_trip()': +| ../git/src/thd_zone.cpp:106:16: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'std::vector::size_type' {aka 'unsigned int'} [-Werror=format=] +| thd_log_debug("sort_and_update_poll_trip: trip_points_size =%lu\n", +| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +| trip_points.size()); + +Signed-off-by: Anuj Mittal +Signed-off-by: Anthony Wong +--- + src/thd_zone.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/thd_zone.cpp b/src/thd_zone.cpp +index b7edf9e..cb7b8e8 100644 +--- a/src/thd_zone.cpp ++++ b/src/thd_zone.cpp +@@ -103,7 +103,7 @@ int cthd_zone::read_user_set_psv_temp() { + } + + void cthd_zone::sort_and_update_poll_trip() { +- thd_log_debug("sort_and_update_poll_trip: trip_points_size =%lu\n", ++ thd_log_debug("sort_and_update_poll_trip: trip_points_size =%zu\n", + trip_points.size()); + if (trip_points.size()) { + unsigned int polling_trip = 0; +-- +2.17.1 + diff -Nru thermald-1.7.0/debian/patches/series thermald-1.7.0/debian/patches/series --- thermald-1.7.0/debian/patches/series 2019-01-15 07:29:41.000000000 +0800 +++ thermald-1.7.0/debian/patches/series 2019-08-08 19:24:30.000000000 +0800 @@ -3,3 +3,11 @@ 0003-thermald-fix-uninitialised-member.patch 0007-Ignore-_TRT-and-B0D4-device-if-passive-1-UUID-not-pr.patch 0008-Honor-ACPI-_CRT-for-processor-thermal-zone.patch +0009-Simplify-RAPL-Cdev.patch +0010-Process-force-flag.patch +0011-Update-poll-trip-for-user-overidden-temperature.patch +0012-Fast-polling-when-near-the-trip.patch +0013-Increase-rapl-cooling-percent.patch +0014-Add-Per-trip-PID-parameters.patch +0015-Fix-the-dynamic-rapl-control.patch +0016-Use-correct-format-specifier-for-size_t.patch