diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-23 14:29:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-23 14:29:31 +0000 |
commit | 4db34dba5ac7f0a54bd9c52854570f819752a0df (patch) | |
tree | 02526e76b4e5346b387c6dfbf739df28ea42ca2f | |
parent | 5cdb21df848b97d59c2d1fb831c596c2dadf7fce (diff) | |
parent | c0e699319b59412a2818647b646d1a5277d0254f (diff) | |
download | pixel-android13-mainline-adservices-release.tar.gz |
Snap for 8760376 from c0e699319b59412a2818647b646d1a5277d0254f to mainline-adservices-releaseaml_ads_331920180aml_ads_331814200aml_ads_331710270aml_ads_331611190aml_ads_331511020aml_ads_331418080aml_ads_331131000android13-mainline-adservices-release
Change-Id: Iffb880fceee947a1525695b6d5199cc34debfad4
-rw-r--r-- | pixelstats/BatteryEEPROMReporter.cpp | 8 | ||||
-rw-r--r-- | power-libperfmgr/aidl/Power.cpp | 10 | ||||
-rw-r--r-- | power-libperfmgr/aidl/PowerExt.cpp | 10 | ||||
-rw-r--r-- | power-libperfmgr/aidl/PowerHintSession.cpp | 18 | ||||
-rw-r--r-- | power-libperfmgr/aidl/PowerHintSession.h | 3 | ||||
-rw-r--r-- | power-libperfmgr/aidl/PowerSessionManager.cpp | 6 | ||||
-rw-r--r-- | power-libperfmgr/aidl/PowerSessionManager.h | 12 |
7 files changed, 51 insertions, 16 deletions
diff --git a/pixelstats/BatteryEEPROMReporter.cpp b/pixelstats/BatteryEEPROMReporter.cpp index 5183a1b0..d5ed720a 100644 --- a/pixelstats/BatteryEEPROMReporter.cpp +++ b/pixelstats/BatteryEEPROMReporter.cpp @@ -252,6 +252,14 @@ void BatteryEEPROMReporter::reportEvent(const std::shared_ptr<IStats> &stats_cli values[BatteryEEPROM::kMinIbattFieldNumber - kVendorAtomOffset] = val; val.set<VendorAtomValue::intValue>(hist.checksum); values[BatteryEEPROM::kChecksumFieldNumber - kVendorAtomOffset] = val; + val.set<VendorAtomValue::intValue>(hist.tempco); + values[BatteryEEPROM::kTempcoFieldNumber - kVendorAtomOffset] = val; + val.set<VendorAtomValue::intValue>(hist.rcomp0); + values[BatteryEEPROM::kRcomp0FieldNumber - kVendorAtomOffset] = val; + val.set<VendorAtomValue::intValue>(hist.timer_h); + values[BatteryEEPROM::kTimerHFieldNumber - kVendorAtomOffset] = val; + val.set<VendorAtomValue::intValue>(hist.full_rep); + values[BatteryEEPROM::kFullRepFieldNumber - kVendorAtomOffset] = val; VendorAtom event = {.reverseDomainName = "", .atomId = PixelAtoms::Atom::kBatteryEeprom, diff --git a/power-libperfmgr/aidl/Power.cpp b/power-libperfmgr/aidl/Power.cpp index 54469182..5bd18d33 100644 --- a/power-libperfmgr/aidl/Power.cpp +++ b/power-libperfmgr/aidl/Power.cpp @@ -88,7 +88,10 @@ Power::Power(std::shared_ptr<DisplayLowPower> dlpw, std::shared_ptr<AdaptiveCpu> ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled; - PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled); + if (HintManager::GetInstance()->GetAdpfProfile() && + HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) { + PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled); + } switch (type) { case Mode::LOW_POWER: mDisplayLowPower->SetDisplayLowPower(enabled); @@ -188,7 +191,10 @@ ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) { ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) { LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs; - PowerSessionManager::getInstance()->updateHintBoost(toString(type), durationMs); + if (HintManager::GetInstance()->GetAdpfProfile() && + HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) { + PowerSessionManager::getInstance()->updateHintBoost(toString(type), durationMs); + } switch (type) { case Boost::INTERACTION: if (mVRModeOn || mSustainedPerfModeOn) { diff --git a/power-libperfmgr/aidl/PowerExt.cpp b/power-libperfmgr/aidl/PowerExt.cpp index 751e5e82..1d91d9b2 100644 --- a/power-libperfmgr/aidl/PowerExt.cpp +++ b/power-libperfmgr/aidl/PowerExt.cpp @@ -47,7 +47,10 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) { } else { HintManager::GetInstance()->EndHint(mode); } - PowerSessionManager::getInstance()->updateHintMode(mode, enabled); + if (HintManager::GetInstance()->GetAdpfProfile() && + HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) { + PowerSessionManager::getInstance()->updateHintMode(mode, enabled); + } if (mode == AdaptiveCpu::HINT_NAME) { LOG(DEBUG) << "AdaptiveCpu intercepted hint"; @@ -66,7 +69,10 @@ ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aid ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) { LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs; - PowerSessionManager::getInstance()->updateHintBoost(boost, durationMs); + if (HintManager::GetInstance()->GetAdpfProfile() && + HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) { + PowerSessionManager::getInstance()->updateHintBoost(boost, durationMs); + } if (durationMs > 0) { HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs)); diff --git a/power-libperfmgr/aidl/PowerHintSession.cpp b/power-libperfmgr/aidl/PowerHintSession.cpp index e8ef1e24..cac641a6 100644 --- a/power-libperfmgr/aidl/PowerHintSession.cpp +++ b/power-libperfmgr/aidl/PowerHintSession.cpp @@ -147,7 +147,7 @@ PowerHintSession::PowerHintSession(std::shared_ptr<AdaptiveCpu> adaptiveCpu, int } PowerSessionManager::getInstance()->addPowerSession(this); // init boost - wakeup(); + setSessionUclampMin(HintManager::GetInstance()->GetAdpfProfile()->mUclampMinInit); ALOGV("PowerHintSession created: %s", mDescriptor->toString().c_str()); } @@ -163,10 +163,6 @@ PowerHintSession::~PowerHintSession() { sz = sz = StringPrintf("adpf.%s-active", idstr.c_str()); ATRACE_INT(sz.c_str(), 0); } - { - std::lock_guard<std::mutex> guard(mSessionLock); - mSessionClosed.store(true); - } delete mDescriptor; } @@ -267,11 +263,16 @@ ndk::ScopedAStatus PowerHintSession::close() { if (!mSessionClosed.compare_exchange_strong(sessionClosedExpectedToBe, true)) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); } + // Remove the session from PowerSessionManager first to avoid racing. + PowerSessionManager::getInstance()->removePowerSession(this); + setSessionUclampMin(0); + { + std::lock_guard<std::mutex> guard(mSessionLock); + mSessionClosed.store(true); + } mDescriptor->is_active.store(false); mEarlyBoostHandler->setSessionDead(); mStaleTimerHandler->setSessionDead(); - setSessionUclampMin(0); - PowerSessionManager::getInstance()->removePowerSession(this); updateUniveralBoostMode(); return ndk::ScopedAStatus::ok(); } @@ -443,8 +444,7 @@ void PowerHintSession::updateWorkPeriod(const std::vector<WorkDuration> &actualD } const WorkDuration ¤t = actualDurations.back(); int64_t curr_start = current.timeStampNanos - current.durationNanos; - int64_t period = mDescriptor->duration.count(); - period = curr_start - mLastStartedTimeNs; + int64_t period = curr_start - mLastStartedTimeNs; if (period > 0 && period < mDescriptor->duration.count() * 2) { // Accounting workload period with moving average for the last 10 workload. mWorkPeriodNs = 0.9 * mWorkPeriodNs + 0.1 * period; diff --git a/power-libperfmgr/aidl/PowerHintSession.h b/power-libperfmgr/aidl/PowerHintSession.h index 14a738be..96b445ed 100644 --- a/power-libperfmgr/aidl/PowerHintSession.h +++ b/power-libperfmgr/aidl/PowerHintSession.h @@ -114,7 +114,8 @@ class PowerHintSession : public BnPowerHintSession { class EarlyBoostHandler : public MessageHandler { public: - EarlyBoostHandler(PowerHintSession *session) : mSession(session) {} + EarlyBoostHandler(PowerHintSession *session) + : mSession(session), mIsMonitoring(false), mIsSessionDead(false) {} void updateTimer(time_point<steady_clock> boostTime); void handleMessage(const Message &message) override; void setSessionDead(); diff --git a/power-libperfmgr/aidl/PowerSessionManager.cpp b/power-libperfmgr/aidl/PowerSessionManager.cpp index 313a19ee..516942ac 100644 --- a/power-libperfmgr/aidl/PowerSessionManager.cpp +++ b/power-libperfmgr/aidl/PowerSessionManager.cpp @@ -97,7 +97,7 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(), durationMs); if (boost.compare("DISPLAY_UPDATE_IMMINENT") == 0) { - wakeSessions(); + PowerHintMonitor::getInstance()->getLooper()->sendMessage(mWakeupHandler, NULL); } } @@ -201,6 +201,10 @@ 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<std::mutex> guard(mLock); diff --git a/power-libperfmgr/aidl/PowerSessionManager.h b/power-libperfmgr/aidl/PowerSessionManager.h index 90076591..6cd0886c 100644 --- a/power-libperfmgr/aidl/PowerSessionManager.h +++ b/power-libperfmgr/aidl/PowerSessionManager.h @@ -62,6 +62,13 @@ class PowerSessionManager : public MessageHandler { } private: + class WakeupHandler : public MessageHandler { + public: + WakeupHandler() {} + void handleMessage(const Message &message) override; + }; + + private: void wakeSessions(); std::optional<bool> isAnyAppSessionActive(); void disableSystemTopAppBoost(); @@ -71,6 +78,7 @@ class PowerSessionManager : public MessageHandler { 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. @@ -82,7 +90,9 @@ class PowerSessionManager : public MessageHandler { : kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost, "ADPF_DISABLE_TA_BOOST")), mActive(false), - mDisplayRefreshRate(60) {} + mDisplayRefreshRate(60) { + mWakeupHandler = sp<WakeupHandler>(new WakeupHandler()); + } PowerSessionManager(PowerSessionManager const &) = delete; void operator=(PowerSessionManager const &) = delete; }; |