From 919a6ad95009492ac96b11cb1bf50ae22e7c2d6b Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Sun, 6 Oct 2019 04:16:15 +0300 Subject: power: Handle launch and interaction hints for legacy platforms Author: Michael Bestas Date: Mon Mar 26 01:52:03 2018 +0300 power: apq8084: Add support for power profile & boost * Based on msm8974 HAL. Change-Id: I88ce707b022f7b122ad7a2fcfc67fde0075d7e7a Author: Michael Bestas Date: Mon Mar 26 02:07:03 2018 +0300 power: msm8226: Add support for power profile & boost * Based on legacy HAL implementation Change-Id: Ifb93945e4e4005ef922cacee95e51bb95d5df9e3 Author: Michael Bestas Date: Mon Mar 26 02:13:51 2018 +0300 power: msm8610: Add support for power profile & boost * Based on legacy HAL implementation Change-Id: If778938b9703fd01185c2448bc83a09f04348333 Author: dianlujitao Date: Sun Mar 25 18:08:45 2018 +0800 power: msm8916: Add support for power profile & boost * Based on legacy HAL implementation Change-Id: I20225ae9244023555724c76df5e208fd60eb3841 Author: Michael Bestas Date: Mon Jan 22 02:30:25 2018 +0200 power: msm8974: Add support for power profile * Based on Steve Kondik's and Zhao Wei Liew's implementation from the legacy HAL. Change-Id: Ie2a28b589537349cbcefc5b64e5404d346edf2c2 Author: Michael Bestas Date: Mon Mar 26 03:24:26 2018 +0300 power: msm8974: POWER_HINT_INTERACTION improvements Change-Id: I9bde2a1d62fcb9e987741b5932f8f50a019cdfd2 Author: Craig Tatlor Date: Mon May 21 17:22:31 2018 +0100 power: msm8974: Build with with BOARD_VNDK_VERSION time.h isnt included by default when vndk is enabled. Change-Id: I7ca6ca601a8d25557bd1bb0484766121a9ae5633 Author: Michael Bestas Date: Mon Mar 26 03:00:15 2018 +0300 power: msm8992: Add support for power profile & boost * Based on legacy HAL implementation Change-Id: I9ebb44c1e215a76a95180a6188e80cb24f0b03ba Author: Michael Bestas Date: Mon Mar 26 03:00:30 2018 +0300 power: msm8994: Add support for power profile & boost * Based on legacy HAL implementation Change-Id: I5aa0b75b493825f2d87ce6eea0f3c3b1c3bba135 Author: Michael Bestas Date: Fri May 25 21:30:28 2018 +0300 power: Spring cleanup * Cleanup SoC specific files: - Fix code spacing and indentation - Remove dead code - Remove useless comments - Remove useless logs - Make code uniform between the files so it's easier to diff - Use declared enums when possible for power hints Change-Id: Ie1378c94c53b33299927c5eb1bfc19f1a42b8743 Author: Corinna Vinschen Date: Mon Aug 6 21:14:12 2018 +0200 power-8084: clean up code * express interactive boost frequencies as descriptive symbolic values rather than arbitrary hex numbers * express durations as descriptive symbolic values rather than just numbers in the code Change-Id: I47a92bd4c9b0b86ae0444d87345daf4e94d56126 Signed-off-by: Corinna Vinschen Author: Corinna Vinschen Date: Mon Aug 6 10:58:20 2018 +0200 power-8084: reduce interactive boost * 1,1 GHz min freq is more than enough for interactive boost on apq8084 * default duration is unnecessarily long, reduce to 200 ms * 1,5 GHz min freq on 2 CPUs for 1 sec is entirely sufficient for launch action Change-Id: I5e51267ed32a3e50899627e4281321820fac237f Signed-off-by: Corinna Vinschen Author: Corinna Vinschen Date: Mon Aug 6 16:52:08 2018 +0200 power-8084: drop POWER_HINT_LAUNCH handling * kernel governor is doing well by itself, but thanks all the same Change-Id: I64fa61a1d8ff0f20bac9e5c32c56b031570a564f Signed-off-by: Corinna Vinschen Author: Corinna Vinschen Date: Fri Oct 12 21:40:24 2018 +0200 power-8084: Revert POWER_HINT_LAUNCH handling This effectively reverts commit 0ef4cb429ff3d42e8f8bd27d749ecd80f2911dc5. Users (including myself) noticed some laggy behaviour. The patch reverts to some more oomph at launch time, trying for a compromise between performance and power saving. Change-Id: I2d07686a131dcb75c9e590d99764d2a650cae507 Author: Craig Tatlor Date: Mon May 21 17:22:31 2018 +0100 power: Build with with BOARD_VNDK_VERSION time.h isnt included by default when vndk is enabled. Change-Id: I949ed271d7e7ed31e186019b0289299c1c8ff940 Author: tomascus Date: Tue Feb 19 17:15:58 2019 +1100 power: Release launch boost perflock when launch is completed Currently, the launch boost perflock is held for a fixed duration, either specified in perfboostsconfig.xml for perf HAL platforms or hardcoded in the powerHAL for non-perf HAL platforms. Using a fixed duration for this perflock has two shortcomings: * perflock can be held for too long, causing the CPU freq and other resources to be boosted for too long even if the application has finished launching, resulting in excessive battery drainage * perflock can be held not long enough if it takes more than the timeout time to finish launch The framework sends out a powerhint for both when launch starts and when launch ends. The launch finish hint can be used to signal when to release the perflock. Reference: Wahoo power-libperfmgr Change-Id: I405cc453c5f58d9fb2583b9c6017f3964a0ce024 Change-Id: I8a1d8101bc40d3fc169a0f1f2982a5cac76e6a13 --- power-8226.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'power-8226.c') diff --git a/power-8226.c b/power-8226.c index b654923..7f5ff72 100644 --- a/power-8226.c +++ b/power-8226.c @@ -35,6 +35,7 @@ #include #include #include +#include #define LOG_TAG "QTI PowerHAL" #include @@ -123,6 +124,46 @@ static int process_video_decode_hint(void* metadata) { return HINT_NONE; } +// clang-format off +static int resources_interaction_boost[] = { + CPUS_ONLINE_MIN_2, + 0x20B, + 0x30B +}; +// clang-format on + +const int kDefaultInteractiveDuration = 500; /* ms */ +const int kMaxInteractiveDuration = 5000; /* ms */ + +static void process_interaction_hint(void* data) { + static struct timespec s_previous_boost_timespec; + static int s_previous_duration = 0; + + struct timespec cur_boost_timespec; + long long elapsed_time; + int duration = kDefaultInteractiveDuration; + + if (data) { + int input_duration = *((int*)data); + if (input_duration > duration) { + duration = (input_duration > kMaxInteractiveDuration) ? kMaxInteractiveDuration + : input_duration; + } + } + + clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec); + + elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec); + // don't hint if previous hint's duration covers this hint's duration + if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) { + return; + } + s_previous_boost_timespec = cur_boost_timespec; + s_previous_duration = duration; + + interaction(duration, ARRAY_SIZE(resources_interaction_boost), resources_interaction_boost); +} + int power_hint_override(power_hint_t hint, void* data) { int ret_val = HINT_NONE; switch (hint) { @@ -133,10 +174,7 @@ int power_hint_override(power_hint_t hint, void* data) { ret_val = process_video_decode_hint(data); break; case POWER_HINT_INTERACTION: - int resources[] = {CPUS_ONLINE_MIN_2, 0x20B, 0x30B}; - int duration = 3000; - - interaction(duration, ARRAY_SIZE(resources), resources); + process_interaction_hint(data); ret_val = HINT_HANDLED; break; default: -- cgit v1.2.3