summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia-yi Chen <jychen@google.com>2022-05-31 23:46:13 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-05-31 23:46:13 +0000
commit6313ee485913912361c8377efcc8f1383f04d201 (patch)
tree4f14f24a3bb92f3d2547a876754954a8c51446d9
parentb3a989f663ba3c2f942ff253a8eff88e03b6494d (diff)
parent03168e2a876d44b23f5b4811892bfe3134cf0cf4 (diff)
downloadpixel-6313ee485913912361c8377efcc8f1383f04d201.tar.gz
Merge "thermal: support excluded powr rail check" into tm-dev am: 03168e2a87
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/pixel/+/18283847 Change-Id: I35d2f94b9af2ef110213db8da31f61cf28f14a9e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--thermal/thermal-helper.cpp13
-rw-r--r--thermal/utils/thermal_info.cpp31
-rw-r--r--thermal/utils/thermal_info.h1
-rw-r--r--thermal/utils/thermal_throttling.cpp52
-rw-r--r--thermal/utils/thermal_throttling.h7
5 files changed, 91 insertions, 13 deletions
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index b44ccbd1..8bc67414 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -232,16 +232,17 @@ ThermalHelper::ThermalHelper(const NotificationCallback &cb)
}
// Update cooling device max state
- for (auto &binded_cdev_pair :
+ for (auto &binded_cdev_info_pair :
name_status_pair.second.throttling_info->binded_cdev_info_map) {
- const auto &cdev_info = cooling_device_info_map_.at(binded_cdev_pair.first);
+ const auto &cdev_info = cooling_device_info_map_.at(binded_cdev_info_pair.first);
- for (auto &cdev_ceiling : binded_cdev_pair.second.cdev_ceiling) {
+ for (auto &cdev_ceiling : binded_cdev_info_pair.second.cdev_ceiling) {
if (cdev_ceiling > cdev_info.max_state) {
if (cdev_ceiling != std::numeric_limits<int>::max()) {
- 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;
+ LOG(ERROR)
+ << "Sensor " << name_status_pair.first << "'s "
+ << binded_cdev_info_pair.first << " cdev_ceiling:" << cdev_ceiling
+ << " is higher than max state:" << cdev_info.max_state;
}
cdev_ceiling = cdev_info.max_state;
}
diff --git a/thermal/utils/thermal_info.cpp b/thermal/utils/thermal_info.cpp
index 02c147ee..f01d11be 100644
--- a/thermal/utils/thermal_info.cpp
+++ b/thermal/utils/thermal_info.cpp
@@ -749,6 +749,31 @@ bool ParseSensorInfo(std::string_view config_path,
};
}
+ std::unordered_map<std::string, ThrottlingArray> excluded_power_info_map;
+ values = sensors[i]["ExcludedPowerInfo"];
+ for (Json::Value::ArrayIndex j = 0; j < values.size(); ++j) {
+ Json::Value sub_values;
+ const std::string &power_rail = values[j]["PowerRail"].asString();
+ if (power_rail.empty()) {
+ LOG(ERROR) << "Sensor[" << name << "] failed to parse excluded PowerRail";
+ sensors_parsed->clear();
+ return false;
+ }
+ ThrottlingArray power_weight;
+ power_weight.fill(1);
+ if (!values[j]["PowerWeight"].empty()) {
+ LOG(INFO) << "Sensor[" << name << "]: Start to parse " << power_rail
+ << "'s PowerWeight";
+ if (!getFloatFromJsonValues(values[j]["PowerWeight"], &power_weight, false,
+ false)) {
+ LOG(ERROR) << "Failed to parse PowerWeight";
+ sensors_parsed->clear();
+ return false;
+ }
+ }
+ excluded_power_info_map[power_rail] = power_weight;
+ }
+
if (is_hidden && send_cb) {
LOG(ERROR) << "is_hidden and send_cb cannot be enabled together";
sensors_parsed->clear();
@@ -764,9 +789,9 @@ bool ParseSensorInfo(std::string_view config_path,
trigger_sensor, formula});
}
- std::shared_ptr<ThrottlingInfo> throttling_info(
- new ThrottlingInfo{k_po, k_pu, k_i, k_d, i_max, max_alloc_power, min_alloc_power,
- s_power, i_cutoff, i_default, tran_cycle, binded_cdev_info_map});
+ std::shared_ptr<ThrottlingInfo> throttling_info(new ThrottlingInfo{
+ k_po, k_pu, k_i, k_d, i_max, max_alloc_power, min_alloc_power, s_power, i_cutoff,
+ i_default, tran_cycle, excluded_power_info_map, binded_cdev_info_map});
(*sensors_parsed)[name] = {
.type = sensor_type,
diff --git a/thermal/utils/thermal_info.h b/thermal/utils/thermal_info.h
index 58ef19a8..e56b358d 100644
--- a/thermal/utils/thermal_info.h
+++ b/thermal/utils/thermal_info.h
@@ -97,6 +97,7 @@ struct ThrottlingInfo {
ThrottlingArray i_cutoff;
float i_default;
int tran_cycle;
+ std::unordered_map<std::string, ThrottlingArray> excluded_power_info_map;
std::unordered_map<std::string, BindedCdevInfo> binded_cdev_info_map;
};
diff --git a/thermal/utils/thermal_throttling.cpp b/thermal/utils/thermal_throttling.cpp
index 43b36505..6f2d1205 100644
--- a/thermal/utils/thermal_throttling.cpp
+++ b/thermal/utils/thermal_throttling.cpp
@@ -37,6 +37,7 @@ namespace hardware {
namespace thermal {
namespace V2_0 {
namespace implementation {
+using android::base::StringPrintf;
// To find the next PID target state according to the current thermal severity
size_t getTargetStateOfPID(const SensorInfo &sensor_info, const ThrottlingSeverity curr_severity) {
@@ -235,6 +236,28 @@ float ThermalThrottling::updatePowerBudget(const Temperature_2_0 &temp,
return power_budget;
}
+float ThermalThrottling::computeExcludedPower(
+ const SensorInfo &sensor_info, const ThrottlingSeverity curr_severity,
+ const std::unordered_map<std::string, PowerStatus> &power_status_map,
+ std::string *log_buf) {
+ float excluded_power = 0.0;
+
+ for (const auto &excluded_power_info_pair :
+ sensor_info.throttling_info->excluded_power_info_map) {
+ const auto last_updated_avg_power =
+ power_status_map.at(excluded_power_info_pair.first).last_updated_avg_power;
+ if (!std::isnan(last_updated_avg_power)) {
+ excluded_power += last_updated_avg_power *
+ excluded_power_info_pair.second[static_cast<size_t>(curr_severity)];
+ log_buf->append(StringPrintf(
+ "(%s: %0.2f mW, cdev_weight: %f)", excluded_power_info_pair.first.c_str(),
+ last_updated_avg_power,
+ excluded_power_info_pair.second[static_cast<size_t>(curr_severity)]));
+ }
+ }
+ return excluded_power;
+}
+
// Allocate power budget to binded cooling devices base on the real ODPM power data
bool ThermalThrottling::allocatePowerToCdev(
const Temperature_2_0 &temp, const SensorInfo &sensor_info,
@@ -248,10 +271,23 @@ bool ThermalThrottling::allocatePowerToCdev(
bool low_power_device_check = true;
bool is_budget_allocated = false;
bool power_data_invalid = false;
- auto total_power_budget = updatePowerBudget(temp, sensor_info, time_elapsed_ms, curr_severity);
std::set<std::string> allocated_cdev;
+ std::string log_buf;
std::unique_lock<std::shared_mutex> _lock(thermal_throttling_status_map_mutex_);
+ auto total_power_budget = updatePowerBudget(temp, sensor_info, time_elapsed_ms, curr_severity);
+
+ if (sensor_info.throttling_info->excluded_power_info_map.size()) {
+ std::string log_buf;
+ total_power_budget -=
+ computeExcludedPower(sensor_info, curr_severity, power_status_map, &log_buf);
+ total_power_budget = std::max(total_power_budget, 0.0f);
+ if (!log_buf.empty()) {
+ LOG(INFO) << temp.name << " power budget=" << total_power_budget << " after " << log_buf
+ << " is excluded";
+ }
+ }
+
// Compute total cdev weight
for (const auto &binded_cdev_info_pair : sensor_info.throttling_info->binded_cdev_info_map) {
const auto cdev_weight = binded_cdev_info_pair.second
@@ -271,8 +307,6 @@ bool ThermalThrottling::allocatePowerToCdev(
binded_cdev_info_pair.second
.cdev_weight_for_pid[static_cast<size_t>(curr_severity)];
- const CdevInfo &cdev_info = cooling_device_info_map.at(binded_cdev_info_pair.first);
-
if (allocated_cdev.count(binded_cdev_info_pair.first)) {
continue;
}
@@ -312,10 +346,18 @@ bool ThermalThrottling::allocatePowerToCdev(
allocated_power += last_updated_avg_power;
allocated_weight += cdev_weight;
allocated_cdev.insert(binded_cdev_info_pair.first);
+ log_buf.append(StringPrintf("(%s: %0.2f mW)",
+ binded_cdev_info_pair.second.power_rail.c_str(),
+ last_updated_avg_power));
+
LOG(VERBOSE) << temp.name << " binded " << binded_cdev_info_pair.first
<< " has been already at min state 0";
}
} else {
+ const CdevInfo &cdev_info = cooling_device_info_map.at(binded_cdev_info_pair.first);
+ log_buf.append(StringPrintf("(%s: %0.2f mW)",
+ binded_cdev_info_pair.second.power_rail.c_str(),
+ last_updated_avg_power));
// Ignore the power distribution if the CDEV has no space to reduce power
if ((cdev_power_adjustment < 0 &&
thermal_throttling_status_map_[temp.name].pid_cdev_request_map.at(
@@ -394,7 +436,9 @@ bool ThermalThrottling::allocatePowerToCdev(
is_budget_allocated = true;
}
}
-
+ if (log_buf.size()) {
+ LOG(INFO) << temp.name << " binded power rails: " << log_buf;
+ }
return true;
}
diff --git a/thermal/utils/thermal_throttling.h b/thermal/utils/thermal_throttling.h
index ad3f8a43..d373dd36 100644
--- a/thermal/utils/thermal_throttling.h
+++ b/thermal/utils/thermal_throttling.h
@@ -97,6 +97,13 @@ class ThermalThrottling {
float updatePowerBudget(const Temperature_2_0 &temp, const SensorInfo &sensor_info,
std::chrono::milliseconds time_elapsed_ms,
ThrottlingSeverity curr_severity);
+
+ // PID algo - return the power number from excluded power rail list
+ float computeExcludedPower(const SensorInfo &sensor_info,
+ const ThrottlingSeverity curr_severity,
+ const std::unordered_map<std::string, PowerStatus> &power_status_map,
+ std::string *log_buf);
+
// PID algo - allocate the power to target CDEV according to the ODPM
bool allocatePowerToCdev(
const Temperature_2_0 &temp, const SensorInfo &sensor_info,