void WorkItemQueueManager::enqueueImmediateWorkItemAndReturn(WorkItem* workItem, UIntN priority) { EsifMutexHelper esifMutexHelper(&m_mutex); esifMutexHelper.lock(); if (canEnqueueImmediateWorkItem(workItem)) { ImmediateWorkItem* immediateWorkItem = new ImmediateWorkItem(workItem, priority); try { m_immediateQueue->enqueue(immediateWorkItem); } catch (std::exception ex) { DELETE_MEMORY_TC(immediateWorkItem); throw; } } else { DELETE_MEMORY_TC(workItem); throw dptf_exception("Failed to enqueue work item. Enqueueing has been disabled."); } esifMutexHelper.unlock(); }
DomainCoreControl_001::~DomainCoreControl_001(void) { DELETE_MEMORY_TC(m_coreControlStaticCaps); DELETE_MEMORY_TC(m_coreControlDynamicCaps); DELETE_MEMORY_TC(m_coreControlLpoPreference); DELETE_MEMORY_TC(m_coreControlStatus); }
void WorkItemQueueManager::deleteAllObjects(void) { // Do not acquire mutex for this function. DELETE_MEMORY_TC(m_workItemQueueThread); DELETE_MEMORY_TC(m_deferredQueue); DELETE_MEMORY_TC(m_immediateQueue); DELETE_MEMORY_TC(m_workItemQueueSemaphore); DELETE_MEMORY_TC(m_workItemStatistics); }
void DomainCoreControl_001::clearCachedData(void) { // Do not delete m_coreControlStatus. We can't read this from ESIF. We store it whenever it is 'set' and return // the value when requested. DELETE_MEMORY_TC(m_coreControlStaticCaps); DELETE_MEMORY_TC(m_coreControlDynamicCaps); DELETE_MEMORY_TC(m_coreControlLpoPreference); }
WorkItemQueueThread::~WorkItemQueueThread(void) { m_destroyThread = true; m_workItemQueueSemaphore->signal(); m_workItemQueueThreadExitSemaphore->wait(); DELETE_MEMORY_TC(m_workItemQueueThreadHandle); DELETE_MEMORY_TC(m_workItemQueueThreadExitSemaphore); }
void DomainPowerControl_001::setPowerControl(UIntN participantIndex, UIntN domainIndex, const PowerControlStatusSet& powerControlStatusSet) { validatePowerControlStatus(powerControlStatusSet, domainIndex); programPowerControl(powerControlStatusSet, domainIndex); DELETE_MEMORY_TC(m_powerControlStatusSet); m_powerControlStatusSet = new PowerControlStatusSet(powerControlStatusSet); }
void WorkItemQueueManager::enqueueDeferredWorkItem(WorkItem* workItem, UInt64 numMilliSecUntilExecution) { EsifMutexHelper esifMutexHelper(&m_mutex); esifMutexHelper.lock(); if (m_enqueueingEnabled == true) { DeferredWorkItem* deferredWorkItem = new DeferredWorkItem(workItem, numMilliSecUntilExecution); try { m_deferredQueue->enqueue(deferredWorkItem); } catch (std::exception ex) { DELETE_MEMORY_TC(deferredWorkItem); throw; } } else { delete workItem; throw dptf_exception("Failed to enqueue work item. Enqueueing has been disabled."); } esifMutexHelper.unlock(); }
void DomainConfigTdpControl_001::checkHWConfigTdpSupport(std::vector<ConfigTdpControl> controls, UIntN domainIndex) { m_configTdpLevelsAvailable = getLevelCount(domainIndex); m_configTdpLock = isLockBitSet(domainIndex); UIntN currentTdpControl = //ulTdpControl NOT index... getParticipantServices()->primitiveExecuteGetAsUInt32( esif_primitive_type::GET_PROC_CTDP_CURRENT_SETTING, domainIndex); // Determine the index... Bool controlIdFound = false; for (UIntN i = 0; i < controls.size(); i++) { if (currentTdpControl == controls.at(i).getControlId()) { DELETE_MEMORY_TC(m_configTdpControlStatus); m_configTdpControlStatus = new ConfigTdpControlStatus(i); controlIdFound = true; } } if (controlIdFound == false) { throw dptf_exception("cTDP control not found in set."); } }
UIntN ImmediateWorkItemQueue::removeIfMatches(const WorkItemMatchCriteria& matchCriteria) { EsifMutexHelper esifMutexHelper(&m_mutex); esifMutexHelper.lock(); UIntN numRemoved = 0; auto it = m_queue.begin(); while (it != m_queue.end()) { if ((*it)->matches(matchCriteria) == true) { DELETE_MEMORY_TC(*it); it = m_queue.erase(it); numRemoved++; } else { it++; } } esifMutexHelper.unlock(); return numRemoved; }
void DomainCoreControl_001::createCoreControlLpoPreferenceIfNeeded(UIntN domainIndex) { if (m_coreControlLpoPreference == nullptr) { Bool useDefault = false; UInt32 dataLength = 0; DptfMemory binaryData(Constants::DefaultBufferSize); try { m_participantServicesInterface->primitiveExecuteGet( esif_primitive_type::GET_PROC_CURRENT_LOGICAL_PROCESSOR_OFFLINING, ESIF_DATA_BINARY, binaryData, binaryData.getSize(), &dataLength, domainIndex); } catch (...) { m_participantServicesInterface->writeMessageWarning( ParticipantMessage(FLF, "CLPO not found. Using defaults.")); useDefault = true; } if (useDefault == false) { try { m_coreControlLpoPreference = BinaryParse::processorClpoObject(dataLength, binaryData); } catch (...) { m_participantServicesInterface->writeMessageWarning( ParticipantMessage(FLF, "Could not parse CLPO data. Using defaults.")); DELETE_MEMORY_TC(m_coreControlLpoPreference); useDefault = true; } } if (useDefault == true) { m_coreControlLpoPreference = new CoreControlLpoPreference(true, 0, Percentage(.50), CoreControlOffliningMode::Smt, CoreControlOffliningMode::Core); } binaryData.deallocate(); } }
void WorkItemQueueThread::processImmediateQueue(void) { ImmediateWorkItem* immediateWorkItem = m_immediateQueue->dequeue(); while (immediateWorkItem != nullptr) { // FrameworkEvent::Type eventType = immediateWorkItem->getFrameworkEventType(); #ifdef INCLUDE_WORK_ITEM_STATISTICS try { immediateWorkItem->setWorkItemExecutionStartTime(); } catch (...) { } #endif try { immediateWorkItem->execute(); } catch (...) { } try { m_participantManager->clearAllParticipantCachedData(); } catch (...) { } #ifdef INCLUDE_WORK_ITEM_STATISTICS try { m_workItemStatistics->incrementImmediateTotals(immediateWorkItem); } catch (...) { } #endif DELETE_MEMORY_TC(immediateWorkItem); immediateWorkItem = m_immediateQueue->dequeue(); } }
void WorkItemQueueManager::enqueueImmediateWorkItemAndWait(WorkItem* workItem, UIntN priority) { if (isWorkItemThread() == true) { // This is in place to prevent a deadlock. Keep in mind that we run a single thread to process work items. // There are conditions where a work item is running (on a work item thread) and it submits another work item // and waits for the return. In that case we have an automatic deadlock without this special processing // in place. When this happens we just treat it like a function call and execute the work item directly // and return. Without this in place the work item would just sit in the queue and never execute since // the thread is being held by the currently running work item. workItem->execute(); delete workItem; } else { EsifSemaphore semaphore; EsifMutexHelper esifMutexHelper(&m_mutex); esifMutexHelper.lock(); if (canEnqueueImmediateWorkItem(workItem)) { ImmediateWorkItem* immediateWorkItem = new ImmediateWorkItem(workItem, priority); immediateWorkItem->signalAtCompletion(&semaphore); try { m_immediateQueue->enqueue(immediateWorkItem); } catch (std::exception ex) { DELETE_MEMORY_TC(immediateWorkItem); throw; } } else { delete workItem; throw dptf_exception("Failed to enqueue work item. Enqueueing has been disabled."); } esifMutexHelper.unlock(); semaphore.wait(); } }
void WorkItemQueueThread::executeThread(void) { // This is running on a separate thread and processes all work items until // the destructor is executed m_workItemQueueThreadId = new EsifThreadId(); while (m_destroyThread == false) { processImmediateQueue(); m_workItemQueueSemaphore->wait(); } DELETE_MEMORY_TC(m_workItemQueueThreadId); m_workItemQueueThreadExitSemaphore->signal(); }
void DomainCoreControl_001::setActiveCoreControl(UIntN participantIndex, UIntN domainIndex, const CoreControlStatus& coreControlStatus) { verifyCoreControlStatus(domainIndex, coreControlStatus); createCoreControlStaticCapsIfNeeded(domainIndex); UIntN totalCores = m_coreControlStaticCaps->getTotalLogicalProcessors(); UIntN totalOfflineCoreRequest = totalCores - coreControlStatus.getNumActiveLogicalProcessors(); m_participantServicesInterface->primitiveExecuteSetAsUInt32( esif_primitive_type::SET_PROC_NUMBER_OFFLINE_CORES, totalOfflineCoreRequest, domainIndex); // Refresh the status DELETE_MEMORY_TC(m_coreControlStatus); m_coreControlStatus = new CoreControlStatus(coreControlStatus.getNumActiveLogicalProcessors()); }
void ParticipantManager::destroyParticipant(UIntN participantIndex) { if ((participantIndex < m_participant.size()) && (m_participant[participantIndex] != nullptr)) { try { m_participant[participantIndex]->destroyParticipant(); } catch (...) { ManagerMessage message = ManagerMessage(m_dptfManager, FLF, "Failed while trying to destroy participant."); message.addMessage("Participant Index", participantIndex); m_dptfManager->getEsifServices()->writeMessageError(message); } DELETE_MEMORY_TC(m_participant[participantIndex]); } }
DisplayControlStatus DomainDisplayControl_001::getDisplayControlStatus(UIntN participantIndex, UIntN domainIndex) { if (m_currentDisplayControlIndex == Constants::Invalid) { checkAndCreateControlStructures(domainIndex); // FIXME : This primitive will return the brightness after ALS setting has been applied! Percentage brightnessPercentage = m_participantServicesInterface->primitiveExecuteGetAsPercentage( esif_primitive_type::GET_DISPLAY_BRIGHTNESS_SOFT, domainIndex); m_currentDisplayControlIndex = m_displayControlSet->getControlIndex(brightnessPercentage); DELETE_MEMORY_TC(m_displayControlStatus); m_displayControlStatus = new DisplayControlStatus(m_currentDisplayControlIndex); } return *m_displayControlStatus; }
void DomainConfigTdpControl_001::setConfigTdpControl(UIntN participantIndex, UIntN domainIndex, UIntN configTdpControlIndex) { checkAndCreateControlStructures(domainIndex); // If any of the lock bits are set, we cannot program cTDP if (m_configTdpLock) { getParticipantServices()->writeMessageWarning( ParticipantMessage(FLF, "cTDP set level ignored, lock bit is set!")); return; } // Bounds checking verifyConfigTdpControlIndex(configTdpControlIndex); getParticipantServices()->primitiveExecuteSetAsUInt32( esif_primitive_type::SET_PROC_CTDP_CONTROL, (UInt32)(*m_configTdpControlSet)[configTdpControlIndex].getControlId(), // This is what 7.x does domainIndex); getParticipantServices()->primitiveExecuteSetAsUInt32( esif_primitive_type::SET_PROC_TURBO_ACTIVATION_RATIO, (UInt32)((*m_configTdpControlSet)[configTdpControlIndex].getTdpRatio() - 1), // This is what 7.x does domainIndex); // Then BIOS getParticipantServices()->primitiveExecuteSetAsUInt32( esif_primitive_type::SET_CTDP_POINT, configTdpControlIndex, domainIndex); // Refresh the status DELETE_MEMORY_TC(m_configTdpControlStatus); m_configTdpControlStatus = new ConfigTdpControlStatus(configTdpControlIndex); }
void DomainDisplayControl_001::setDisplayControl(UIntN participantIndex, UIntN domainIndex, UIntN displayControlIndex, Bool isOverridable) { checkAndCreateControlStructures(domainIndex); if (displayControlIndex == m_currentDisplayControlIndex) { m_participantServicesInterface->writeMessageDebug( ParticipantMessage(FLF, "Requested limit = current limit. Ignoring.")); return; } verifyDisplayControlIndex(displayControlIndex); Percentage newBrightness = (*m_displayControlSet)[m_currentDisplayControlIndex].getBrightness(); if (isOverridable == true) { m_participantServicesInterface->primitiveExecuteSetAsPercentage( esif_primitive_type::SET_DISPLAY_BRIGHTNESS_SOFT, newBrightness, domainIndex); } else { m_participantServicesInterface->primitiveExecuteSetAsPercentage( esif_primitive_type::SET_DISPLAY_BRIGHTNESS_HARD, newBrightness, domainIndex); } // Refresh the status m_currentDisplayControlIndex = displayControlIndex; DELETE_MEMORY_TC(m_displayControlStatus); m_displayControlStatus = new DisplayControlStatus(m_currentDisplayControlIndex); }
void DomainPowerControl_001::clearCachedData(void) { DELETE_MEMORY_TC(m_powerControlDynamicCaps); }
void DptfManager::deleteEsifServices(void) { DELETE_MEMORY_TC(m_esifServices); }
DeferredWorkItem::~DeferredWorkItem(void) { DELETE_MEMORY_TC(m_workItem); }
void DomainConfigTdpControl_001::clearCachedData(void) { DELETE_MEMORY_TC(m_configTdpControlSet); DELETE_MEMORY_TC(m_configTdpControlDynamicCaps); DELETE_MEMORY_TC(m_configTdpControlStatus); }
void DptfManager::deleteIndexContainer(void) { DELETE_MEMORY_TC(m_indexContainer); }
DptfStatus::~DptfStatus() { DELETE_MEMORY_TC(m_participantStatusMap); }
void DptfManager::deleteParticipantManager(void) { DELETE_MEMORY_TC(m_participantManager); }
DomainDisplayControl_001::~DomainDisplayControl_001(void) { DELETE_MEMORY_TC(m_displayControlDynamicCaps); DELETE_MEMORY_TC(m_displayControlSet); DELETE_MEMORY_TC(m_displayControlStatus); }
void UniqueIdGenerator::destroy(void) { DELETE_MEMORY_TC(uniqueIdGenerator); }
DomainPowerControl_001::~DomainPowerControl_001(void) { DELETE_MEMORY_TC(m_powerControlStatusSet); DELETE_MEMORY_TC(m_powerControlDynamicCaps); }
dptf_export void DestroyPolicyInstance(PolicyInterface* policy) { DELETE_MEMORY_TC(policy); }
UnifiedDomain::~UnifiedDomain(void) { // destroy all objects created in the constructor DELETE_MEMORY_TC(m_activeControl); DELETE_MEMORY_TC(m_configTdpControl); DELETE_MEMORY_TC(m_coreControl); DELETE_MEMORY_TC(m_displayControl); DELETE_MEMORY_TC(m_performanceControl); DELETE_MEMORY_TC(m_pixelClockControl); DELETE_MEMORY_TC(m_pixelClockStatus); DELETE_MEMORY_TC(m_powerControl); DELETE_MEMORY_TC(m_powerStatus); DELETE_MEMORY_TC(m_domainPriority); DELETE_MEMORY_TC(m_rfProfileControl); DELETE_MEMORY_TC(m_rfProfileStatus); DELETE_MEMORY_TC(m_temperature); DELETE_MEMORY_TC(m_utilization); }