powerstats: correct TPU, GPU, several DVFS buckets and frequency unit

Bug: 197152245
Test: dumpsys android.hardware.power.stats.IPowerStats/default
Change-Id: Ie4f260c643e3d19f8080436b3a0197764196ccfc
This commit is contained in:
samou 2021-08-25 10:58:48 +00:00 committed by Sam Ou
parent df5cec3e17
commit 21623c73d0
2 changed files with 79 additions and 194 deletions

View file

@ -42,8 +42,6 @@ using aidl::android::hardware::power::stats::IioEnergyMeterDataProvider;
using aidl::android::hardware::power::stats::PixelStateResidencyDataProvider;
using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer;
constexpr char kBootHwSoCRev[] = "ro.boot.hw.soc.rev";
// TODO (b/181070764) (b/182941084):
// Remove this when Wifi/BT energy consumption models are available or revert before ship
using aidl::android::hardware::power::stats::EnergyConsumerResult;
@ -147,169 +145,61 @@ void addDvfsStats(std::shared_ptr<PowerStats> p) {
std::vector<DvfsStateResidencyDataProvider::Config> cfgs;
cfgs.push_back({"MIF", {
std::make_pair("3172KHz", "3172000"),
std::make_pair("2730KHz", "2730000"),
std::make_pair("2535KHz", "2535000"),
std::make_pair("2288KHz", "2288000"),
std::make_pair("2028KHz", "2028000"),
std::make_pair("1716KHz", "1716000"),
std::make_pair("1539KHz", "1539000"),
std::make_pair("1352KHz", "1352000"),
std::make_pair("1014KHz", "1014000"),
std::make_pair("845KHz", "845000"),
std::make_pair("676KHz", "676000"),
std::make_pair("546KHz", "546000"),
std::make_pair("421KHz", "421000"),
std::make_pair("0KHz", "0"),
std::make_pair("3172MHz", "3172000"),
std::make_pair("2730MHz", "2730000"),
std::make_pair("2535MHz", "2535000"),
std::make_pair("2288MHz", "2288000"),
std::make_pair("2028MHz", "2028000"),
std::make_pair("1716MHz", "1716000"),
std::make_pair("1539MHz", "1539000"),
std::make_pair("1352MHz", "1352000"),
std::make_pair("1014MHz", "1014000"),
std::make_pair("845MHz", "845000"),
std::make_pair("676MHz", "676000"),
std::make_pair("546MHz", "546000"),
std::make_pair("421MHz", "421000"),
}});
cfgs.push_back({"CL0", {
std::make_pair("1598MHz", "1598000"),
std::make_pair("1197MHz", "1197000"),
std::make_pair("1098MHz", "1098000"),
std::make_pair("930MHz", "930000"),
std::make_pair("738MHz", "738000"),
std::make_pair("574MHz", "574000"),
std::make_pair("300MHz", "300000"),
std::make_pair("0MHz", "0"),
}});
cfgs.push_back({"CL1", {
std::make_pair("2466KHz", "2466000"),
std::make_pair("2393KHz", "2393000"),
std::make_pair("2348KHz", "2348000"),
std::make_pair("2253KHz", "2253000"),
std::make_pair("2130KHz", "2130000"),
std::make_pair("1999KHz", "1999000"),
std::make_pair("1836KHz", "1836000"),
std::make_pair("1663KHz", "1663000"),
std::make_pair("1491KHz", "1491000"),
std::make_pair("1328KHz", "1328000"),
std::make_pair("1197KHz", "1197000"),
std::make_pair("1024KHz", "1024000"),
std::make_pair("910KHz", "910000"),
std::make_pair("799KHz", "799000"),
std::make_pair("696KHz", "696000"),
std::make_pair("533KHz", "533000"),
std::make_pair("400KHz", "400000"),
std::make_pair("0KHz", "0"),
std::make_pair("910MHz", "910000"),
std::make_pair("799MHz", "799000"),
std::make_pair("696MHz", "696000"),
std::make_pair("533MHz", "533000"),
std::make_pair("400MHz", "400000"),
std::make_pair("0MHz", "0"),
}});
// B0/B1 chips have different DVFS operating points than A0/A1 SoC
const int socRev = android::base::GetIntProperty(kBootHwSoCRev, 0);
if (socRev >= 2) {
cfgs.push_back({"CL0", {
std::make_pair("2196KHz", "2196000"),
std::make_pair("2098KHz", "2098000"),
std::make_pair("2024KHz", "2024000"),
std::make_pair("1950KHz", "1950000"),
std::make_pair("1803KHz", "1803000"),
std::make_pair("1704KHz", "1704000"),
std::make_pair("1598KHz", "1598000"),
std::make_pair("1401KHz", "1401000"),
std::make_pair("1328KHz", "1328000"),
std::make_pair("1197KHz", "1197000"),
std::make_pair("1098KHz", "1098000"),
std::make_pair("930KHz", "930000"),
std::make_pair("738KHz", "738000"),
std::make_pair("574KHz", "574000"),
std::make_pair("300KHz", "300000"),
std::make_pair("0KHz", "0"),
}});
cfgs.push_back({"CL2", {
std::make_pair("984MHz", "984000"),
std::make_pair("851MHz", "851000"),
std::make_pair("500MHz", "500000"),
std::make_pair("0MHz", "0"),
}});
cfgs.push_back({"CL2", {
std::make_pair("3195KHz", "3195000"),
std::make_pair("3097KHz", "3097000"),
std::make_pair("2950KHz", "2950000"),
std::make_pair("2850KHz", "2850000"),
std::make_pair("2802KHz", "2802000"),
std::make_pair("2704KHz", "2704000"),
std::make_pair("2630KHz", "2630000"),
std::make_pair("2507KHz", "2507000"),
std::make_pair("2401KHz", "2401000"),
std::make_pair("2252KHz", "2252000"),
std::make_pair("2188KHz", "2188000"),
std::make_pair("2048KHz", "2048000"),
std::make_pair("1826KHz", "1826000"),
std::make_pair("1745KHz", "1745000"),
std::make_pair("1582KHz", "1582000"),
std::make_pair("1426KHz", "1426000"),
std::make_pair("1277KHz", "1277000"),
std::make_pair("1106KHz", "1106000"),
std::make_pair("984KHz", "984000"),
std::make_pair("851KHz", "851000"),
std::make_pair("500KHz", "500000"),
std::make_pair("0KHz", "0"),
}});
cfgs.push_back({"TPU", {
std::make_pair("1393KHz", "1393000"),
std::make_pair("1180KHz", "1180000"),
std::make_pair("1024KHz", "1024000"),
std::make_pair("967KHz", "967000"),
std::make_pair("836KHz", "836000"),
std::make_pair("627KHz", "627000"),
std::make_pair("455KHz", "455000"),
std::make_pair("226KHz", "226000"),
std::make_pair("RET_SLOW", "6"),
std::make_pair("S_OFF", "5"),
std::make_pair("S_SLOW", "4"),
std::make_pair("DS_FAST", "3"),
std::make_pair("DS_SLOW", "2"),
std::make_pair("DS_OFF", "1"),
std::make_pair("OFF", "0"),
}});
} else {
cfgs.push_back({"CL0", {
std::make_pair("2196KHz", "2196000"),
std::make_pair("2098KHz", "2098000"),
std::make_pair("2024KHz", "2024000"),
std::make_pair("1950KHz", "1950000"),
std::make_pair("1868KHz", "1868000"),
std::make_pair("1745KHz", "1745000"),
std::make_pair("1598KHz", "1598000"),
std::make_pair("1459KHz", "1459000"),
std::make_pair("1328KHz", "1328000"),
std::make_pair("1197KHz", "1197000"),
std::make_pair("1098KHz", "1098000"),
std::make_pair("889KHz", "889000"),
std::make_pair("738KHz", "738000"),
std::make_pair("574KHz", "574000"),
std::make_pair("300KHz", "300000"),
std::make_pair("0KHz", "0"),
}});
cfgs.push_back({"CL2", {
std::make_pair("3195KHz", "3195000"),
std::make_pair("3097KHz", "3097000"),
std::make_pair("2999KHz", "2999000"),
std::make_pair("2900KHz", "2900000"),
std::make_pair("2802KHz", "2802000"),
std::make_pair("2704KHz", "2704000"),
std::make_pair("2630KHz", "2630000"),
std::make_pair("2507KHz", "2507000"),
std::make_pair("2302KHz", "2302000"),
std::make_pair("2188KHz", "2188000"),
std::make_pair("2048KHz", "2048000"),
std::make_pair("1901KHz", "1901000"),
std::make_pair("1745KHz", "1745000"),
std::make_pair("1582KHz", "1582000"),
std::make_pair("1426KHz", "1426000"),
std::make_pair("1237KHz", "1237000"),
std::make_pair("1106KHz", "1106000"),
std::make_pair("984KHz", "984000"),
std::make_pair("848KHz", "848000"),
std::make_pair("500KHz", "500000"),
std::make_pair("0KHz", "0"),
}});
cfgs.push_back({"TPU", {
std::make_pair("1393KHz", "1393000"),
std::make_pair("1180KHz", "1180000"),
std::make_pair("1049KHz", "1049000"),
std::make_pair("967KHz", "967000"),
std::make_pair("721KHz", "721000"),
std::make_pair("648KHz", "648000"),
std::make_pair("455KHz", "455000"),
std::make_pair("250KHz", "250000"),
std::make_pair("RET_SLOW", "6"),
std::make_pair("S_OFF", "5"),
std::make_pair("S_SLOW", "4"),
std::make_pair("DS_FAST", "3"),
std::make_pair("DS_SLOW", "2"),
std::make_pair("DS_OFF", "1"),
std::make_pair("OFF", "0"),
}});
}
cfgs.push_back({"TPU", {
std::make_pair("1066MHz", "1066000"),
std::make_pair("845MHz", "845000"),
std::make_pair("625MHz", "625000"),
std::make_pair("227MHz", "227000"),
std::make_pair("RET_SLOW", "6"),
std::make_pair("S_OFF", "5"),
std::make_pair("S_SLOW", "4"),
std::make_pair("DS_FAST", "3"),
std::make_pair("DS_SLOW", "2"),
std::make_pair("DS_OFF", "1"),
std::make_pair("OFF", "0"),
}});
p->addStateResidencyDataProvider(std::make_unique<DvfsStateResidencyDataProvider>(
"/sys/devices/platform/acpm_stats/fvp_stats", NS_TO_MS, cfgs));
@ -357,6 +247,7 @@ void addSoC(std::shared_ptr<PowerStats> p) {
std::make_pair("SICD", "SICD"),
std::make_pair("SLEEP", "SLEEP"),
std::make_pair("SLEEP_SLCMON", "SLEEP_SLCMON"),
std::make_pair("SLEEP_HSI1ON", "SLEEP_HSI1ON"),
std::make_pair("STOP", "STOP"),
};
const std::vector<std::pair<std::string, std::string>> mifReqStateHeaders = {
@ -429,36 +320,29 @@ void addCPUclusters(std::shared_ptr<PowerStats> p) {
void addGPU(std::shared_ptr<PowerStats> p) {
// Add gpu energy consumer
std::map<std::string, int32_t> stateCoeffs;
const int socRev = android::base::GetIntProperty(kBootHwSoCRev, 0);
// B0/B1 chips have different GPU DVFS operating points than A0/A1 SoC
if (socRev >= 2) {
stateCoeffs = {
{"151000", 642},
{"202000", 890},
{"251000", 1102},
{"302000", 1308},
{"351000", 1522},
{"400000", 1772},
{"471000", 2105},
{"510000", 2292},
{"572000", 2528},
{"701000", 3127},
{"762000", 3452},
{"848000", 4044}};
} else {
stateCoeffs = {
{"151000", 843},
{"302000", 1529},
{"455000", 2298},
{"572000", 2866},
{"670000", 3191}};
}
// TODO (b/197721618): Measuring the GPU power numbers
stateCoeffs = {
{"151000", 642},
{"202000", 890},
{"251000", 1102},
{"302000", 1308},
{"351000", 1522},
{"400000", 1772},
{"471000", 2105},
{"510000", 2292},
{"572000", 2528},
{"701000", 3127},
{"762000", 3452},
{"848000", 4044}};
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
EnergyConsumerType::OTHER, "GPU", {"S2S_VDD_G3D"},
{{UID_TIME_IN_STATE, "/sys/devices/platform/1c500000.mali/uid_time_in_state"}},
EnergyConsumerType::OTHER, "GPU", {"S8S_VDD_G3D_L2"},
{{UID_TIME_IN_STATE, "/sys/devices/platform/28000000.mali/uid_time_in_state"}},
stateCoeffs));
p->addStateResidencyDataProvider(std::make_unique<DevfreqStateResidencyDataProvider>("GPU",
"/sys/devices/platform/28000000.mali"));
}
void addMobileRadio(std::shared_ptr<PowerStats> p)
@ -634,10 +518,10 @@ void addPowerDomains(std::shared_ptr<PowerStats> p) {
};
std::vector<GenericStateResidencyDataProvider::PowerEntityConfig> cfgs;
for (std::string name : {"pd-tpu", "pd-bo", "pd-tnr", "pd-gdc", "pd-mcsc", "pd-ipp",
"pd-g3aa", "pd-dns", "pd-itp", "pd-pdp", "pd-csis",
"pd-mfc", "pd-g2d", "pd-dpu", "pd-disp", "pd-hsi0",
"pd-embedded_g3d", "pd-g3d", "pd-eh"}) {
for (std::string name : {"pd-aur", "pd-tpu", "pd-bo", "pd-tnr", "pd-gdc", "pd-mcsc", "pd-itp",
"pd-ipp", "pd-g3aa", "pd-dns", "pd-pdp", "pd-csis",
"pd-mfc", "pd-g2d", "pd-disp", "pd-dpu", "pd-hsi0",
"pd-g3d", "pd-embedded_g3d", "pd-eh"}) {
cfgs.emplace_back(generateGenericStateResidencyConfigs(cpuStateConfig, cpuStateHeaders),
name, name + ":");
}
@ -655,10 +539,11 @@ void addTPU(std::shared_ptr<PowerStats> p) {
std::map<std::string, int32_t> stateCoeffs;
stateCoeffs = {
{"500000", 10},
{"800000", 20},
{"1066000", 30},
{"1230000", 40}};
// TODO (b/197721618): Measuring the TPU power numbers
{"227000", 10},
{"625000", 20},
{"845000", 30},
{"1066000", 40}};
p->addEnergyConsumer(PowerStatsEnergyConsumer::createMeterAndAttrConsumer(p,
EnergyConsumerType::OTHER, "TPU", {"S10M_VDD_TPU"},