RM6785: power-libperfmgr: Import power HAL AIDL implementation

Author: Bruno Martins <bgcngm@gmail.com>
Date:   Sat Apr 17 17:01:20 2021 +0100

    power-libperfmgr: Import power HAL AIDL implementation

    Change-Id: I7cd1ea241920bc76756df12a2e46e5a33f48b797

Author: Wei Wang <wvw@google.com>
Date:   Fri Mar 13 11:34:11 2020 -0700

    power-libperfmgr: Hook with display handler

    Bug: 147840817
    Test: boot and check power hint

Author: Wei Wang <wvw@google.com>
Date:   Fri Mar 20 12:21:12 2020 -0700

    power-libperfmgr: add aidl extension server

    Bug: 151896829
    Test: boot flame

Author: Wei Wang <wvw@google.com>
Date:   Fri Mar 20 22:11:48 2020 -0700

    power-libperfmgr: allow powerhint calls as soon as service starts

    Bug: 147840817
    Test: boot

Author: Wei Wang <wvw@google.com>
Date:   Mon Mar 30 18:28:45 2020 -0700

    power-libperfmgr: rename namespace for Pixel power HAL

    Bug: 152811907
    Test: Build

Author: Kyle Lin <kylelin@google.com>
Date:   Mon Aug 10 18:12:41 2020 +0800

    libperfmgr.rc: let perfmgr can change dex2oat priorities

    Because perfmgr is a vendor process, it cannot adjust system priority
    directly.

    Bug: 162791243

    Test: build and using emul temp/running burn8 to verify it

Author: Kyle Lin <kylelin@google.com>
Date:   Wed Aug 12 16:00:15 2020 +0800

    libperfmgr.rc: let power hal start early

    Bug: 162791243
    Bug: 72471476
    Test: build and using emul temp/running burn8 to verify it

Author: Jesse Chan <jc@lineageos.org>
Date:   Mon Jun 29 12:26:29 2020 +0800

    power-libperfmgr: remove Google-specific VR and camera hints

Author: Wei Wang <wvw@google.com>
Date:   Wed Oct 21 12:15:30 2020 -0700

    Power: add support for devices without display idle signals

    To workaround b/141025174, adding support for devices without display
    idle signals. Also added a property to override idle display function.

    Besides the idle signal support, this CL also makes touch boost duration
    tunable through several new vendor properties. It also named display
    idle monitor thread and cleans out the obsolete HIDL Power HAL
    implementation.

    Bug: 168080943
    Bug: 169065024
    Bug: 171494137
    Test: Boot and trace

Author: Wei Wang <wvw@google.com>
Date:   Thu Oct 22 16:21:39 2020 -0700

    Power: advertise power headers are deprecated

    Test: Build
    Bug: 169065024
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Wei Wang <wvw@google.com>
Date:   Fri Nov 13 10:59:00 2020 -0800

    power: add a property for config file

    Test: build
    Bug: 173222103
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Jeongik Cha <jeongik@google.com>
Date:   Thu Jan 28 00:49:48 2021 +0900

    Specify version for aidl_interface explicitly

    Bug: 150578172
    Test: m

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Mon Jan 25 01:20:38 2021 +0800

    power: add PowerHintSession for ADPF implementation

    Adapted from PoC from ag/13100800

    Added more ATRACE for further tuning and debug

    Test: APPPID=$(adb shell pidof com.prefabulated.touchlatency); watch -n
          1 adb shell grep uclamp /proc/${APPPID}/sched
    Test: atest VtsHalPowerTargetTest
    Bug: 177492680

    Signed-off-by: Wei Wang <wvw@google.com>

Author: Wei Wang <wvw@google.com>
Date:   Wed Apr 14 10:21:50 2021 -0700

    power: reduce log spam and refine trace title

    Add bunch of TODO for team as well.

    Test: build
    Bug: 177492680
    Bug: 185368789
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Wed May 5 11:17:41 2021 +0800

    ADPF: use PID algorithm to control cpu resource

    The patch includes:
    1. Move from folder adpf to aidl.
    2. Add PowerSessionManager class to maintain hint status.
       And PowerHintMointor looper thread for monitoring or updating
       PowerHintSession status.
    3. Use PID algorithm to replace the step-wise alogrithm for cpu resource
       control.

    Test: build, boot to home, trace analysis
    Bug: 177493042

Author: Wei Wang <wvw@google.com>
Date:   Mon Jun 14 22:03:10 2021 -0700

    Fix objects that are derived from refbase

    Fixes: ag/14313466
    Bug: 177493042
    Bug: 191163855
    Test: Build

    Signed-off-by: Wei Wang <wvw@google.com>

Author: Wei Wang <wvw@google.com>
Date:   Wed Jun 16 21:20:44 2021 -0700

    power-libperfmgr: improve adpf logic

    Cache active state and reduce log spam
    Add value tracing into libperfmgr
    Use adaptive stale timeout based on rate limit

    Bug: 191331719
    Bug: 191296994
    Bug: 177493042
    Test: boot
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Wei Wang <wvw@google.com>
Date:   Thu Jun 17 21:32:18 2021 -0700

    Adpf: honor window setting for P,D caculation

    Also change default window setting to 0

    Bug: 191409203
    Test: Build
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Mon Jun 21 00:22:47 2021 +0800

    adpf: clean up ADPF trace points

    clean up ADPF trace points and use vendor.powerhal.adpf.uclamp.boost_cap
    instead of vendor.powerhal.adpf.uclamp.cap_ratio.

    Bug: 191551452
    Test: build

Author: Wei Wang <wvw@google.com>
Date:   Wed Jun 23 15:58:56 2021 -0700

    Add PID tunables for sample window

    Bug: 191480755
    Test: Build
    Signed-off-by: Wei Wang <wvw@google.com>

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Sun Jun 27 01:39:31 2021 +0800

    Adpf: set uclamp when session is created

    When seesion is created, set uclamp to boost CPU for top-app.

    Bug: 192143316
    Test: Build and run UiBenchSlowNestedRecyclerViewInitialFlingMicrobenchmark test

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Wed Jul 7 12:00:43 2021 +0800

    ADPF: fix abnormal high uclamp

    "GPU completion" task inherits a high uclamp value from RenderThread.
    But it's not in the ADPF thread list, so it remains a high uclamp value.
    Use SetTaskProfiles("ResetUclampGrp") and
    SetTaskProfiles("NoResetUclampGrp") to manage the uclamp_fork_reset for
    tasks.

    Bug: 191973176
    Bug: 192149875
    Test: vendor/google_testing/pts/tests/common/utils/perf/run_pts/jank_test.sh
    Test: adb shell cat /proc/vendor_sched/dump_task

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Thu Jul 29 23:58:22 2021 +0800

    ADPF: avoid to call close() twice

    To get rid of error logs, avoid to call close() twice.

    07-29 17:20:35.341 E powerhal-libperfmgr: Unexpected Error! Failed to
    look up tid:2585 in TidRefCountMap
    07-29 17:20:35.341 E powerhal-libperfmgr: Unexpected Error! Failed to
    look up tid:2586 in TidRefCountMap
    07-29 17:20:35.341 E powerhal-libperfmgr: Unexpected Error! Failed to
    look up tid:2031 in TidRefCountMap
    07-29 17:20:35.341 E powerhal-libperfmgr: Unexpected Error! Failed to
    look up tid:2585 in TidRefCountMap

    Bug: 194775170
    Test: build and check log.

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Tue Jul 27 10:45:07 2021 +0800

    ADPF: fix no boost due to the big negative ILowLimit

    Tuning the PID control loop as the below:
    ILowLimit: -512 -> -120
    kPOver: 2->5
    kPunder: 2->3
    kDOver: 1->5
    kDUnder: 0->0

    Bug: 193165816
    Test: cuj/youtuble, cuj/facebook, PtsUiBench

Author: Jiyong Park <jiyong@google.com>
Date:   Mon Aug 9 09:01:16 2021 +0900

    power-libperfmgr: Remove ndk_platform backend. Use the ndk backend.

    The ndk_platform backend will soon be deprecated because the ndk backend
    can serve the same purpose. This is to eliminate the confusion about
    having two variants (ndk and ndk_platform) for the same ndk backend.

    Bug: 161456198
    Test: m

Change-Id: I8323fadd841777537f3f28d5605bc3420ed89080

Author: Wei Wang <wvw@google.com>
Date:   Fri Sep 17 15:30:09 2021 -0700

    power: move trace point to libperfmgr.

    Test: systrace
    Bug: 199776250
    Change-Id: I9bb4d5a50faa93e7bc638ef723bdc2662fb63b24

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Wed Sep 8 16:37:34 2021 +0800

    power: ADPF: limit uclamp high/low values and use I as boost base

    1. set uclamp.min high to 384 (from 512)
    2. set uclamp.min low to 2 (from 0)
    3. set kPo to 2 (from 5)
    4. set kPu to 1 (from 3)
    5. instead of the previous boost value, use I Error-Integral as the base
       of boost value.
    6. add more traces (wakeup, overtime)

    Bug: 198708191
    Bug: 197586898
    Bug: 197540375
    Test: build and check trace
          adb shell perfetto -o \
          /data/misc/perfetto-traces/trace_file.perfetto-trace -t 20s sched \
          freq idle am wm gfx view power hal
    Change-Id: I35484322a84c2ab19f3024cf6634c1818ba570b0

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Mon Oct 18 10:02:28 2021 +0800

    power: ADPF: fix stale trace status

    Bug: 196192645
    Test: Manual
    Change-Id: Ibdbb8f47a16032ce3249aa667fa0c11e7869748f

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Fri Feb 11 01:35:47 2022 +0800

    power: Add a debug property for switching powerhint.json path

    Add a bool property `vendor.powerhal.config.debug`.
    Power HAL would use `/data/vendor/etc/powerhint.json` when vendor.powerhal.config.debug = true.

    Bug: 218872105
    Bug: 206061061
    Test: adb wait-for-device root; adb shell mkdir -p /data/vendor/etc/;
          adb push powerhint_mod.json /data/vendor/etc/powerhint.json
    Test: adb shell setprop vendor.powerhal.config.debug true && \
          adb shell getprop vendor.powerhal.config.debug && \
          adb shell stop vendor.power-hal-aidl && \
          adb shell start vendor.power-hal-aidl && adb shell stop && adb shell start
    Test: adb pull /data/local.prop ; vim local.prop
          + vendor.powerhal.config.debug=true
    Test: adb wait-for-device root && adb shell perfetto -o \
          /data/misc/perfetto-traces/trace_file.perfetto-trace -t 20s sched freq \
          idle am wm gfx view power hal && \
          adb pull /data/misc/perfetto-traces/trace_file.perfetto-trace trace_profile_debug.pftrace
    Change-Id: Ibaf5df280b989a8268efce1e3ab9a3f1e5510800

Author: Wei Wang <wvw@google.com>
Date:   Tue Feb 15 21:49:11 2022 -0800

    power: Add global debug property for override config path properly

    An init trigger would restart powerhal as early as the property was
    loaded and it is hopefully early than any clients would try to connect.

    Also remove the obsolete restart hook with audio.

    Bug: 218872105
    Test: boot
    Signed-off-by: Wei Wang <wvw@google.com>
    Change-Id: Ib55897f65709a963016b729f213718aae5af8e8c

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Wed Mar 30 14:43:21 2022 +0800

    power: Fix race condition between Looper and destructor

    1. Clean all messages before add new.
    2. Insteading of using `this`, use the unique mStaleHandler sp so Looper
       can hold the sp to keep the instance alive until the last message
       done.

    Test: Manual Test
    Bug: 219965773
    Change-Id: Ic039146f0b966c1f27d86b121d4b72b75ff360e5

Author: Wei Wang <wvw@google.com>
Date:   Wed Apr 6 10:26:33 2022 -0700

    power: PowerHintSession: do not update PID controller when target changes

    There is no history kept in powerhint session, so let us just keep what
    we have in the PID controller and let new samples settle.

    Bug: 227003278
    Test: Build
    Change-Id: Ia8b9a0be288389ec36ac35c668aca013d470c257

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Sat Feb 12 01:05:23 2022 +0800

    power: Make HintManager a singleton class

    HintManager is unique and widely used in many different components.
    This is for making it easiler to be reloaded for debugging.

    Bug: 172285365
    Test: adb push \
          out/target/product/raven/data/nativetest64/libperfmgr_test/libperfmgr_test \
          /data/nativetest64/libperfmgr_test/libperfmgr_test && \
          adb shell /data/nativetest64/libperfmgr_test/libperfmgr_test
    Change-Id: I3affdfe780073ebbc50fac7bfbdd1530ee9dc8c2

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Tue Nov 9 22:44:46 2021 +0800

    power: ADPF: make uclamp.min stable

    Considering the previous uclamp.min value is the base of PID output.
    Instead of:
      `next_min = std::min(sUclampMinHighLimit, output);`
    We should use:
      `next_min = std::min(sUclampMinHighLimit, current_min + output);`

    When session status entered stale state, set the uclamp to 0, but keep
    the current_min. That would be helpful for boosting the heavy workload
    of the first few frames.

    Bug: 204444691
    Test: build && manual test

    Change-Id: Idb19e2bfd8e9522fae5fd452b1fcc58786e96e65

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Tue Oct 26 17:48:06 2021 +0800

    power: ADPF: Use Adpf Profile for PID tunnables

    1. Use Adpf Profile to replace system-property-based PID tunnables.
    2. Add a tunable for switch PID on/off
    3. Switch Adpf Profile by hint name (ex: REFRESH_120FPS)

    Bug: 202158746
    Bug: 204444691
    Bug: 206061061
    Test: Build
    Change-Id: Ia673a6bf64d40128ca1797d1e26fe564b3b35ff1

Author: Jimmy Shiu <jimmyshiu@google.com>
Date:   Mon Jan 17 21:02:41 2022 +0800

    power: ADPF: add Early Hint feature

    Add Early Hint feature and integrate with Stale Timer

    Bug: 198379880
    Test: build and manual test

    Change-Id: I17009ee5b9ff922a79ccf5cb68be5b959038267d

Author: Wei Wang <wvw@google.com>
Date:   Wed Apr 20 15:22:12 2022 -0700

    power: Add minimal binder thread prio as -20 to match process prio

    Bug: 227811781
    Test: Build
    Change-Id: I94670429ede032703661ee8eb8b1ea6456f5cbd5
    Signed-off-by: Wei Wang <wvw@google.com>

Author: jimmyshiu <jimmyshiu@google.com>
Date:   Mon Apr 25 08:46:49 2022 +0000

    power: ADPF: log clean up

    Remove ALOGD logs.

    Bug: 230205812
    Test: adb shell logcat -b all | grep libperf
    Change-Id: I4125afec526b76e3905e75c22fc2bfb555810fa8

Author: Matt Buckley <mattbuckley@google.com>
Date:   Fri Apr 29 21:05:38 2022 +0000

    power: Ignore system hint sessions for universal boost

    Currently PowerHAL does not distinguish between system processes and
    apps when deciding whether to apply universal boost. This patch
    distinguishes system sessions and app sessions and ignores system ones,
    making the disabling of universal boost dependent on the presence of app
    hint sessions.

    Bug: b/230511824
    Test: manual
    Change-Id: I08dea29b3a45f2ba69ed99a9f188fa83ba143423

Author: Wei Wang <wvw@google.com>
Date:   Thu May 12 09:54:25 2022 -0700

    power: PowerHAL: remove UclampMinGranularity

    This is causing session update skipped and stuck.

    Bug: 232336917
    Test: /data/nativetest64/libperfmgr_test/libperfmgr_test
    Signed-off-by: Wei Wang <wvw@google.com>
    Change-Id: I8928b6f6a60dcf8d21e60228a74d3aa0ab792eff

Author: jimmyshiu <jimmyshiu@google.com>
Date:   Thu May 19 06:43:55 2022 +0000

    power: ADPF: uclamp.min integration

    Integrate the uclamp.min across sessions.
    Add UClampMininit as the display update boost

    Bug: 232313238
    Test: Manual test
    Change-Id: I601f407b0b5383a1e39eac448d45cbaaeb7788fb

Author: jimmyshiu <jimmyshiu@google.com>
Date:   Thu Apr 21 17:39:51 2022 +0000

    power: ADPF: dump ADPF session info

    Dump current ADPF profile and ADPF session list into bugreport.

    Bug: 204444691
    Test: adb root && adb shell dumpsys android.hardware.power.IPower/default
    Test: gpaste/6469309887938560
    Change-Id: I17c0d615051f5e51c2e1fe99d17c402f9a65679a

Author: Will McVicker <willmcvicker@google.com>
Date:   Fri Jun 3 14:54:29 2022 -0700

    power: Fix race between closing a session and receiving a boost

    We need to be holding the session lock when we dereference mDescriptor
    since mDescriptor is destroyed when the session is closed. This patch
    takes the session lock and verifies if it's still open during wakeup.

    Test: vts run -m VtsHalGraphicsComposerV2_4TargetTest
    Bug: 232992641
    Change-Id: I4000a85bf2932cfdcddd3006d671a3c91ed32c48

Author: jimmyshiu <jimmyshiu@google.com>
Date:   Thu Jun 2 09:30:18 2022 +0000

    power: Fix uclamp_min stuck at high freq

    Separate Stale and EarlyBoost handlers and refine the code.

    Test: adb shell dumpsys android.hardware.power.IPower/default
    Test: Manual
    Bug: 232992641

    Change-Id: I81a4fd96fb7311ae5bbb7cbabe72378c9cad4aa3

Author: jimmyshiu <jimmyshiu@google.com>
Date:   Fri Jun 10 10:14:56 2022 +0000

    power: ADPF: Fix updateHintBoost blocks the binder thread

    post the task into a looper thread.

    Bug: 232992641
    Test: Manually playing UIBench -> Transitions -> ActivityTransition
    Change-Id: Ibd241834f904b4c87a51363e766e110d2818d496

Change-Id: Ifd21d00c68ac3a07128970811f624efb3483d4c8

Author: Wei Wang <wvw@google.com>
Date:   Sat Aug 6 00:31:07 2022 -0700

    ADPF: extend non-stale session timer in wakeup

    For DISPLAY_UPDATE_IMMINENT wakeup signal, non-stale
    session's timer should be also extended. This resolves
    the performance issue caused those sessions to go stale    
    prematurely.

    Bug: 241621485
    Test: Build
    Signed-off-by: Wei Wang <wvw@google.com>
    Change-Id: I06330e064060248bb556ae35e0cb8fd302cef231
    (cherry picked from commit 986c81e89ba5bb0537429a631a4c93caf3dc846e)
    Merged-In: I06330e064060248bb556ae35e0cb8fd302cef231

Change-Id: I71b1efeb1f28a361ed015bfe9582632d94bd89e7
16 files changed