mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Support Windows Sysman initialization
Support for Initialization using zesInit Support Power module using new sysman initialization Related-To: LOCI-4134 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f8623fadaf
commit
d0fb5a6e51
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/sysman/source/firmware_util/firmware_util.h"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2020-2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_sysman_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_power.h
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_kmd_sys_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
uint32_t mockPowerLimit1Enabled = 1;
|
||||
uint32_t mockPowerLimit2Enabled = 1;
|
||||
int32_t mockPowerLimit1 = 25000;
|
||||
int32_t mockPowerLimit2 = 41000;
|
||||
int32_t mockTauPowerLimit1 = 20800;
|
||||
uint32_t mockTpdDefault = 34000;
|
||||
uint32_t mockMinPowerLimit = 1000;
|
||||
uint32_t mockMaxPowerLimit = 80000;
|
||||
int32_t mockAcPowerPeak = 0;
|
||||
int32_t mockDcPowerPeak = 0;
|
||||
uint32_t mockEnergyThreshold = 0;
|
||||
uint32_t mockEnergyCounter = 3231121;
|
||||
uint32_t mockTimeStamp = 1123412412;
|
||||
uint32_t mockEnergyUnit = 14;
|
||||
uint64_t mockEnergyCounter64Bit = 32323232323232;
|
||||
uint32_t mockFrequencyTimeStamp = 38400000;
|
||||
|
||||
void getActivityProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
|
||||
switch (pRequest->inRequestId) {
|
||||
case KmdSysman::Requests::Activity::TimestampFrequency: {
|
||||
uint32_t *pValueFrequency = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValueFrequency = mockFrequencyTimeStamp;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void getPowerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
|
||||
switch (pRequest->inRequestId) {
|
||||
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->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->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->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->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::PowerLimit1Enabled: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockPowerLimit1Enabled;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
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;
|
||||
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->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->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->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->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);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyThreshold: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pValue = mockEnergyThreshold;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyCounter: {
|
||||
uint32_t *pValueCounter = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
uint64_t *pValueTS = reinterpret_cast<uint64_t *>(pBuffer + sizeof(uint32_t));
|
||||
*pValueCounter = mockEnergyCounter;
|
||||
*pValueTS = mockTimeStamp;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
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->outDataSize = sizeof(uint32_t);
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyCounter64Bit: {
|
||||
uint64_t *pValueCounter = reinterpret_cast<uint64_t *>(pBuffer);
|
||||
uint64_t *pValueTS = reinterpret_cast<uint64_t *>(pBuffer + sizeof(uint64_t));
|
||||
*pValueCounter = mockEnergyCounter64Bit;
|
||||
*pValueTS = mockTimeStamp;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(uint64_t) + sizeof(uint64_t);
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void setPowerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pRequest);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
|
||||
switch (pRequest->inRequestId) {
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit1: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockPowerLimit1 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit1Tau: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockTauPowerLimit1 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit2: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockPowerLimit2 = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Ac: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockAcPowerPeak = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentPowerLimit4Dc: {
|
||||
int32_t *pValue = reinterpret_cast<int32_t *>(pBuffer);
|
||||
mockDcPowerPeak = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
case KmdSysman::Requests::Power::CurrentEnergyThreshold: {
|
||||
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
mockEnergyThreshold = *pValue;
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/test/unit_tests/sources/power/windows/mock_power.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_fixture.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
constexpr uint32_t powerHandleComponentCount = 1u;
|
||||
class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PowerKmdSysManager> pKmdSysManager;
|
||||
L0::Sysman::KmdSysManager *pOriginalKmdSysManager = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
}
|
||||
|
||||
void init(bool allowSetCalls) {
|
||||
pKmdSysManager.reset(new PowerKmdSysManager);
|
||||
|
||||
pKmdSysManager->allowSetCalls = allowSetCalls;
|
||||
|
||||
pOriginalKmdSysManager = pWddmSysmanImp->pKmdSysManager;
|
||||
pWddmSysmanImp->pKmdSysManager = pKmdSysManager.get();
|
||||
|
||||
for (auto handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
}
|
||||
void TearDown() override {
|
||||
pWddmSysmanImp->pKmdSysManager = pOriginalKmdSysManager;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
std::vector<zes_pwr_handle_t> get_power_handles(uint32_t count) {
|
||||
std::vector<zes_pwr_handle_t> handles(count, nullptr);
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
return handles;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
init(true);
|
||||
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenInvalidComponentCountWhenEnumeratingPowerDomainThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
init(true);
|
||||
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
|
||||
count = count + 1;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainThenValidPowerHandlesIsReturned) {
|
||||
init(true);
|
||||
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
|
||||
std::vector<zes_pwr_handle_t> handles(count, nullptr);
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(pSysmanDevice->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
for (auto handle : handles) {
|
||||
EXPECT_NE(handle, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, DISABLED_GivenValidPowerHandleWhenGettingPowerPropertiesAllowSetToTrueThenCallSucceeds) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
|
||||
ze_result_t result = zesPowerGetProperties(handle, &properties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0);
|
||||
EXPECT_TRUE(properties.canControl);
|
||||
EXPECT_TRUE(properties.isEnergyThresholdSupported);
|
||||
EXPECT_EQ(properties.maxLimit, pKmdSysManager->mockMaxPowerLimit);
|
||||
EXPECT_EQ(properties.minLimit, pKmdSysManager->mockMinPowerLimit);
|
||||
EXPECT_EQ(properties.defaultLimit, pKmdSysManager->mockTpdDefault);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, DISABLED_GivenValidPowerHandleWhenGettingPowerPropertiesAllowSetToFalseThenCallSucceeds) {
|
||||
// Setting allow set calls or not
|
||||
init(false);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
|
||||
ze_result_t result = zesPowerGetProperties(handle, &properties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0);
|
||||
EXPECT_FALSE(properties.canControl);
|
||||
EXPECT_FALSE(properties.isEnergyThresholdSupported);
|
||||
EXPECT_EQ(properties.maxLimit, pKmdSysManager->mockMaxPowerLimit);
|
||||
EXPECT_EQ(properties.minLimit, pKmdSysManager->mockMinPowerLimit);
|
||||
EXPECT_EQ(properties.defaultLimit, pKmdSysManager->mockTpdDefault);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterThenValidPowerReadingsRetrieved) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_energy_counter_t energyCounter;
|
||||
|
||||
ze_result_t result = zesPowerGetEnergyCounter(handle, &energyCounter);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(energyCounter.energy, pKmdSysManager->mockEnergyCounter64Bit);
|
||||
EXPECT_EQ(energyCounter.timestamp, pKmdSysManager->mockTimeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerLimitsAllowSetToFalseThenCallSucceedsWithValidPowerReadingsRetrieved) {
|
||||
// Setting allow set calls or not
|
||||
init(false);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
|
||||
ze_result_t result = zesPowerGetLimits(handle, &sustained, &burst, &peak);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(sustained.enabled);
|
||||
EXPECT_EQ(sustained.power, pKmdSysManager->mockPowerLimit1);
|
||||
EXPECT_EQ(sustained.interval, pKmdSysManager->mockTauPowerLimit1);
|
||||
EXPECT_TRUE(burst.enabled);
|
||||
EXPECT_EQ(burst.power, pKmdSysManager->mockPowerLimit2);
|
||||
EXPECT_EQ(peak.powerAC, pKmdSysManager->mockAcPowerPeak);
|
||||
EXPECT_EQ(peak.powerDC, pKmdSysManager->mockDcPowerPeak);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerLimitsAllowSetToFalseThenCallFails) {
|
||||
// Setting allow set calls or not
|
||||
init(false);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
|
||||
ze_result_t result = zesPowerGetLimits(handle, &sustained, &burst, &peak);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
sustained.power += 1000;
|
||||
|
||||
result = zesPowerSetLimits(handle, &sustained, &burst, &peak);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingEnergyThresholdAllowSetToFalseThenCallFails) {
|
||||
// Setting allow set calls or not
|
||||
init(false);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
double energyThreshold = 2000;
|
||||
|
||||
ze_result_t result = zesPowerSetEnergyThreshold(handle, energyThreshold);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingEnergyThresholdAllowSetToTrueThenCallSucceeds) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
double energyThreshold = 2000;
|
||||
|
||||
ze_result_t result = zesPowerSetEnergyThreshold(handle, energyThreshold);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
zes_energy_threshold_t newEnergyThreshold;
|
||||
result = zesPowerGetEnergyThreshold(handle, &newEnergyThreshold);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(newEnergyThreshold.threshold, energyThreshold);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerLimitsAllowSetToTrueThenCallSucceeds) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
|
||||
uint32_t powerIncrement = 1500;
|
||||
uint32_t timeIncrement = 12000;
|
||||
uint32_t AcPeakPower = 56000;
|
||||
uint32_t DcPeakPower = 44100;
|
||||
|
||||
ze_result_t result = zesPowerGetLimits(handle, &sustained, &burst, &peak);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
sustained.power += powerIncrement;
|
||||
sustained.interval += timeIncrement;
|
||||
burst.power += powerIncrement;
|
||||
peak.powerAC = AcPeakPower;
|
||||
peak.powerDC = DcPeakPower;
|
||||
|
||||
result = zesPowerSetLimits(handle, &sustained, &burst, &peak);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
zes_power_sustained_limit_t newSustained;
|
||||
zes_power_burst_limit_t newBurst;
|
||||
zes_power_peak_limit_t newPeak;
|
||||
|
||||
result = zesPowerGetLimits(handle, &newSustained, &newBurst, &newPeak);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(newSustained.power, sustained.power);
|
||||
EXPECT_EQ(newSustained.interval, sustained.interval);
|
||||
EXPECT_EQ(newBurst.power, burst.power);
|
||||
EXPECT_EQ(newPeak.powerAC, peak.powerAC);
|
||||
EXPECT_EQ(newPeak.powerDC, peak.powerDC);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtWhenHwmonInterfaceExistThenUnsupportedFeatureIsReturned) {
|
||||
// Setting allow set calls or not
|
||||
init(true);
|
||||
|
||||
auto handles = get_power_handles(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));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 2020-2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_wddm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_kmd_sys_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_driver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_driver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_manager.cpp
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,514 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/sysman/source/windows/kmd_sys_manager.h"
|
||||
#include "level_zero/zes_api.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
constexpr uint32_t mockKmdVersionMajor = 1;
|
||||
constexpr uint32_t mockKmdVersionMinor = 0;
|
||||
constexpr uint32_t mockKmdPatchNumber = 0;
|
||||
constexpr uint32_t mockKmdMaxHandlesPerEvent = 20;
|
||||
|
||||
struct MockEventHandle {
|
||||
HANDLE eventHandle;
|
||||
bool inited = false;
|
||||
};
|
||||
|
||||
uint64_t convertTStoMicroSec(uint64_t TS, uint32_t freq);
|
||||
namespace KmdSysman = L0::Sysman::KmdSysman;
|
||||
struct MockKmdSysManager : public L0::Sysman::KmdSysManager {
|
||||
ze_bool_t allowSetCalls = false;
|
||||
ze_bool_t fanSupported = false;
|
||||
uint32_t mockPowerLimit1 = 2500;
|
||||
NTSTATUS mockEscapeResult = STATUS_SUCCESS;
|
||||
bool mockRequestSingle = false;
|
||||
bool mockRequestMultiple = false;
|
||||
bool requestMultipleSizeDiff = false;
|
||||
ze_result_t mockRequestSingleResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t mockRequestMultipleResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
|
||||
MockEventHandle handles[KmdSysman::Events::MaxEvents][mockKmdMaxHandlesPerEvent];
|
||||
|
||||
MOCKABLE_VIRTUAL void getInterfaceProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setInterfaceProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getPowerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
|
||||
if (pRequest->inRequestId == KmdSysman::Requests::Power::CurrentPowerLimit1) {
|
||||
uint32_t *pPl1 = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
*pPl1 = mockPowerLimit1;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(uint32_t);
|
||||
} else {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setPowerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pRequest);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
|
||||
if (pRequest->inRequestId == KmdSysman::Requests::Power::CurrentPowerLimit1) {
|
||||
uint32_t *pPl1 = reinterpret_cast<uint32_t *>(pBuffer);
|
||||
mockPowerLimit1 = *pPl1;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
} else {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getFrequencyProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setFrequencyProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getActivityProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getPerformanceProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setActivityProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getFanProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setFanProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getTemperatureProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setTemperatureProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setPerformanceProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getFpsProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setFpsProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getSchedulerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setSchedulerProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getMemoryProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setMemoryProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getPciProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setPciProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void getGlobalOperationsProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL void setGlobalOperationsProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
}
|
||||
|
||||
void retrieveCorrectVersion(KmdSysman::GfxSysmanMainHeaderOut *pHeaderOut) {
|
||||
pHeaderOut->outNumElements = 1;
|
||||
pHeaderOut->outTotalSize = 0;
|
||||
|
||||
KmdSysman::GfxSysmanReqHeaderOut *pResponse = reinterpret_cast<KmdSysman::GfxSysmanReqHeaderOut *>(pHeaderOut->outBuffer);
|
||||
uint8_t *pBuffer = nullptr;
|
||||
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess;
|
||||
pResponse->outDataSize = sizeof(KmdSysman::KmdSysmanVersion);
|
||||
pBuffer = reinterpret_cast<uint8_t *>(pResponse);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
pHeaderOut->outTotalSize += sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
|
||||
KmdSysman::KmdSysmanVersion *pCurrentVersion = reinterpret_cast<KmdSysman::KmdSysmanVersion *>(pBuffer);
|
||||
pCurrentVersion->majorVersion = mockKmdVersionMajor;
|
||||
pCurrentVersion->minorVersion = mockKmdVersionMinor;
|
||||
pCurrentVersion->patchNumber = mockKmdPatchNumber;
|
||||
|
||||
pHeaderOut->outTotalSize += sizeof(KmdSysman::KmdSysmanVersion);
|
||||
}
|
||||
|
||||
bool validateInputBuffer(KmdSysman::GfxSysmanMainHeaderIn *pHeaderIn) {
|
||||
uint32_t sizeCheck = pHeaderIn->inTotalsize;
|
||||
uint8_t *pBufferPtr = pHeaderIn->inBuffer;
|
||||
|
||||
for (uint32_t i = 0; i < pHeaderIn->inNumElements; i++) {
|
||||
KmdSysman::GfxSysmanReqHeaderIn *pRequest = reinterpret_cast<KmdSysman::GfxSysmanReqHeaderIn *>(pBufferPtr);
|
||||
if (pRequest->inCommand == KmdSysman::Command::Get ||
|
||||
pRequest->inCommand == KmdSysman::Command::Set ||
|
||||
pRequest->inCommand == KmdSysman::Command::RegisterEvent) {
|
||||
if (pRequest->inComponent >= KmdSysman::Component::InterfaceProperties && pRequest->inComponent < KmdSysman::Component::MaxComponents) {
|
||||
pBufferPtr += sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
sizeCheck -= sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
|
||||
if (pRequest->inCommand == KmdSysman::Command::Set ||
|
||||
pRequest->inCommand == KmdSysman::Command::RegisterEvent) {
|
||||
if (pRequest->inDataSize == 0) {
|
||||
return false;
|
||||
}
|
||||
pBufferPtr += pRequest->inDataSize;
|
||||
sizeCheck -= pRequest->inDataSize;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeCheck != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void registerEvent(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
if (!allowSetCalls) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pRequest);
|
||||
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
|
||||
pResponse->outDataSize = 0;
|
||||
|
||||
switch (pRequest->inRequestId) {
|
||||
case KmdSysman::Events::EnterD0:
|
||||
case KmdSysman::Events::EnterD3:
|
||||
case KmdSysman::Events::EnterTDR:
|
||||
case KmdSysman::Events::ExitTDR:
|
||||
case KmdSysman::Events::EnergyThresholdCrossed: {
|
||||
bool found = false;
|
||||
for (uint32_t i = 0; i < mockKmdMaxHandlesPerEvent; i++) {
|
||||
if (!handles[pRequest->inRequestId][i].inited) {
|
||||
handles[pRequest->inRequestId][i].inited = true;
|
||||
unsigned long long eventID = *(unsigned long long *)pBuffer;
|
||||
handles[pRequest->inRequestId][i].eventHandle = reinterpret_cast<HANDLE>(eventID);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pResponse->outReturnCode = found ? KmdSysman::KmdSysmanSuccess : KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
default:
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void signalEvent(uint32_t idEvent) {
|
||||
|
||||
uint32_t arrayID = 0;
|
||||
if (idEvent & ZES_EVENT_TYPE_FLAG_ENERGY_THRESHOLD_CROSSED) {
|
||||
arrayID = KmdSysman::Events::EnergyThresholdCrossed;
|
||||
}
|
||||
|
||||
if (idEvent & ZES_EVENT_TYPE_FLAG_DEVICE_SLEEP_STATE_ENTER) {
|
||||
arrayID = KmdSysman::Events::EnterD3;
|
||||
}
|
||||
|
||||
if (idEvent & ZES_EVENT_TYPE_FLAG_DEVICE_SLEEP_STATE_EXIT) {
|
||||
arrayID = KmdSysman::Events::EnterD0;
|
||||
}
|
||||
|
||||
if (idEvent & ZES_EVENT_TYPE_FLAG_DEVICE_DETACH) {
|
||||
arrayID = KmdSysman::Events::EnterTDR;
|
||||
}
|
||||
|
||||
if (idEvent & ZES_EVENT_TYPE_FLAG_DEVICE_ATTACH) {
|
||||
arrayID = KmdSysman::Events::ExitTDR;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mockKmdMaxHandlesPerEvent; i++) {
|
||||
if (handles[arrayID][i].inited) {
|
||||
SetEvent(handles[arrayID][i].eventHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t requestSingle(KmdSysman::RequestProperty &In, KmdSysman::ResponseProperty &Out) {
|
||||
if (mockRequestSingle == false) {
|
||||
return KmdSysManager::requestSingle(In, Out);
|
||||
}
|
||||
return mockRequestSingleResult;
|
||||
}
|
||||
|
||||
ze_result_t requestMultiple(std::vector<KmdSysman::RequestProperty> &vIn, std::vector<KmdSysman::ResponseProperty> &vOut) {
|
||||
if (mockRequestMultiple == false) {
|
||||
return KmdSysManager::requestMultiple(vIn, vOut);
|
||||
} else {
|
||||
if (requestMultipleSizeDiff == true) {
|
||||
KmdSysman::ResponseProperty temp;
|
||||
vOut.push_back(temp);
|
||||
}
|
||||
return mockRequestMultipleResult;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void setProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
if (!allowSetCalls) {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pRequest->inComponent) {
|
||||
case KmdSysman::Component::InterfaceProperties: {
|
||||
setInterfaceProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PowerComponent: {
|
||||
setPowerProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FrequencyComponent: {
|
||||
setFrequencyProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::ActivityComponent: {
|
||||
setActivityProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FanComponent: {
|
||||
setFanProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::TemperatureComponent: {
|
||||
setTemperatureProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FpsComponent: {
|
||||
setFpsProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::SchedulerComponent: {
|
||||
setSchedulerProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::MemoryComponent: {
|
||||
setMemoryProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PciComponent: {
|
||||
setPciProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::GlobalOperationsComponent: {
|
||||
setGlobalOperationsProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PerformanceComponent: {
|
||||
setPerformanceProperty(pRequest, pResponse);
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void getProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) {
|
||||
switch (pRequest->inComponent) {
|
||||
case KmdSysman::Component::InterfaceProperties: {
|
||||
getInterfaceProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PowerComponent: {
|
||||
getPowerProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FrequencyComponent: {
|
||||
getFrequencyProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::ActivityComponent: {
|
||||
getActivityProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FanComponent: {
|
||||
getFanProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::TemperatureComponent: {
|
||||
getTemperatureProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::FpsComponent: {
|
||||
getFpsProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::SchedulerComponent: {
|
||||
getSchedulerProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::MemoryComponent: {
|
||||
getMemoryProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PciComponent: {
|
||||
getPciProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::GlobalOperationsComponent: {
|
||||
getGlobalOperationsProperty(pRequest, pResponse);
|
||||
} break;
|
||||
case KmdSysman::Component::PerformanceComponent: {
|
||||
getPerformanceProperty(pRequest, pResponse);
|
||||
} break;
|
||||
default: {
|
||||
pResponse->outDataSize = 0;
|
||||
pResponse->outReturnCode = KmdSysman::KmdSysmanFail;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS escape(uint32_t escapeOp, uint64_t pInPtr, uint32_t dataInSize, uint64_t pOutPtr, uint32_t dataOutSize) {
|
||||
if (mockEscapeResult != STATUS_SUCCESS) {
|
||||
return mockEscapeResult;
|
||||
}
|
||||
void *pDataIn = reinterpret_cast<void *>(pInPtr);
|
||||
void *pDataOut = reinterpret_cast<void *>(pOutPtr);
|
||||
|
||||
if (pDataIn == nullptr || pDataOut == nullptr) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (dataInSize != sizeof(KmdSysman::GfxSysmanMainHeaderIn) || dataOutSize != sizeof(KmdSysman::GfxSysmanMainHeaderOut)) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (escapeOp != KmdSysman::PcEscapeOperation) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
KmdSysman::GfxSysmanMainHeaderIn *pSysmanMainHeaderIn = reinterpret_cast<KmdSysman::GfxSysmanMainHeaderIn *>(pDataIn);
|
||||
KmdSysman::GfxSysmanMainHeaderOut *pSysmanMainHeaderOut = reinterpret_cast<KmdSysman::GfxSysmanMainHeaderOut *>(pDataOut);
|
||||
|
||||
KmdSysman::KmdSysmanVersion versionSysman;
|
||||
versionSysman.data = pSysmanMainHeaderIn->inVersion;
|
||||
|
||||
if (versionSysman.majorVersion != KmdSysman::KmdMajorVersion) {
|
||||
if (versionSysman.majorVersion == 0) {
|
||||
retrieveCorrectVersion(pSysmanMainHeaderOut);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (pSysmanMainHeaderIn->inTotalsize == 0) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (pSysmanMainHeaderIn->inNumElements == 0) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (!validateInputBuffer(pSysmanMainHeaderIn)) {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
uint8_t *pBufferIn = pSysmanMainHeaderIn->inBuffer;
|
||||
uint8_t *pBufferOut = pSysmanMainHeaderOut->outBuffer;
|
||||
uint32_t requestOffset = 0;
|
||||
uint32_t responseOffset = 0;
|
||||
pSysmanMainHeaderOut->outTotalSize = 0;
|
||||
|
||||
for (uint32_t i = 0; i < pSysmanMainHeaderIn->inNumElements; i++) {
|
||||
KmdSysman::GfxSysmanReqHeaderIn *pRequest = reinterpret_cast<KmdSysman::GfxSysmanReqHeaderIn *>(pBufferIn);
|
||||
KmdSysman::GfxSysmanReqHeaderOut *pResponse = reinterpret_cast<KmdSysman::GfxSysmanReqHeaderOut *>(pBufferOut);
|
||||
|
||||
switch (pRequest->inCommand) {
|
||||
case KmdSysman::Command::Get: {
|
||||
getProperty(pRequest, pResponse);
|
||||
requestOffset = sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
responseOffset = sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
responseOffset += pResponse->outDataSize;
|
||||
} break;
|
||||
case KmdSysman::Command::Set: {
|
||||
setProperty(pRequest, pResponse);
|
||||
requestOffset = sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
requestOffset += pRequest->inDataSize;
|
||||
responseOffset = sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
} break;
|
||||
case KmdSysman::Command::RegisterEvent: {
|
||||
registerEvent(pRequest, pResponse);
|
||||
requestOffset = sizeof(KmdSysman::GfxSysmanReqHeaderIn);
|
||||
requestOffset += pRequest->inDataSize;
|
||||
responseOffset = sizeof(KmdSysman::GfxSysmanReqHeaderOut);
|
||||
} break;
|
||||
default: {
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
} break;
|
||||
}
|
||||
|
||||
pResponse->outRequestId = pRequest->inRequestId;
|
||||
pResponse->outComponent = pRequest->inComponent;
|
||||
pBufferIn += requestOffset;
|
||||
pBufferOut += responseOffset;
|
||||
pSysmanMainHeaderOut->outTotalSize += responseOffset;
|
||||
}
|
||||
|
||||
pSysmanMainHeaderOut->outNumElements = pSysmanMainHeaderIn->inNumElements;
|
||||
pSysmanMainHeaderOut->outStatus = KmdSysman::KmdSysmanSuccess;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/sysman/source/sysman_driver_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct MockSysmanDriver : public ::L0::Sysman::SysmanDriverImp {
|
||||
MockSysmanDriver() {
|
||||
previousDriver = driver;
|
||||
driver = this;
|
||||
}
|
||||
~MockSysmanDriver() override {
|
||||
driver = previousDriver;
|
||||
}
|
||||
|
||||
ze_result_t driverInit(ze_init_flags_t flag) override {
|
||||
initCalledCount++;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
::L0::Sysman::SysmanDriver *previousDriver = nullptr;
|
||||
uint32_t initCalledCount = 0;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/sysman_driver_handle_imp.h"
|
||||
#include "level_zero/sysman/source/windows/os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_wddm.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class PublicWddmSysmanImp : public L0::Sysman::WddmSysmanImp {
|
||||
public:
|
||||
using WddmSysmanImp::pFwUtilInterface;
|
||||
using WddmSysmanImp::pKmdSysManager;
|
||||
};
|
||||
|
||||
class SysmanDeviceFixture : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
|
||||
execEnv = new NEO::ExecutionEnvironment();
|
||||
execEnv->prepareRootDeviceEnvironments(numRootDevices);
|
||||
for (auto i = 0u; i < execEnv->rootDeviceEnvironments.size(); i++) {
|
||||
execEnv->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
|
||||
execEnv->rootDeviceEnvironments[i]->osInterface = std::make_unique<NEO::OSInterface>();
|
||||
execEnv->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::make_unique<SysmanMockWddm>(*execEnv->rootDeviceEnvironments[i]));
|
||||
}
|
||||
|
||||
driverHandle = std::make_unique<L0::Sysman::SysmanDriverHandleImp>();
|
||||
driverHandle->initialize(*execEnv);
|
||||
pSysmanDevice = driverHandle->sysmanDevices[0];
|
||||
|
||||
pSysmanDeviceImp = static_cast<L0::Sysman::SysmanDeviceImp *>(pSysmanDevice);
|
||||
pOsSysman = pSysmanDeviceImp->pOsSysman;
|
||||
pWddmSysmanImp = static_cast<PublicWddmSysmanImp *>(pOsSysman);
|
||||
pWddmSysmanImp->pFwUtilInterface = new MockFwUtilInterface();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
|
||||
L0::Sysman::SysmanDevice *pSysmanDevice = nullptr;
|
||||
L0::Sysman::SysmanDeviceImp *pSysmanDeviceImp = nullptr;
|
||||
L0::Sysman::OsSysman *pOsSysman = nullptr;
|
||||
PublicWddmSysmanImp *pWddmSysmanImp = nullptr;
|
||||
NEO::ExecutionEnvironment *execEnv = nullptr;
|
||||
std::unique_ptr<L0::Sysman::SysmanDriverHandleImp> driverHandle;
|
||||
const uint32_t numRootDevices = 1u;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/common/mocks/mock_wddm.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class SysmanMockWddm : public NEO::WddmMock {
|
||||
public:
|
||||
SysmanMockWddm(NEO::RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_driver.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <cstring>
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
TEST(zesInit, whenCallingZesInitThenInitializeOnDriverIsCalled) {
|
||||
MockSysmanDriver driver;
|
||||
|
||||
auto result = zesInit(ZE_INIT_FLAG_GPU_ONLY);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(1u, driver.initCalledCount);
|
||||
}
|
||||
|
||||
TEST(zesInit, whenCallingZesInitWithNoFlagsThenInitializeOnDriverIsCalled) {
|
||||
MockSysmanDriver driver;
|
||||
|
||||
auto result = zesInit(0);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(1u, driver.initCalledCount);
|
||||
}
|
||||
|
||||
TEST(zesInit, whenCallingZesInitWithoutGpuOnlyFlagThenInitializeOnDriverIsNotCalled) {
|
||||
MockSysmanDriver driver;
|
||||
|
||||
auto result = zesInit(ZE_INIT_FLAG_VPU_ONLY);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, result);
|
||||
EXPECT_EQ(0u, driver.initCalledCount);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/source/windows/os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_kmd_sys_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class SysmanKmdManagerFixture : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
MockKmdSysManager *pKmdSysManager = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
pKmdSysManager = new MockKmdSysManager;
|
||||
}
|
||||
void TearDown() override {
|
||||
if (pKmdSysManager != nullptr) {
|
||||
delete pKmdSysManager;
|
||||
pKmdSysManager = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsFalseWhenRequestingSingleThenPowerValueIsCorrect) {
|
||||
pKmdSysManager->allowSetCalls = false;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
uint32_t value = 0;
|
||||
memcpy_s(&value, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
value = static_cast<uint32_t>(value);
|
||||
|
||||
EXPECT_EQ(value, pKmdSysManager->mockPowerLimit1);
|
||||
}
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsTrueWhenRequestingSingleThenPowerValueIsCorrect) {
|
||||
pKmdSysManager->allowSetCalls = true;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
constexpr uint32_t increase = 500;
|
||||
uint32_t iniitialPl1 = pKmdSysManager->mockPowerLimit1;
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
uint32_t value = 0;
|
||||
memcpy_s(&value, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
value = static_cast<uint32_t>(value);
|
||||
|
||||
EXPECT_EQ(value, iniitialPl1);
|
||||
|
||||
value += increase;
|
||||
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = sizeof(uint32_t);
|
||||
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &value, sizeof(uint32_t));
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
value = 0;
|
||||
memcpy_s(&value, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
value = static_cast<uint32_t>(value);
|
||||
|
||||
EXPECT_EQ(value, (iniitialPl1 + increase));
|
||||
}
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsFalseAndCorruptedDataWhenRequestingSingleThenCallFails) {
|
||||
pKmdSysManager->allowSetCalls = false;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = sizeof(uint64_t);
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::MaxCommands;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MaxComponents;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::MaxPowerRequests;
|
||||
request.dataSize = 0;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsTrueAndCorruptedDataWhenRequestingSingleThenCallFails) {
|
||||
pKmdSysManager->allowSetCalls = true;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
uint32_t value = 0;
|
||||
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &value, sizeof(uint32_t));
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::MaxCommands;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = sizeof(uint32_t);
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MaxComponents;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::MaxPowerRequests;
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_NE(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsFalseAndTDROccuredWhenRequestSingleIsCalledThenErrorDeviceLostIsReturned) {
|
||||
pKmdSysManager->allowSetCalls = false;
|
||||
pKmdSysManager->mockEscapeResult = STATUS_DEVICE_REMOVED;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
uint32_t value = 0;
|
||||
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
request.dataSize = 0;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &value, sizeof(uint32_t));
|
||||
|
||||
result = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanKmdManagerFixture, GivenAllowSetCallsFalseAndTDROccuredWhenRequestMultipleIsCalledThenErrorDeviceLostIsReturned) {
|
||||
pKmdSysManager->allowSetCalls = false;
|
||||
pKmdSysManager->mockEscapeResult = STATUS_DEVICE_REMOVED;
|
||||
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
std::vector<KmdSysman::RequestProperty> vRequests = {};
|
||||
std::vector<KmdSysman::ResponseProperty> vResponses = {};
|
||||
KmdSysman::RequestProperty request = {};
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MemoryComponent;
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::MaxBandwidth;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::CurrentBandwidthRead;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::CurrentBandwidthWrite;
|
||||
vRequests.push_back(request);
|
||||
|
||||
result = pKmdSysManager->requestMultiple(vRequests, vResponses);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user