sdm710-common: 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
Signed-off-by: SamarV-121 <samarvispute121@gmail.com>
This commit is contained in:
tomascus 2019-02-19 17:15:58 +11:00 committed by SamarV-121
parent fa987c9474
commit 18960a4972

View file

@ -53,6 +53,7 @@
#define CHECK_HANDLE(x) ((x) > 0) #define CHECK_HANDLE(x) ((x) > 0)
#define NUM_PERF_MODES 3 #define NUM_PERF_MODES 3
const int kMaxLaunchDuration = 5000; /* ms */
const int kMaxInteractiveDuration = 5000; /* ms */ const int kMaxInteractiveDuration = 5000; /* ms */
const int kMinInteractiveDuration = 100; /* ms */ const int kMinInteractiveDuration = 100; /* ms */
const int kMinFlingDuration = 1500; /* ms */ const int kMinFlingDuration = 1500; /* ms */
@ -194,10 +195,29 @@ static int process_video_encode_hint(void* metadata) {
} }
static int process_activity_launch_hint(void* data) { static int process_activity_launch_hint(void* data) {
static int launch_handle = -1;
static int launch_mode = 0;
// release lock early if launch has finished
if (!data) {
if (CHECK_HANDLE(launch_handle)) {
release_request(launch_handle);
launch_handle = -1;
}
launch_mode = 0;
return HINT_HANDLED;
}
if (current_mode != NORMAL_MODE) { if (current_mode != NORMAL_MODE) {
ALOGV("%s: ignoring due to other active perf hints", __func__); ALOGV("%s: ignoring due to other active perf hints", __func__);
} else { } else if (!launch_mode) {
perf_hint_enable_with_type(VENDOR_HINT_FIRST_LAUNCH_BOOST, -1, LAUNCH_BOOST_V1); launch_handle = perf_hint_enable_with_type(VENDOR_HINT_FIRST_LAUNCH_BOOST,
kMaxLaunchDuration, LAUNCH_BOOST_V1);
if (!CHECK_HANDLE(launch_handle)) {
ALOGE("Failed to perform launch boost");
return HINT_NONE;
}
launch_mode = 1;
} }
return HINT_HANDLED; return HINT_HANDLED;
} }