RM6785: power: Remove wakeup behavior from PowerHintSession and PowerSessionManager
Currently, all sessions get boosted any time DISPLAY_UPDATE_IMMINENT is
sent from SurfaceFlinger which can lead to large, unnecessary boosts.
This patch aims to change that by removing the wakeup behavior, relying
instead on sessions to boost themselves with new load change hints.
* Remove wakeup() from PowerHintSession
* Remove wakeSessions from PowerSessionManager
* Remove related timers and message handlers
* Remove DISPLAY_UPDATE_IMMINENT behavior entirely
Test: manual
Bug: b/260136431
Change-Id: I4610edfefe8fcbef7d4cdbf5768830a9392a54f7
diff --git a/aidl/power-libperfmgr/PowerHintSession.cpp b/aidl/power-libperfmgr/PowerHintSession.cpp
index ea709fb..9fb070c 100644
--- a/aidl/power-libperfmgr/PowerHintSession.cpp
+++ b/aidl/power-libperfmgr/PowerHintSession.cpp
@@ -366,33 +366,6 @@
}
}
-void PowerHintSession::wakeup() {
- std::lock_guard<std::mutex> guard(mSessionLock);
-
- // We only wake up non-paused session
- if (mSessionClosed || !isActive()) {
- return;
- }
- // Update session's timer
- mStaleTimerHandler->updateTimer();
- // Skip uclamp update for stale session
- if (!isTimeout()) {
- return;
- }
- if (ATRACE_ENABLED()) {
- std::string tag =
- StringPrintf("wakeup.%s(a:%d,s:%d)", mIdString.c_str(), isActive(), isTimeout());
- ATRACE_NAME(tag.c_str());
- }
- std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
- mDescriptor->current_min =
- std::max(mDescriptor->current_min, static_cast<int>(adpfConfig->mUclampMinInit));
-
- if (ATRACE_ENABLED()) {
- traceSessionVal("min", mDescriptor->current_min);
- }
-}
-
void PowerHintSession::StaleTimerHandler::updateTimer() {
auto now = std::chrono::steady_clock::now();
nanoseconds staleDuration = std::chrono::nanoseconds(
diff --git a/aidl/power-libperfmgr/PowerHintSession.h b/aidl/power-libperfmgr/PowerHintSession.h
index a12426a..c14d626 100644
--- a/aidl/power-libperfmgr/PowerHintSession.h
+++ b/aidl/power-libperfmgr/PowerHintSession.h
@@ -69,7 +69,6 @@
const std::vector<WorkDuration> &actualDurations) override;
bool isActive();
bool isTimeout();
- void wakeup();
void setStale();
// Is this hint session for a user application
bool isAppSession();
diff --git a/aidl/power-libperfmgr/PowerSessionManager.cpp b/aidl/power-libperfmgr/PowerSessionManager.cpp
index ddd9f75..80bce68 100644
--- a/aidl/power-libperfmgr/PowerSessionManager.cpp
+++ b/aidl/power-libperfmgr/PowerSessionManager.cpp
@@ -87,37 +87,6 @@
ATRACE_CALL();
ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(),
durationMs);
- if (boost.compare("DISPLAY_UPDATE_IMMINENT") == 0) {
- PowerHintMonitor::getInstance()->getLooper()->sendMessage(mWakeupHandler, NULL);
- }
-}
-
-void PowerSessionManager::wakeSessions() {
- std::lock_guard<std::mutex> guard(mLock);
- std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
- std::unordered_set<PowerHintSession *> wakeupList;
- const int wakeupBoostValue = static_cast<int>(adpfConfig->mUclampMinInit);
- for (auto &it : mTidSessionListMap) {
- int tid = it.first;
- int maxboost = -1;
- // Find the max boost value among all the sessions that include the same TID.
- for (PowerHintSession *s : it.second) {
- if (!s->isActive())
- continue;
- // all active sessions need to be awakened.
- wakeupList.insert(s);
- if (s->isTimeout()) {
- maxboost = std::max(maxboost, s->getUclampMin());
- }
- }
- // Found the max boost and actally set to the task.
- if (maxboost != -1) {
- set_uclamp_min(tid, std::max(maxboost, wakeupBoostValue));
- }
- }
- for (PowerHintSession *s : wakeupList) {
- s->wakeup();
- }
}
int PowerSessionManager::getDisplayRefreshRate() {
@@ -213,10 +182,6 @@
}
}
-void PowerSessionManager::WakeupHandler::handleMessage(const Message &) {
- PowerSessionManager::getInstance()->wakeSessions();
-}
-
void PowerSessionManager::dumpToFd(int fd) {
std::ostringstream dump_buf;
std::lock_guard<std::mutex> guard(mLock);
diff --git a/aidl/power-libperfmgr/PowerSessionManager.h b/aidl/power-libperfmgr/PowerSessionManager.h
index 54ea0da..972407c 100644
--- a/aidl/power-libperfmgr/PowerSessionManager.h
+++ b/aidl/power-libperfmgr/PowerSessionManager.h
@@ -52,14 +52,6 @@
}
private:
- class WakeupHandler : public MessageHandler {
- public:
- WakeupHandler() {}
- void handleMessage(const Message &message) override;
- };
-
- private:
- void wakeSessions();
std::optional<bool> isAnyAppSessionActive();
void disableSystemTopAppBoost();
void enableSystemTopAppBoost();
@@ -68,7 +60,6 @@
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
- sp<WakeupHandler> mWakeupHandler;
bool mActive; // protected by mLock
/**
* mLock to pretect the above data objects opertions.
@@ -80,9 +71,7 @@
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
"ADPF_DISABLE_TA_BOOST")),
mActive(false),
- mDisplayRefreshRate(60) {
- mWakeupHandler = sp<WakeupHandler>(new WakeupHandler());
- }
+ mDisplayRefreshRate(60) {}
PowerSessionManager(PowerSessionManager const &) = delete;
void operator=(PowerSessionManager const &) = delete;
};