Commit graph

559 commits

Author SHA1 Message Date
Chenyang Zhong
6b6029c515
sm6375-common: libqti-perfd-client: return a dummy value
Return a positive integer for perf lock acquire and release so
that Goodix/FPC fingerprint sensor blobs will not complain.

Goodix:
E [goodixHAL][gf_hal_milan_f_series]: goodix_perf_lock_acquire: Failed to acquire perf lock, err: 0
E [goodixHAL][gf_hal_milan_f_series]: goodix_perf_lock_release: Perf lock release error 0

FPC:
E fpc_tac : fpc_perf_lock_acquire: Incorrect params, Failed to acquire perf lock, err
E fpc_tac : fpc_perf_lock_release: Perf lock release error 0

Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
Change-Id: I861672e9a738c2204755d802670f4b28b662f286
2024-07-18 20:16:00 +05:30
Bruno Martins
ddaba172c6
sm6375-common: libqti-perfd-client: Remove namespace declaration
It's pointless when using extern "C".

Change-Id: Ibdf9f06a70aa3a75687b33781c78cf2172bb334d
2024-07-18 20:16:00 +05:30
Lucchetto
1e25d6fd85
sm6375-common: Create dummy libqti-perfd-client
* proprietary perfd blobs can finally be nuked without breaking goodix
* we could even map the functions to use libperfmgr powerhints in the future

Change-Id: I124652f3041761966a3e3bd97c757fecc39cc5fb
2024-07-18 20:16:00 +05:30
Sugakesshaa
ca771e2087
sm6375-common: sepolicy: Allow libperfmgr to write to proc_sched nodes
Change-Id: Ic8d9f03befb2ea5722d340d9f2b797b1cf8f0f50
2024-07-18 20:16:00 +05:30
Arian
4bbb9ac9bc
sm6375-common: sepolicy: Address pixel power HAL denials
Change-Id: I7327bd54c0d12fde03472695a5598d2a3d22f716
2024-07-18 20:16:00 +05:30
Subhajeet Muhuri
642f408f24
sm6375-common: Include hardware/google/interfaces and hardware/google/pixel
* Required by power-libperfmgr

Change-Id: I4053938614be26c7066ea83d97955739f39b4144
2024-07-18 20:16:00 +05:30
Bruno Martins
e3669945b5
sm6375-common: power-libperfmgr: enable powerhint parsing after boot completion
Change-Id: Ie065f234bfd949264b962bae80e400a446f65b80
2024-07-18 20:16:00 +05:30
Jimmy Shiu
3478253879
sm6375-common: power-libperfmgr: ADPF: fix use-after-free crash
The main problem is the timer thread could be woken after the session
was destroyed. We did have a closed flag which was set in destructor and the flag would be checked before handleMessage accessing the session
instance. To fix the problem, the operations of flag checking and session instance accessing should be guarded by the lock.

Bug: 236674672
Test: manual test
Change-Id: I49a18efbc135b1bc070b101038a8a0bcc6e19fec
(cherry picked from commit 5c75978f530b27bd976d8695ed79acd336c24776)
Merged-In: I49a18efbc135b1bc070b101038a8a0bcc6e19fec
2024-07-18 20:16:00 +05:30
jimmyshiu
523949c628
sm6375-common: power-libperfmgr: ADPF: optimize the wakeup performance and fix unstable boost.
Optimize boost:
A more efficient way is to trigger the wakeup boost through mTidSessionListMap, so the time
   complexity reduce from O(n^3) to O(n^2).

The original code path:
  PSM:wakeSessions() contains a loop that is O(n),
  inside the loop, it calls to PHS::wakeup() which call to
  PSM::setUclampMinLocked(), and
  PSM::setUclampMinLocked() contains two loops O(n^2)

The new code path:
  PSM::wakeSessions() directly checks all the ADPF tasks O(n) and
  get the wakeup boost value O(n), then directly set the uclamp.min
  The time complexity lower to O(n^2).

Fix unstable boost:
The original flow is to find max boost and wake it up from stale state
one by one. But the previous woken ones would not be counted when the later ones finding their max boost value.
The new flow boost all the tasks first, then wake up all those sessions.

Bug: 235510337
Test: Manually playing UIBench -> Transitions -> ActivityTransition
Change-Id: I995673b74401e198eb72188134ba1ebc134f971c
2024-07-18 20:16:00 +05:30
Wei Wang
de130faac2
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
jimmyshiu
fbcc05b19b
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
jimmyshiu
620a6da869
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Will McVicker
00036d86cc
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
jimmyshiu
0118a38571
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
jimmyshiu
f032fe2747
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Wei Wang
7fc85e9871
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Matt Buckley
be068a8061
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
jimmyshiu
c3f82f2ecd
sm6375-common: power-libperfmgr: ADPF: log clean up
Remove ALOGD logs.

Bug: 230205812
Test: adb shell logcat -b all | grep libperf
Change-Id: I4125afec526b76e3905e75c22fc2bfb555810fa8
2024-07-18 20:16:00 +05:30
Wei Wang
454a949b18
sm6375-common: power-libperfmgr: 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>
2024-07-18 20:16:00 +05:30
Jimmy Shiu
938e2b96f7
sm6375-common: power-libperfmgr: ADPF: add Early Hint feature
Add Early Hint feature and integrate with Stale Timer

Bug: 198379880
Test: build and manual test

Change-Id: I17009ee5b9ff922a79ccf5cb68be5b959038267d
2024-07-18 20:16:00 +05:30
Jimmy Shiu
362ddc9bd3
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Jimmy Shiu
e395871686
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Jimmy Shiu
53f1fc4eee
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Wei Wang
40a340e68d
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Jimmy Shiu
e943cbd1a8
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Wei Wang
4bdcfc21e1
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Jimmy Shiu
412dc73d54
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Jimmy Shiu
31820c6a8a
sm6375-common: power-libperfmgr: ADPF: fix stale trace status
Bug: 196192645
Test: Manual
Change-Id: Ibdbb8f47a16032ce3249aa667fa0c11e7869748f
2024-07-18 20:16:00 +05:30
Jimmy Shiu
8bd36d98f7
sm6375-common: power-libperfmgr: 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
2024-07-18 20:16:00 +05:30
Wei Wang
98722b9831
sm6375-common: power-libperfmgr: move trace point to libperfmgr.
Test: systrace
Bug: 199776250
Change-Id: I9bb4d5a50faa93e7bc638ef723bdc2662fb63b24
2024-07-18 20:16:00 +05:30
Jiyong Park
5b9b880773
sm6375-common: power-libperfmgr: aidl: 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
Merged-In: I14a1c57bd06f1f2aa52491f779c7030d4de03547
Change-Id: I7b9055909b901843631314b9577a9e578a739d00
2024-07-18 20:16:00 +05:30
Jimmy Shiu
fe3d88452b
sm6375-common: power-libperfmgr: 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
Change-Id: Icc1a9a8d04004f60e47cabb7c4131ea67585be53
2024-07-18 20:16:00 +05:30
Jimmy Shiu
20db3354f7
sm6375-common: power-libperfmgr: 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.
Change-Id: I91adf907b837382f68935b9054e19465a499049c
2024-07-18 20:16:00 +05:30
Jimmy Shiu
0515fc6f25
sm6375-common: power-libperfmgr: 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
Change-Id: I6aed171e88c0a6db5f762e7c791344bb3f4b7a90
2024-07-18 20:16:00 +05:30
Jimmy Shiu
17a4a4abb8
sm6375-common: power-libperfmgr: 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
Change-Id: I748037019fae439ab1863a5ed21aa98b9d26e0dc
2024-07-18 20:16:00 +05:30
Wei Wang
c3ec3fccba
sm6375-common: power-libperfmgr: Add PID tunables for sample window
Bug: 191480755
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Id559796ee4a423410148b8c2df0524909658af82
2024-07-18 20:16:00 +05:30
Jimmy Shiu
c64f218687
sm6375-common: power-libperfmgr: 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
Change-Id: I457710b1bd9a7adbb55749d7bb915c736dde2751
2024-07-18 20:16:00 +05:30
Wei Wang
d955e9499b
sm6375-common: power-libperfmgr: 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>
Change-Id: Ieadf50a64e795d9942373c411189adf9daaee779
2024-07-18 20:16:00 +05:30
Wei Wang
e5e88cf477
sm6375-common: 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>
Change-Id: I1c1484c9277209bf68bd287ceae83e2b37684c62
2024-07-18 20:16:00 +05:30
Wei Wang
7bfee27a4b
sm6375-common: power-libperfmgr: Fix objects that are derived from refbase
Fixes: ag/14313466
Bug: 177493042
Bug: 191163855
Test: Build
Change-Id: I94812997a8214b77a2e1d0bcf90ef62205c5adf6
Signed-off-by: Wei Wang <wvw@google.com>
2024-07-18 20:16:00 +05:30
Jimmy Shiu
d01fb0826f
sm6375-common: power-libperfmgr: 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
Change-Id: Ib7d3f414225b18954350341ca22b7be87a6202e7
2024-07-18 20:16:00 +05:30
Wei Wang
de42f91c95
sm6375-common: power-libperfmgr: 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>
Change-Id: Ic1d5ecea10a60b23343866cd62519fda37bd6ec5
2024-07-18 20:16:00 +05:30
Jimmy Shiu
8ac355cf49
sm6375-common: power-libperfmgr: 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
Change-Id: I6bfd61b21dc1cde04f6ba9ae8d3533cd263ad814
Signed-off-by: Wei Wang <wvw@google.com>
2024-07-18 20:16:00 +05:30
Jeongik Cha
582d354820
sm6375-common: power-libperfmgr: Specify version for aidl_interface explicitly
Bug: 150578172
Test: m
Change-Id: I4a9bf218b92252403e9ebbe8f89b10ee1899283f
2024-07-18 20:16:00 +05:30
Wei Wang
79dc67e98c
sm6375-common: power-libperfmgr: add a property for config file
Test: build
Bug: 173222103
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I14e7e0aa349e446f6889cbfc9a914f5314438e6b
2024-07-18 20:16:00 +05:30
Wei Wang
6544285109
sm6375-common: power-libperfmgr: advertise power headers are deprecated
Test: Build
Bug: 169065024
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I3cef3aff4bb2394571a3de13e535283722c308ed
2024-07-18 20:16:00 +05:30
Wei Wang
c3dad50ec4
sm6375-common: power-libperfmgr: 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
Change-Id: I76067d10958654d539624ec4cac8f346103e67bc
2024-07-18 20:16:00 +05:30
Stefanie Kondik
3223436585
sm6375-common: power-libperfmgr: Add support for tap-to-wake feature control
Change-Id: Ib6e1e010834b1b16668d52db79b26804fe0e1671
2024-07-18 20:16:00 +05:30
Jesse Chan
250e9ff625
sm6375-common: power-libperfmgr: remove Google-specific VR and camera hints
Change-Id: Iac0e65a16f660583d3400a35622113d35d8d1d27
2024-07-18 20:16:00 +05:30
Kyle Lin
2ae9846959
sm6375-common: libperfmgr.rc: let power hal start early
Bug: 162791243
Bug: 72471476
Test: build and using emul temp/running burn8 to verify it
Change-Id: I5ca475be8b73b940e4858634595a7918ae92f6ef
2024-07-18 20:16:00 +05:30