summaryrefslogtreecommitdiff
path: root/thermal
diff options
context:
space:
mode:
authorTeYuan Wang <kamewang@google.com>2021-07-07 00:10:03 +0800
committerTeYuan Wang <kamewang@google.com>2021-07-08 17:21:48 +0800
commitcf16c810fc1ac978e21122b6438b11e736c889d2 (patch)
treeb63577816350d765eb7f3a06cc20200e8e40f2f1 /thermal
parent8daf64c732942ae25a350437165076792ed1aaf7 (diff)
downloadpixel-cf16c810fc1ac978e21122b6438b11e736c889d2.tar.gz
thermal: improve PID throttling
1. Support cdev weight for each severity 2. Support cdev ceiling for each severity Bug: 188118470 Test: Verified by emul temp Change-Id: I05e147e101fefde3404d3f46537c0a399917f6cd
Diffstat (limited to 'thermal')
-rw-r--r--thermal/Thermal.cpp34
-rw-r--r--thermal/thermal-helper.cpp123
-rw-r--r--thermal/thermal-helper.h11
-rw-r--r--thermal/utils/config_parser.cpp121
-rw-r--r--thermal/utils/config_parser.h7
5 files changed, 206 insertions, 90 deletions
diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp
index ea826595..2e9a99d1 100644
--- a/thermal/Thermal.cpp
+++ b/thermal/Thermal.cpp
@@ -295,7 +295,7 @@ void Thermal::dumpVirtualSensorInfo(std::ostringstream *dump_buf) {
*dump_buf << "MINIMUM";
break;
default:
- *dump_buf << "None";
+ *dump_buf << "NONE";
break;
}
@@ -362,17 +362,28 @@ void Thermal::dumpThrottlingInfo(std::ostringstream *dump_buf) {
name_info_pair.second.throttling_info->binded_cdev_info_map) {
*dump_buf << " Cooling device name: " << binded_cdev_info_pair.first
<< std::endl;
+ *dump_buf << " WeightForPID: [";
+ for (size_t i = 0; i < kThrottlingSeverityCount; ++i) {
+ *dump_buf << binded_cdev_info_pair.second.cdev_weight_for_pid[i] << " ";
+ }
+ *dump_buf << "]" << std::endl;
+ *dump_buf << " Ceiling: [";
+ for (size_t i = 0; i < kThrottlingSeverityCount; ++i) {
+ *dump_buf << binded_cdev_info_pair.second.cdev_ceiling[i] << " ";
+ }
+ *dump_buf << "]" << std::endl;
*dump_buf << " Hard limit: [";
for (size_t i = 0; i < kThrottlingSeverityCount; ++i) {
*dump_buf << binded_cdev_info_pair.second.limit_info[i] << " ";
}
- *dump_buf << "]";
- *dump_buf << " Power threshold: [";
+ *dump_buf << "]" << std::endl;
+
+ *dump_buf << " Power threshold: [";
for (size_t i = 0; i < kThrottlingSeverityCount; ++i) {
*dump_buf << binded_cdev_info_pair.second.power_thresholds[i] << " ";
}
- *dump_buf << "]";
- *dump_buf << " Release logic: ";
+ *dump_buf << "]" << std::endl;
+ *dump_buf << " Release logic: ";
switch (binded_cdev_info_pair.second.release_logic) {
case ReleaseLogic::DECREASE:
*dump_buf << "DECREASE";
@@ -385,13 +396,12 @@ void Thermal::dumpThrottlingInfo(std::ostringstream *dump_buf) {
break;
}
*dump_buf << std::endl;
- *dump_buf << " Weight: " << binded_cdev_info_pair.second.cdev_weight;
- *dump_buf << " Cdev_ceiling: " << binded_cdev_info_pair.second.cdev_ceiling;
- *dump_buf << " Power_sample_count: "
- << binded_cdev_info_pair.second.power_sample_count;
- *dump_buf << " Power_sample_delay: "
- << binded_cdev_info_pair.second.power_sample_delay.count();
- *dump_buf << " Power_reversly_check: "
+ *dump_buf << " Power_sample_count: "
+ << binded_cdev_info_pair.second.power_sample_count << std::endl;
+ *dump_buf << " Power_sample_delay: "
+ << binded_cdev_info_pair.second.power_sample_delay.count()
+ << std::endl;
+ *dump_buf << " Power_reversly_check: " << std::boolalpha
<< binded_cdev_info_pair.second.power_reversly_check << std::endl;
}
}
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index bda51335..cf394511 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -294,22 +294,40 @@ ThermalHelper::ThermalHelper(const NotificationCallback &cb)
};
bool invalid_binded_cdev = false;
- for (auto const &binded_cdev_pair :
+ for (auto &binded_cdev_pair :
name_status_pair.second.throttling_info->binded_cdev_info_map) {
if (!cooling_device_info_map_.count(binded_cdev_pair.first)) {
invalid_binded_cdev = true;
LOG(ERROR) << "Could not find " << binded_cdev_pair.first
<< " in cooling device info map";
}
- if (binded_cdev_pair.second.cdev_weight) {
- sensor_status_map_[name_status_pair.first].pid_request_map[binded_cdev_pair.first] =
- 0;
- cdev_status_map_[binded_cdev_pair.first][name_status_pair.first] = 0;
+
+ for (const auto &cdev_weight : binded_cdev_pair.second.cdev_weight_for_pid) {
+ if (!std::isnan(cdev_weight)) {
+ sensor_status_map_[name_status_pair.first]
+ .pid_request_map[binded_cdev_pair.first] = 0;
+ cdev_status_map_[binded_cdev_pair.first][name_status_pair.first] = 0;
+ break;
+ }
}
- if (binded_cdev_pair.second.limit_info.size()) {
- sensor_status_map_[name_status_pair.first]
- .hard_limit_request_map[binded_cdev_pair.first] = 0;
- cdev_status_map_[binded_cdev_pair.first][name_status_pair.first] = 0;
+
+ for (const auto &limit_info : binded_cdev_pair.second.limit_info) {
+ if (limit_info > 0) {
+ sensor_status_map_[name_status_pair.first]
+ .hard_limit_request_map[binded_cdev_pair.first] = 0;
+ cdev_status_map_[binded_cdev_pair.first][name_status_pair.first] = 0;
+ }
+ }
+ const auto &cdev_info = cooling_device_info_map_.at(binded_cdev_pair.first);
+
+ for (auto &cdev_ceiling : binded_cdev_pair.second.cdev_ceiling) {
+ if (cdev_ceiling < 0 ||
+ static_cast<unsigned int>(cdev_ceiling) > cdev_info.max_state) {
+ LOG(ERROR) << "Sensor " << name_status_pair.first << "'s "
+ << binded_cdev_pair.first << " cdev_ceiling:" << cdev_ceiling
+ << " is higher than max state:" << cdev_info.max_state;
+ cdev_ceiling = cdev_info.max_state;
+ }
}
if (binded_cdev_pair.second.power_sample_count &&
@@ -535,13 +553,9 @@ bool ThermalHelper::readTemperatureThreshold(std::string_view sensor_name,
return true;
}
-// Return the power budget which is computed by PID algorithm
-float ThermalHelper::pidPowerCalculator(const Temperature_2_0 &temp, const SensorInfo &sensor_info,
- SensorStatus *sensor_status,
- std::chrono::milliseconds time_elapsed_ms) {
- float p = 0, i = 0, d = 0;
+size_t ThermalHelper::getTargetStateOfPID(const SensorInfo &sensor_info,
+ const SensorStatus &sensor_status) {
size_t target_state = 0;
- float power_budget = std::numeric_limits<float>::max();
for (const auto &severity : hidl_enum_range<ThrottlingSeverity>()) {
size_t state = static_cast<size_t>(severity);
@@ -549,13 +563,22 @@ float ThermalHelper::pidPowerCalculator(const Temperature_2_0 &temp, const Senso
continue;
}
target_state = state;
- if (severity > sensor_status->severity) {
- target_state = state;
+ if (severity > sensor_status.severity) {
break;
}
}
LOG(VERBOSE) << "PID target state=" << target_state;
+ return target_state;
+}
+
+// Return the power budget which is computed by PID algorithm
+float ThermalHelper::pidPowerCalculator(const Temperature_2_0 &temp, const SensorInfo &sensor_info,
+ SensorStatus *sensor_status,
+ std::chrono::milliseconds time_elapsed_ms,
+ size_t target_state) {
+ float p = 0, i = 0, d = 0;
+ float power_budget = std::numeric_limits<float>::max();
if (!target_state || (sensor_status->severity == ThrottlingSeverity::NONE)) {
sensor_status->err_integral = 0;
sensor_status->prev_err = NAN;
@@ -601,13 +624,14 @@ float ThermalHelper::pidPowerCalculator(const Temperature_2_0 &temp, const Senso
}
bool ThermalHelper::requestCdevByPower(std::string_view sensor_name, SensorStatus *sensor_status,
- const SensorInfo &sensor_info, float total_power_budget) {
+ const SensorInfo &sensor_info, float total_power_budget,
+ size_t target_state) {
float total_weight = 0, cdev_power_budget;
size_t j;
for (const auto &binded_cdev_info_pair : sensor_info.throttling_info->binded_cdev_info_map) {
- if (binded_cdev_info_pair.second.cdev_weight) {
- total_weight += binded_cdev_info_pair.second.cdev_weight;
+ if (!std::isnan(binded_cdev_info_pair.second.cdev_weight_for_pid[target_state])) {
+ total_weight += binded_cdev_info_pair.second.cdev_weight_for_pid[target_state];
}
}
@@ -618,16 +642,14 @@ bool ThermalHelper::requestCdevByPower(std::string_view sensor_name, SensorStatu
// Map cdev state by power
for (const auto &binded_cdev_info_pair : sensor_info.throttling_info->binded_cdev_info_map) {
- if (binded_cdev_info_pair.second.cdev_weight) {
- cdev_power_budget =
- total_power_budget * (binded_cdev_info_pair.second.cdev_weight / total_weight);
+ const auto cdev_weight = binded_cdev_info_pair.second.cdev_weight_for_pid[target_state];
+ if (!std::isnan(cdev_weight)) {
+ cdev_power_budget = total_power_budget * (cdev_weight / total_weight);
- int cdev_ceiling = binded_cdev_info_pair.second.cdev_ceiling;
const CdevInfo &cdev_info_pair =
cooling_device_info_map_.at(binded_cdev_info_pair.first);
for (j = 0; j < cdev_info_pair.state2power.size() - 1; ++j) {
- if (cdev_power_budget > cdev_info_pair.state2power[j] ||
- (cdev_ceiling && static_cast<int>(j) >= cdev_ceiling)) {
+ if (cdev_power_budget > cdev_info_pair.state2power[j]) {
break;
}
}
@@ -635,7 +657,7 @@ bool ThermalHelper::requestCdevByPower(std::string_view sensor_name, SensorStatu
static_cast<unsigned int>(j);
LOG(VERBOSE) << "Power allocator: Sensor " << sensor_name.data() << " allocate "
<< cdev_power_budget << "mW to " << binded_cdev_info_pair.first
- << ", update state to " << j;
+ << "(cdev_weight=" << cdev_weight << ") update state to " << j;
}
}
return true;
@@ -654,8 +676,8 @@ void ThermalHelper::requestCdevBySeverity(std::string_view sensor_name, SensorSt
}
void ThermalHelper::computeCoolingDevicesRequest(
- std::string_view sensor_name, const SensorStatus &sensor_status,
- std::vector<std::string> *cooling_devices_to_update) {
+ std::string_view sensor_name, const SensorInfo &sensor_info,
+ const SensorStatus &sensor_status, std::vector<std::string> *cooling_devices_to_update) {
unsigned int release_step = 0;
std::unique_lock<std::shared_mutex> _lock(cdev_status_map_mutex_);
@@ -665,31 +687,39 @@ void ThermalHelper::computeCoolingDevicesRequest(
}
unsigned int pid_request = 0;
unsigned int hard_limit_request = 0;
- const auto max_state = cooling_device_info_map_.at(cdev_request_pair.first).max_state;
+ const auto &binded_cdev_info =
+ sensor_info.throttling_info->binded_cdev_info_map.at(cdev_request_pair.first);
+ const auto cdev_ceiling =
+ binded_cdev_info.cdev_ceiling[static_cast<size_t>(sensor_status.severity)];
release_step = 0;
if (sensor_status.pid_request_map.count(cdev_request_pair.first)) {
- pid_request =
- std::min(sensor_status.pid_request_map.at(cdev_request_pair.first), max_state);
+ pid_request = sensor_status.pid_request_map.at(cdev_request_pair.first);
}
if (sensor_status.hard_limit_request_map.count(cdev_request_pair.first)) {
- hard_limit_request = std::min(
- sensor_status.hard_limit_request_map.at(cdev_request_pair.first), max_state);
+ hard_limit_request = sensor_status.hard_limit_request_map.at(cdev_request_pair.first);
}
+ release_step = power_files_.getReleaseStep(sensor_name, cdev_request_pair.first);
+ LOG(VERBOSE) << "Sensor: " << sensor_name.data() << " binded cooling device "
+ << cdev_request_pair.first << "'s pid_request=" << pid_request
+ << " hard_limit_request=" << hard_limit_request
+ << " release_step=" << release_step << " cdev_ceiling=" << cdev_ceiling;
+
auto request_state = std::max(pid_request, hard_limit_request);
- release_step = power_files_.getReleaseStep(
- sensor_name, cooling_device_info_map_.at(cdev_request_pair.first).power_rail);
- if (release_step >= request_state) {
- request_state = 0;
- } else {
- request_state = request_state - release_step;
+ if (release_step) {
+ if (release_step >= request_state) {
+ request_state = 0;
+ } else {
+ request_state = request_state - release_step;
+ }
}
- LOG(VERBOSE) << "Sensor: " << sensor_name.data() << " binded cooling device "
- << cdev_request_pair.first << "'s release step = " << release_step;
+ if (cdev_ceiling >= 0 && request_state > static_cast<unsigned int>(cdev_ceiling)) {
+ request_state = static_cast<unsigned int>(cdev_ceiling);
+ }
if (cdev_request_pair.second.at(sensor_name.data()) != request_state) {
cdev_request_pair.second.at(sensor_name.data()) = request_state;
@@ -1173,10 +1203,11 @@ std::chrono::milliseconds ThermalHelper::thermalWatcherCallbackFunc(
// Start PID computation
if (sensor_status.pid_request_map.size()) {
- float power_budget =
- pidPowerCalculator(temp, sensor_info, &sensor_status, time_elapsed_ms);
+ size_t target_state = getTargetStateOfPID(sensor_info, sensor_status);
+ float power_budget = pidPowerCalculator(temp, sensor_info, &sensor_status,
+ time_elapsed_ms, target_state);
if (!requestCdevByPower(name_status_pair.first, &sensor_status, sensor_info,
- power_budget)) {
+ power_budget, target_state)) {
LOG(ERROR) << "Sensor " << temp.name << " PID request cdev failed";
}
}
@@ -1200,7 +1231,7 @@ std::chrono::milliseconds ThermalHelper::thermalWatcherCallbackFunc(
binded_cdev_info_pair.second, power_rail);
}
}
- computeCoolingDevicesRequest(name_status_pair.first, sensor_status,
+ computeCoolingDevicesRequest(name_status_pair.first, sensor_info, sensor_status,
&cooling_devices_to_update);
}
diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h
index f5618fe3..1c255ee3 100644
--- a/thermal/thermal-helper.h
+++ b/thermal/thermal-helper.h
@@ -180,17 +180,22 @@ class ThermalHelper {
ThrottlingSeverity prev_hot_severity, ThrottlingSeverity prev_cold_severity,
float value) const;
bool checkVirtualSensor(std::string_view sensor_name, std::string *temp) const;
+
+ // Return the target state of PID algorithm
+ size_t getTargetStateOfPID(const SensorInfo &sensor_info, const SensorStatus &sensor_status);
+
// Return the power budget which is computed by PID algorithm
float pidPowerCalculator(const Temperature_2_0 &temp, const SensorInfo &sensor_info,
SensorStatus *sensor_status,
- const std::chrono::milliseconds time_elapsed_ms);
+ const std::chrono::milliseconds time_elapsed_ms, size_t target_state);
bool connectToPowerHal();
void updateSupportedPowerHints();
bool requestCdevByPower(std::string_view sensor_name, SensorStatus *sensor_status,
- const SensorInfo &sensor_info, float total_power_budget);
+ const SensorInfo &sensor_info, float total_power_budget,
+ size_t target_state);
void requestCdevBySeverity(std::string_view sensor_name, SensorStatus *sensor_status,
const SensorInfo &sensor_info);
- void computeCoolingDevicesRequest(std::string_view sensor_name,
+ void computeCoolingDevicesRequest(std::string_view sensor_name, const SensorInfo &sensor_info,
const SensorStatus &sensor_status,
std::vector<std::string> *cooling_devices_to_update);
void updateCoolingDevices(const std::vector<std::string> &cooling_devices_to_update);
diff --git a/thermal/utils/config_parser.cpp b/thermal/utils/config_parser.cpp
index 72572aa6..47bef9d0 100644
--- a/thermal/utils/config_parser.cpp
+++ b/thermal/utils/config_parser.cpp
@@ -68,6 +68,39 @@ int getIntFromValue(const Json::Value &value) {
}
}
+bool getIntFromJsonValues(const Json::Value &values, CdevArray *out, bool inc_check,
+ bool dec_check) {
+ CdevArray ret;
+
+ if (inc_check && dec_check) {
+ LOG(ERROR) << "Cannot enable inc_check and dec_check at the same time";
+ return false;
+ }
+
+ if (values.size() != kThrottlingSeverityCount) {
+ LOG(ERROR) << "Values size is invalid";
+ return false;
+ } else {
+ int last;
+ for (Json::Value::ArrayIndex i = 0; i < kThrottlingSeverityCount; ++i) {
+ ret[i] = getIntFromValue(values[i]);
+ if (inc_check && ret[i] < last) {
+ LOG(FATAL) << "Invalid array[" << i << "]" << ret[i] << " min=" << last;
+ return false;
+ }
+ if (dec_check && ret[i] > last) {
+ LOG(FATAL) << "Invalid array[" << i << "]" << ret[i] << " max=" << last;
+ return false;
+ }
+ last = ret[i];
+ LOG(INFO) << "[" << i << "]: " << ret[i];
+ }
+ }
+
+ *out = ret;
+ return true;
+}
+
bool getFloatFromJsonValues(const Json::Value &values, ThrottlingArray *out, bool inc_check,
bool dec_check) {
ThrottlingArray ret;
@@ -100,7 +133,6 @@ bool getFloatFromJsonValues(const Json::Value &values, ThrottlingArray *out, boo
*out = ret;
return true;
}
-
} // namespace
std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view config_path) {
@@ -372,60 +404,78 @@ std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view con
// Parse PID parameters
if (!sensors[i]["PIDInfo"].empty()) {
- LOG(INFO) << "Start to parse K_Po";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s K_Po";
if (sensors[i]["PIDInfo"]["K_Po"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["K_Po"], &k_po, false, false)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse K_Po";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse K_Pu";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s K_Pu";
if (sensors[i]["PIDInfo"]["K_Pu"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["K_Pu"], &k_pu, false, false)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse K_Pu";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse K_I";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s K_I";
if (sensors[i]["PIDInfo"]["K_I"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["K_I"], &k_i, false, false)) {
+ LOG(INFO) << "Sensor[" << name << "]: Failed to parse K_I";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse K_D";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s K_D";
if (sensors[i]["PIDInfo"]["K_D"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["K_D"], &k_d, false, false)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse K_D";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse I_Max";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s I_Max";
if (sensors[i]["PIDInfo"]["I_Max"].empty() ||
- !getFloatFromJsonValues(sensors[i]["PIDInfo"]["K_D"], &i_max, false, false)) {
+ !getFloatFromJsonValues(sensors[i]["PIDInfo"]["I_Max"], &i_max, false, false)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse I_Max";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse MaxAllocPower";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s MaxAllocPower";
if (sensors[i]["PIDInfo"]["MaxAllocPower"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["MaxAllocPower"], &max_alloc_power,
false, true)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse MaxAllocPower";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse MinAllocPower";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s MinAllocPower";
if (sensors[i]["PIDInfo"]["MinAllocPower"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["MinAllocPower"], &min_alloc_power,
false, true)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse MinAllocPower";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse S_Power";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s S_Power";
if (sensors[i]["PIDInfo"]["S_Power"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["S_Power"], &s_power, false, true)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse S_Power";
sensors_parsed.clear();
return sensors_parsed;
}
- LOG(INFO) << "Start to parse I_Cutoff";
+ LOG(INFO) << "Start to parse"
+ << " Sensor[" << name << "]'s I_Cutoff";
if (sensors[i]["PIDInfo"]["I_Cutoff"].empty() ||
!getFloatFromJsonValues(sensors[i]["PIDInfo"]["I_Cutoff"], &i_cutoff, false,
false)) {
+ LOG(ERROR) << "Sensor[" << name << "]: Failed to parse I_Cutoff";
sensors_parsed.clear();
return sensors_parsed;
}
@@ -461,29 +511,48 @@ std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view con
std::unordered_map<std::string, BindedCdevInfo> binded_cdev_info_map;
values = sensors[i]["BindedCdevInfo"];
for (Json::Value::ArrayIndex j = 0; j < values.size(); ++j) {
+ Json::Value sub_values;
const std::string &cdev_name = values[j]["CdevRequest"].asString();
- float cdev_weight;
- int cdev_ceiling;
+ ThrottlingArray cdev_weight_for_pid;
+ cdev_weight_for_pid.fill(NAN);
+ CdevArray cdev_ceiling;
+ cdev_ceiling.fill(std::numeric_limits<int>::max());
if (support_pid) {
- cdev_weight = values[j]["CdevWeightForPID"].asFloat();
- cdev_ceiling = values[j]["CdevCeilingForPID"].asInt();
+ if (!values[j]["CdevWeightForPID"].empty()) {
+ LOG(INFO) << "Sensor[" << name << "]: Star to parse " << cdev_name
+ << "'s CdevWeightForPID";
+ if (!getFloatFromJsonValues(values[j]["CdevWeightForPID"], &cdev_weight_for_pid,
+ false, false)) {
+ LOG(ERROR) << "Failed to parse CdevWeightForPID";
+ sensors_parsed.clear();
+ return sensors_parsed;
+ }
+ }
+ if (!values[j]["CdevCeiling"].empty()) {
+ LOG(INFO) << "Sensor[" << name
+ << "]: Start to parse CdevCeiling: " << cdev_name;
+ if (!getIntFromJsonValues(values[j]["CdevCeiling"], &cdev_ceiling, false,
+ false)) {
+ LOG(ERROR) << "Failed to parse CdevCeiling";
+ sensors_parsed.clear();
+ return sensors_parsed;
+ }
+ }
}
- LOG(INFO) << "CdevWeight: " << cdev_weight << ", CdevCeiling: " << cdev_ceiling;
- std::array<float, kThrottlingSeverityCount> limit_info;
- limit_info.fill(NAN);
- std::array<float, kThrottlingSeverityCount> power_thresholds;
+ CdevArray limit_info;
+ limit_info.fill(0);
+ ThrottlingArray power_thresholds;
power_thresholds.fill(NAN);
ReleaseLogic release_logic = ReleaseLogic::NONE;
- Json::Value sub_values = values[j]["LimitInfo"];
+ sub_values = values[j]["LimitInfo"];
if (sub_values.size()) {
- if (!getFloatFromJsonValues(sub_values, &limit_info, false, false)) {
+ LOG(INFO) << "Sensor[" << name << "]: Start to parse LimitInfo: " << cdev_name;
+ if (!getIntFromJsonValues(sub_values, &limit_info, false, false)) {
+ LOG(ERROR) << "Failed to parse LimitInfo";
sensors_parsed.clear();
return sensors_parsed;
- } else {
- LOG(INFO) << "Sensor[" << name
- << "]: Add cooling device request: " << cdev_name;
}
support_hard_limit = true;
}
@@ -544,7 +613,7 @@ std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view con
.power_thresholds = power_thresholds,
.release_logic = release_logic,
.power_reversly_check = power_reversly_check,
- .cdev_weight = cdev_weight,
+ .cdev_weight_for_pid = cdev_weight_for_pid,
.cdev_ceiling = cdev_ceiling,
.power_sample_count = power_sample_count,
.power_sample_delay = power_sample_delay,
@@ -552,7 +621,7 @@ std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view con
}
bool is_monitor = (send_cb | send_powerhint | support_pid | support_hard_limit);
- LOG(INFO) << "Sensor[" << name << "]'s Monitor: " << is_monitor;
+ LOG(INFO) << "Sensor[" << name << "]'s Monitor: " << std::boolalpha << is_monitor;
std::unique_ptr<VirtualSensorInfo> virtual_sensor_info;
if (is_virtual_sensor) {
diff --git a/thermal/utils/config_parser.h b/thermal/utils/config_parser.h
index 6d4bab49..b6a725ab 100644
--- a/thermal/utils/config_parser.h
+++ b/thermal/utils/config_parser.h
@@ -34,6 +34,7 @@ using ::android::hardware::thermal::V2_0::ThrottlingSeverity;
constexpr size_t kThrottlingSeverityCount = std::distance(
hidl_enum_range<ThrottlingSeverity>().begin(), hidl_enum_range<ThrottlingSeverity>().end());
using ThrottlingArray = std::array<float, static_cast<size_t>(kThrottlingSeverityCount)>;
+using CdevArray = std::array<int, static_cast<size_t>(kThrottlingSeverityCount)>;
constexpr std::chrono::milliseconds kMinPollIntervalMs = std::chrono::milliseconds(2000);
constexpr std::chrono::milliseconds kUeventPollTimeoutMs = std::chrono::milliseconds(300000);
@@ -60,11 +61,11 @@ enum ReleaseLogic : uint32_t {
};
struct BindedCdevInfo {
- ThrottlingArray limit_info;
+ CdevArray limit_info;
ThrottlingArray power_thresholds;
ReleaseLogic release_logic;
- float cdev_weight;
- int cdev_ceiling;
+ ThrottlingArray cdev_weight_for_pid;
+ CdevArray cdev_ceiling;
int power_sample_count;
std::chrono::milliseconds power_sample_delay;
bool power_reversly_check;