From cca80279e20dc2f0c815a351b51861e2c927461b Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Mon, 13 Jan 2020 13:06:13 -0800 Subject: [PATCH] power: Add DPF and update imminent hints to AIDL Adds FIXED_PERFORMANCE mode for the dynamic performance framework as well as a "display update imminent hint" to the AIDL version of the Power HAL. Test: VtsHalPowerTargetTest Bug: 120610745 Bug: 136285293 Bug: 146453294 Change-Id: I0cda99822eed015131f8f068512842a388f9c25c --- power/aidl/android/hardware/power/Boost.aidl | 7 +++ power/aidl/android/hardware/power/IPower.aidl | 2 +- power/aidl/android/hardware/power/Mode.aidl | 44 +++++++++++++++++++ power/aidl/vts/VtsHalPowerTargetTest.cpp | 22 +++++++++- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/power/aidl/android/hardware/power/Boost.aidl b/power/aidl/android/hardware/power/Boost.aidl index 162a36ac2c..c992fd3e67 100644 --- a/power/aidl/android/hardware/power/Boost.aidl +++ b/power/aidl/android/hardware/power/Boost.aidl @@ -28,6 +28,13 @@ enum Boost { */ INTERACTION, + /** + * This boost indicates that the framework is likely to provide a new + * display frame soon. This implies that the device should ensure that the + * display processing path is powered up and ready to receive that update. + */ + DISPLAY_UPDATE_IMMINENT, + /** * Below hints are currently not sent in Android framework but OEM might choose to * implement for power/perf optimizations. diff --git a/power/aidl/android/hardware/power/IPower.aidl b/power/aidl/android/hardware/power/IPower.aidl index 9fb3fc0c48..2c4bd86014 100644 --- a/power/aidl/android/hardware/power/IPower.aidl +++ b/power/aidl/android/hardware/power/IPower.aidl @@ -43,7 +43,7 @@ interface IPower { */ boolean isModeSupported(in Mode type); - /** + /** * setBoost() indicates the device may need to boost some resources, as the * the load is likely to increase before the kernel governors can react. * Depending on the boost, it may be appropriate to raise the frequencies of diff --git a/power/aidl/android/hardware/power/Mode.aidl b/power/aidl/android/hardware/power/Mode.aidl index 1792add2a0..ae113e3799 100644 --- a/power/aidl/android/hardware/power/Mode.aidl +++ b/power/aidl/android/hardware/power/Mode.aidl @@ -38,6 +38,50 @@ enum Mode { */ SUSTAINED_PERFORMANCE, + /** + * Sets the device to a fixed performance level which can be sustained under + * normal indoor conditions for at least 10 minutes. + * + * This is similar to sustained performance mode, except that whereas + * sustained performance mode puts an upper bound on performance in the + * interest of long-term stability, fixed performance mode puts both upper + * and lower bounds on performance such that any workload run while in a + * fixed performance mode should complete in a repeatable amount of time + * (except if the device is under thermal throttling). + * + * This mode is not intended for general purpose use, but rather to enable + * games and other performance-sensitive applications to reduce the number + * of variables during profiling and performance debugging. As such, while + * it is valid to set the device to minimum clocks for all subsystems in + * this mode, it is preferable to attempt to make the relative performance + * of the CPU, GPU, and other subsystems match typical usage, even if the + * frequencies have to be reduced to provide sustainability. + * + * To calibrate this mode, follow these steps: + * + * 1) Build and push the HWUI macrobench as described in + * //frameworks/base/libs/hwui/tests/macrobench/how_to_run.txt + * 2) Run the macrobench as follows: + * while true; do \ + * adb shell /data/benchmarktest/hwuimacro/hwuimacro shadowgrid2 -c 200 -r 10; \ + * done + * 3) Determine a fixed set of device clocks such that the loop in (2) can + * run for at least 10 minutes, starting from an idle device on a desk + * at room temperature (roughly 22 Celsius), without hitting thermal + * throttling. + * 4) After setting those clocks, set the system property + * ro.power.fixed_performance_scale_factor to a value N, where N is the + * number of times the loop from (2) runs during the 10 minute test + * cycle. It is expected that in FIXED_PERFORMANCE mode, unless there is + * thermal throttling, the loop will run N to N+1 times (inclusive). + * + * After calibrating this, while in FIXED_PERFORMANCE mode, the macrobench + * results obtained while running the loop in (2) should be consistent both + * within a given run and from the first run in the 10 minute window through + * the last run in the window. + */ + FIXED_PERFORMANCE, + /** * This mode indicates VR Mode is activated or not. VR mode is intended * to provide minimum guarantee for performance for the amount of time the diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp index c0e0858d58..25a385ed34 100644 --- a/power/aidl/vts/VtsHalPowerTargetTest.cpp +++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ using android::ProcessState; using android::sp; using android::String16; +using android::base::GetUintProperty; using android::binder::Status; using android::hardware::power::Boost; using android::hardware::power::IPower; @@ -77,7 +79,7 @@ TEST_P(PowerAidl, isModeSupported) { for (const auto& mode : kInvalidModes) { bool supported; ASSERT_TRUE(power->isModeSupported(mode, &supported).isOk()); - // Should return false for values outsides enum + // Should return false for values outside enum ASSERT_FALSE(supported); } } @@ -103,11 +105,27 @@ TEST_P(PowerAidl, isBoostSupported) { for (const auto& boost : kInvalidBoosts) { bool supported; ASSERT_TRUE(power->isBoostSupported(boost, &supported).isOk()); - // Should return false for values outsides enum + // Should return false for values outside enum ASSERT_FALSE(supported); } } +// FIXED_PERFORMANCE mode is required for all devices which ship on Android 11 +// or later +TEST_P(PowerAidl, hasFixedPerformance) { + auto apiLevel = GetUintProperty("ro.product.first_api_level", 0); + if (apiLevel == 0) { + apiLevel = GetUintProperty("ro.build.version.sdk", 0); + } + ASSERT_NE(apiLevel, 0); + + if (apiLevel >= 30) { + bool supported; + ASSERT_TRUE(power->isModeSupported(Mode::FIXED_PERFORMANCE, &supported).isOk()); + ASSERT_TRUE(supported); + } +} + INSTANTIATE_TEST_SUITE_P(Power, PowerAidl, testing::ValuesIn(android::getAidlHalInstanceNames(IPower::descriptor)), android::PrintInstanceNameToString);