From d059d7bbe173d2de0051be1b4f844e3a5a9ca7ae Mon Sep 17 00:00:00 2001 From: Matt Buckley Date: Tue, 22 Nov 2022 22:20:25 +0000 Subject: [PATCH] sdm660-common: power-libperfmgr: 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 --- power-libperfmgr/aidl/PowerHintSession.cpp | 24 ------------------- power-libperfmgr/aidl/PowerHintSession.h | 1 - power-libperfmgr/aidl/PowerSessionManager.cpp | 14 ----------- power-libperfmgr/aidl/PowerSessionManager.h | 13 +--------- 4 files changed, 1 insertion(+), 51 deletions(-) diff --git a/power-libperfmgr/aidl/PowerHintSession.cpp b/power-libperfmgr/aidl/PowerHintSession.cpp index 1c78f91f..564cbb22 100644 --- a/power-libperfmgr/aidl/PowerHintSession.cpp +++ b/power-libperfmgr/aidl/PowerHintSession.cpp @@ -399,30 +399,6 @@ void PowerHintSession::setStale() { } } -void PowerHintSession::wakeup() { - std::lock_guard guard(mSessionLock); - - // We only wake up non-paused and stale sessions - if (mSessionClosed || !isActive() || !isTimeout()) - return; - if (ATRACE_ENABLED()) { - std::string tag = StringPrintf("wakeup.%s(a:%d,s:%d)", getIdString().c_str(), isActive(), - isTimeout()); - ATRACE_NAME(tag.c_str()); - } - std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); - int min = std::max(mDescriptor->current_min, static_cast(adpfConfig->mUclampMinInit)); - mDescriptor->current_min = min; - PowerSessionManager::getInstance()->setUclampMinLocked(this, min); - mStaleTimerHandler->updateTimer(); - - if (ATRACE_ENABLED()) { - const std::string idstr = getIdString(); - std::string sz = StringPrintf("adpf.%s-min", idstr.c_str()); - ATRACE_INT(sz.c_str(), min); - } -} - time_point PowerHintSession::getStaleTime() { return mLastUpdatedTime.load() + nanoseconds(static_cast( diff --git a/power-libperfmgr/aidl/PowerHintSession.h b/power-libperfmgr/aidl/PowerHintSession.h index edd80f1c..2002020b 100644 --- a/power-libperfmgr/aidl/PowerHintSession.h +++ b/power-libperfmgr/aidl/PowerHintSession.h @@ -81,7 +81,6 @@ class PowerHintSession : public BnPowerHintSession { const std::vector &actualDurations) override; bool isActive(); bool isTimeout(); - void wakeup(); void setStale(); // Is this hint session for a user application bool isAppSession(); diff --git a/power-libperfmgr/aidl/PowerSessionManager.cpp b/power-libperfmgr/aidl/PowerSessionManager.cpp index 516942ac..903c4b57 100644 --- a/power-libperfmgr/aidl/PowerSessionManager.cpp +++ b/power-libperfmgr/aidl/PowerSessionManager.cpp @@ -96,16 +96,6 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura 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 guard(mLock); - for (PowerHintSession *s : mSessions) { - s->wakeup(); - } } int PowerSessionManager::getDisplayRefreshRate() { @@ -201,10 +191,6 @@ void PowerSessionManager::handleMessage(const Message &) { } } -void PowerSessionManager::WakeupHandler::handleMessage(const Message &) { - PowerSessionManager::getInstance()->wakeSessions(); -} - void PowerSessionManager::dumpToFd(int fd) { std::ostringstream dump_buf; std::lock_guard guard(mLock); diff --git a/power-libperfmgr/aidl/PowerSessionManager.h b/power-libperfmgr/aidl/PowerSessionManager.h index 6cd0886c..e65e58e9 100644 --- a/power-libperfmgr/aidl/PowerSessionManager.h +++ b/power-libperfmgr/aidl/PowerSessionManager.h @@ -62,14 +62,6 @@ class PowerSessionManager : public MessageHandler { } private: - class WakeupHandler : public MessageHandler { - public: - WakeupHandler() {} - void handleMessage(const Message &message) override; - }; - - private: - void wakeSessions(); std::optional isAnyAppSessionActive(); void disableSystemTopAppBoost(); void enableSystemTopAppBoost(); @@ -78,7 +70,6 @@ class PowerSessionManager : public MessageHandler { std::unordered_set mSessions; // protected by mLock std::unordered_map mTidRefCountMap; // protected by mLock std::unordered_map> mTidSessionListMap; - sp mWakeupHandler; bool mActive; // protected by mLock /** * mLock to pretect the above data objects opertions. @@ -90,9 +81,7 @@ class PowerSessionManager : public MessageHandler { : kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost, "ADPF_DISABLE_TA_BOOST")), mActive(false), - mDisplayRefreshRate(60) { - mWakeupHandler = sp(new WakeupHandler()); - } + mDisplayRefreshRate(60) {} PowerSessionManager(PowerSessionManager const &) = delete; void operator=(PowerSessionManager const &) = delete; };