mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
feature(sysman): PowerLimitsExt support in windows zes branch
Related-To: NEO-8808 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a67ef72210
commit
a7e0987485
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -288,26 +288,209 @@ ze_result_t WddmPowerImp::setEnergyThreshold(double threshold) {
|
||||
}
|
||||
|
||||
bool WddmPowerImp::isPowerModuleSupported() {
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
powerLimitCount = 0;
|
||||
std::vector<KmdSysman::RequestProperty> vRequests = {};
|
||||
std::vector<KmdSysman::ResponseProperty> vResponses = {};
|
||||
KmdSysman::RequestProperty request = {};
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit1Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestSingle(request, response);
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit2Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
uint32_t enabled = 0;
|
||||
memcpy_s(&enabled, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
return ((status == ZE_RESULT_SUCCESS) && (enabled));
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
|
||||
|
||||
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vResponses.size() - 1; i++) {
|
||||
ze_bool_t enabled = false;
|
||||
if (vResponses[i].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[i].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
if (enabled) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// CurrentPowerLimit4Ac is not a bool hence check for it individually
|
||||
if (vResponses[2].returnCode == KmdSysman::Success) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
|
||||
if (powerLimitCount > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t WddmPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
uint8_t count = 0;
|
||||
|
||||
if (*pCount == 0) {
|
||||
*pCount = powerLimitCount;
|
||||
return result;
|
||||
}
|
||||
|
||||
*pCount = std::min(*pCount, powerLimitCount);
|
||||
|
||||
std::vector<KmdSysman::RequestProperty> vRequests = {};
|
||||
std::vector<KmdSysman::ResponseProperty> vResponses = {};
|
||||
KmdSysman::RequestProperty request = {};
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit1Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1Tau;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit2Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit2;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
|
||||
|
||||
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// sustained
|
||||
ze_bool_t enabled = false;
|
||||
|
||||
if (vResponses[0].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[0].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
if (vResponses[1].returnCode == KmdSysman::Success && vResponses[2].returnCode == KmdSysman::Success) {
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
uint32_t limit = 0;
|
||||
memcpy_s(&limit, sizeof(uint32_t), vResponses[1].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
uint32_t interval = 0;
|
||||
memcpy_s(&interval, sizeof(uint32_t), vResponses[2].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
pSustained[count].enabled = enabled;
|
||||
pSustained[count].limit = limit;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = false;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_SUSTAINED;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = interval;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Burst
|
||||
enabled = false;
|
||||
if (vResponses[3].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[3].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
|
||||
if (count < *pCount && enabled) {
|
||||
if (vResponses[4].returnCode == KmdSysman::Success) {
|
||||
uint32_t limit = 0;
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
memcpy_s(&limit, sizeof(uint32_t), vResponses[4].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
pSustained[count].enabled = enabled;
|
||||
pSustained[count].limit = limit;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = true;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_BURST;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
// Peak
|
||||
if (count < *pCount) {
|
||||
if (vResponses[5].returnCode == KmdSysman::Success) {
|
||||
uint32_t powerAC = 0;
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
memcpy_s(&powerAC, sizeof(uint32_t), vResponses[5].dataBuffer, sizeof(uint32_t));
|
||||
pSustained[count].enabled = true;
|
||||
pSustained[count].limit = powerAC;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = true;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_PEAK;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
*pCount = count;
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t WddmPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.dataSize = sizeof(uint32_t);
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
if (pSustained[i].level == ZES_POWER_LEVEL_SUSTAINED) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1Tau;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].interval, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else if (pSustained[i].level == ZES_POWER_LEVEL_BURST) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit2;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else if (pSustained[i].level == ZES_POWER_LEVEL_PEAK) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
WddmPowerImp::WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -32,6 +32,7 @@ class WddmPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
KmdSysManager *pKmdSysManager = nullptr;
|
||||
uint32_t powerLimitCount = 0;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
constexpr uint32_t mockLimitCount = 3u;
|
||||
|
||||
struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
@@ -31,6 +32,9 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
uint32_t mockEnergyUnit = 14;
|
||||
uint64_t mockEnergyCounter64Bit = 32323232323232;
|
||||
uint32_t mockFrequencyTimeStamp = 38400000;
|
||||
bool mockPowerLimit2EnabledFailure = false;
|
||||
bool mockPowerLimit1EnabledFailure = false;
|
||||
uint32_t mockPowerFailure[KmdSysman::Requests::Power::MaxPowerRequests] = {0};
|
||||
|
||||
void getActivityProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
@@ -50,6 +54,10 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getReturnCode(uint32_t powerRequestCode) {
|
||||
return mockPowerFailure[powerRequestCode] ? KmdSysman::KmdSysmanFail : KmdSysman::KmdSysmanSuccess;
|
||||
}
|
||||
|
||||
void getPowerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
@@ -58,73 +66,81 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
case KmdSysman::Requests::Power::EnergyThresholdSupported: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = static_cast<uint32_t>(this->allowSetCalls);
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::TdpDefault: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockTpdDefault;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::MinPowerLimitDefault: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockMinPowerLimit;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::MaxPowerLimitDefault: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockMaxPowerLimit;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::PowerLimit1Enabled: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockPowerLimit1Enabled;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
if (mockPowerLimit1EnabledFailure) {
|
||||
*pValue = 0;
|
||||
} else {
|
||||
*pValue = mockPowerLimit1Enabled;
|
||||
}
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::PowerLimit2Enabled: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockPowerLimit2Enabled;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
if (mockPowerLimit2EnabledFailure) {
|
||||
*pValue = false;
|
||||
} else {
|
||||
*pValue = mockPowerLimit2Enabled;
|
||||
}
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit1: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
*pValue = mockPowerLimit1;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(int32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit1Tau: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
*pValue = mockTauPowerLimit1;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(int32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit2: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
*pValue = mockPowerLimit2;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(int32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Ac: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
*pValue = mockAcPowerPeak;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(int32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Dc: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
*pValue = mockDcPowerPeak;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(int32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyThreshold: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockEnergyThreshold;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyCounter: {
|
||||
@@ -132,13 +148,13 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
uint64_t *pValueTS = reinterpret_cast<uint64_t *>(pBuffer + sizeof(uint32_t));
|
||||
*pValueCounter = mockEnergyCounter;
|
||||
*pValueTS = mockTimeStamp;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t) + sizeof(uint64_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::EnergyCounterUnits: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockEnergyUnit;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyCounter64Bit: {
|
||||
@@ -146,7 +162,7 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
uint64_t *pValueTS = reinterpret_cast<uint64_t *>(pBuffer + sizeof(uint64_t));
|
||||
memcpy_s(pValueCounter, sizeof(uint64_t), &mockEnergyCounter64Bit, sizeof(mockEnergyCounter64Bit));
|
||||
memcpy_s(pValueTS, sizeof(uint64_t), &mockTimeStamp, sizeof(mockEnergyCounter64Bit));
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
pResponse->outDataSize = sizeof(uint64_t) + sizeof(uint64_t);
|
||||
} break;
|
||||
default: {
|
||||
@@ -165,37 +181,37 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockPowerLimit1 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit1Tau: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockTauPowerLimit1 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit2: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockPowerLimit2 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Ac: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockAcPowerPeak = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Dc: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockDcPowerPeak = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyThreshold: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
mockEnergyThreshold = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outReturnCode = getReturnCode(pRequest->inRequestId);
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -283,16 +283,135 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerLimitsAllo
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtWhenHwmonInterfaceExistThenUnsupportedFeatureIsReturned) {
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtThenCallSucceeds) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
|
||||
uint32_t limitCount = 0;
|
||||
const int32_t testLimit = 3000000;
|
||||
const int32_t testInterval = 10;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
|
||||
EXPECT_EQ(limitCount, mockLimitCount);
|
||||
|
||||
std::vector<zes_power_limit_ext_desc_t> allLimits(limitCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
for (uint32_t i = 0; i < limitCount; i++) {
|
||||
if (allLimits[i].level == ZES_POWER_LEVEL_SUSTAINED) {
|
||||
EXPECT_FALSE(allLimits[i].limitValueLocked);
|
||||
EXPECT_TRUE(allLimits[i].enabledStateLocked);
|
||||
EXPECT_FALSE(allLimits[i].intervalValueLocked);
|
||||
EXPECT_EQ(ZES_POWER_SOURCE_ANY, allLimits[i].source);
|
||||
EXPECT_EQ(ZES_LIMIT_UNIT_POWER, allLimits[i].limitUnit);
|
||||
allLimits[i].limit = testLimit;
|
||||
allLimits[i].interval = testInterval;
|
||||
} else if (allLimits[i].level == ZES_POWER_LEVEL_PEAK) {
|
||||
EXPECT_FALSE(allLimits[i].limitValueLocked);
|
||||
EXPECT_TRUE(allLimits[i].enabledStateLocked);
|
||||
EXPECT_TRUE(allLimits[i].intervalValueLocked);
|
||||
EXPECT_EQ(ZES_POWER_SOURCE_ANY, allLimits[i].source);
|
||||
EXPECT_EQ(ZES_LIMIT_UNIT_POWER, allLimits[i].limitUnit);
|
||||
allLimits[i].limit = testLimit;
|
||||
} else if (allLimits[i].level == ZES_POWER_LEVEL_BURST) {
|
||||
EXPECT_FALSE(allLimits[i].limitValueLocked);
|
||||
EXPECT_TRUE(allLimits[i].enabledStateLocked);
|
||||
EXPECT_TRUE(allLimits[i].intervalValueLocked);
|
||||
EXPECT_EQ(ZES_POWER_SOURCE_ANY, allLimits[i].source);
|
||||
EXPECT_EQ(ZES_LIMIT_UNIT_POWER, allLimits[i].limitUnit);
|
||||
allLimits[i].limit = testLimit;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
for (uint32_t i = 0; i < limitCount; i++) {
|
||||
if (allLimits[i].level == ZES_POWER_LEVEL_SUSTAINED) {
|
||||
EXPECT_EQ(testInterval, allLimits[i].interval);
|
||||
} else if (allLimits[i].level == ZES_POWER_LEVEL_PEAK || allLimits[i].level == ZES_POWER_LEVEL_BURST) {
|
||||
EXPECT_EQ(0, allLimits[i].interval);
|
||||
}
|
||||
EXPECT_EQ(testLimit, allLimits[i].limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenCallingGetAnsSetPowerLimitsExtThenProperValuesAreReturnedCoveringMutlipleBranches) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
|
||||
uint32_t limitCount = 0;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimitsExt(handle, &limitCount, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
|
||||
EXPECT_EQ(limitCount, mockLimitCount);
|
||||
|
||||
std::vector<zes_power_limit_ext_desc_t> allLimits(limitCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
|
||||
std::vector<uint32_t> requestId = {KmdSysman::Requests::Power::PowerLimit1Enabled, KmdSysman::Requests::Power::CurrentPowerLimit1, KmdSysman::Requests::Power::CurrentPowerLimit1Tau, KmdSysman::Requests::Power::PowerLimit2Enabled, KmdSysman::Requests::Power::CurrentPowerLimit2, KmdSysman::Requests::Power::CurrentPowerLimit4Ac};
|
||||
for (auto it = requestId.begin(); it != requestId.end(); it++) {
|
||||
pKmdSysManager->mockPowerFailure[*it] = 1;
|
||||
uint32_t count = limitCount;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &count, allLimits.data()));
|
||||
pKmdSysManager->mockPowerFailure[*it] = 0;
|
||||
}
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
requestId = {KmdSysman::Requests::Power::CurrentPowerLimit1, KmdSysman::Requests::Power::CurrentPowerLimit1Tau, KmdSysman::Requests::Power::CurrentPowerLimit2, KmdSysman::Requests::Power::CurrentPowerLimit4Ac};
|
||||
for (auto it = requestId.begin(); it != requestId.end(); it++) {
|
||||
pKmdSysManager->mockPowerFailure[*it] = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zesPowerSetLimitsExt(handle, &limitCount, allLimits.data()));
|
||||
pKmdSysManager->mockPowerFailure[*it] = 0;
|
||||
}
|
||||
|
||||
uint32_t count = mockLimitCount;
|
||||
pKmdSysManager->mockRequestMultiple = true;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zesPowerGetLimitsExt(handle, &count, allLimits.data()));
|
||||
pKmdSysManager->requestMultipleSizeDiff = true;
|
||||
count = mockLimitCount;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zesPowerGetLimitsExt(handle, &count, allLimits.data()));
|
||||
pKmdSysManager->mockRequestMultiple = false;
|
||||
pKmdSysManager->requestMultipleSizeDiff = false;
|
||||
|
||||
pKmdSysManager->mockPowerLimit2EnabledFailure = true;
|
||||
count = mockLimitCount;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &count, allLimits.data()));
|
||||
pKmdSysManager->mockPowerLimit2EnabledFailure = false;
|
||||
|
||||
pKmdSysManager->mockPowerLimit1EnabledFailure = true;
|
||||
count = mockLimitCount;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &count, allLimits.data()));
|
||||
pKmdSysManager->mockPowerLimit1EnabledFailure = false;
|
||||
|
||||
allLimits[0].level = ZES_POWER_LEVEL_UNKNOWN;
|
||||
count = mockLimitCount;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimitsExt(handle, &count, allLimits.data()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenCallingGetPowerLimitsExtThenProperValuesAreReturned) {
|
||||
// Setting allow set calls or not
|
||||
init(false);
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_limit_ext_desc_t allLimits{};
|
||||
uint32_t count = 0;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &count, nullptr));
|
||||
EXPECT_EQ(count, mockLimitCount);
|
||||
|
||||
count = 1;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(handle, &count, &allLimits));
|
||||
EXPECT_EQ(count, 1u);
|
||||
EXPECT_EQ(false, allLimits.limitValueLocked);
|
||||
EXPECT_EQ(true, allLimits.enabledStateLocked);
|
||||
EXPECT_EQ(false, allLimits.intervalValueLocked);
|
||||
EXPECT_EQ(ZES_POWER_SOURCE_ANY, allLimits.source);
|
||||
EXPECT_EQ(ZES_LIMIT_UNIT_POWER, allLimits.limitUnit);
|
||||
EXPECT_EQ(ZES_POWER_LEVEL_SUSTAINED, allLimits.level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user