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
This commit is contained in:
parent
014cb76f74
commit
33444e5238
1 changed files with 10 additions and 7 deletions
|
@ -153,6 +153,10 @@ PowerHintSession::~PowerHintSession() {
|
||||||
sz = sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
sz = sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||||
ATRACE_INT(sz.c_str(), 0);
|
ATRACE_INT(sz.c_str(), 0);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(mSessionLock);
|
||||||
|
mSessionClosed.store(true);
|
||||||
|
}
|
||||||
mHintTimerHandler->setSessionDead();
|
mHintTimerHandler->setSessionDead();
|
||||||
delete mDescriptor;
|
delete mDescriptor;
|
||||||
}
|
}
|
||||||
|
@ -376,20 +380,19 @@ void PowerHintSession::setStale() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerHintSession::wakeup() {
|
void PowerHintSession::wakeup() {
|
||||||
|
std::lock_guard<std::mutex> guard(mSessionLock);
|
||||||
|
|
||||||
|
// We only wake up non-paused and stale sessions
|
||||||
|
if (mSessionClosed || !isActive() || !isStale())
|
||||||
|
return;
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
std::string tag =
|
std::string tag =
|
||||||
StringPrintf("wakeup.%s(a:%d,s:%d)", getIdString().c_str(), isActive(), isStale());
|
StringPrintf("wakeup.%s(a:%d,s:%d)", getIdString().c_str(), isActive(), isStale());
|
||||||
ATRACE_NAME(tag.c_str());
|
ATRACE_NAME(tag.c_str());
|
||||||
}
|
}
|
||||||
// We only wake up non-paused and stale sessions
|
|
||||||
if (!isActive() || !isStale())
|
|
||||||
return;
|
|
||||||
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
|
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
|
||||||
int min = std::max(mDescriptor->current_min, static_cast<int>(adpfConfig->mUclampMinInit));
|
int min = std::max(mDescriptor->current_min, static_cast<int>(adpfConfig->mUclampMinInit));
|
||||||
{
|
mDescriptor->current_min = min;
|
||||||
std::lock_guard<std::mutex> guard(mSessionLock);
|
|
||||||
mDescriptor->current_min = min;
|
|
||||||
}
|
|
||||||
PowerSessionManager::getInstance()->setUclampMinLocked(this, min);
|
PowerSessionManager::getInstance()->setUclampMinLocked(this, min);
|
||||||
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mHintTimerHandler);
|
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mHintTimerHandler);
|
||||||
PowerHintMonitor::getInstance()->getLooper()->sendMessage(
|
PowerHintMonitor::getInstance()->getLooper()->sendMessage(
|
||||||
|
|
Loading…
Reference in a new issue