diff --git a/aidl/power-libperfmgr/PowerHintSession.cpp b/aidl/power-libperfmgr/PowerHintSession.cpp index 0ac0b4a..2dbb464 100644 --- a/aidl/power-libperfmgr/PowerHintSession.cpp +++ b/aidl/power-libperfmgr/PowerHintSession.cpp @@ -426,14 +426,13 @@ void PowerHintSession::wakeup() { 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); + mDescriptor->current_min = + std::max(mDescriptor->current_min, static_cast(adpfConfig->mUclampMinInit)); if (ATRACE_ENABLED()) { const std::string idstr = getIdString(); std::string sz = StringPrintf("adpf.%s-min", idstr.c_str()); - ATRACE_INT(sz.c_str(), min); + ATRACE_INT(sz.c_str(), mDescriptor->current_min); } } diff --git a/aidl/power-libperfmgr/PowerSessionManager.cpp b/aidl/power-libperfmgr/PowerSessionManager.cpp index 516942a..947208b 100644 --- a/aidl/power-libperfmgr/PowerSessionManager.cpp +++ b/aidl/power-libperfmgr/PowerSessionManager.cpp @@ -33,6 +33,7 @@ namespace power { namespace impl { namespace pixel { +using ::android::perfmgr::AdpfConfig; using ::android::perfmgr::HintManager; namespace { @@ -103,7 +104,28 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura void PowerSessionManager::wakeSessions() { std::lock_guard guard(mLock); - for (PowerHintSession *s : mSessions) { + std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); + std::unordered_set wakeupList; + const int wakeupBoostValue = static_cast(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(); } }