refactor: extract querying device id / revision id to separate method in xe path

Related-To: NEO-13527
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-12-17 15:19:39 +00:00
committed by Compute-Runtime-Automation
parent 270570c5d3
commit 169469eb06
10 changed files with 273 additions and 108 deletions

View File

@@ -127,10 +127,44 @@ IoctlHelperXe::IoctlHelperXe(Drm &drmArg) : IoctlHelper(drmArg) {
xeLog("IoctlHelperXe::IoctlHelperXe\n", "");
}
bool IoctlHelperXe::queryDeviceIdAndRevision(const Drm &drm) {
auto fileDescriptor = drm.getFileDescriptor();
drm_xe_device_query queryConfig = {};
queryConfig.query = DRM_XE_DEVICE_QUERY_CONFIG;
int ret = SysCalls::ioctl(fileDescriptor, DRM_IOCTL_XE_DEVICE_QUERY, &queryConfig);
if (ret || queryConfig.size == 0) {
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query size for device config!\n");
return false;
}
auto data = std::vector<uint64_t>(Math::divideAndRoundUp(sizeof(drm_xe_query_config) + sizeof(uint64_t) * queryConfig.size, sizeof(uint64_t)), 0);
struct drm_xe_query_config *config = reinterpret_cast<struct drm_xe_query_config *>(data.data());
queryConfig.data = castToUint64(config);
ret = SysCalls::ioctl(fileDescriptor, DRM_IOCTL_XE_DEVICE_QUERY, &queryConfig);
if (ret) {
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device ID and revision!\n");
return false;
}
auto hwInfo = drm.getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->platform.usDeviceID = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
hwInfo->platform.usRevId = static_cast<int>((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff);
return true;
}
bool IoctlHelperXe::initialize() {
xeLog("IoctlHelperXe::initialize\n", "");
euDebugInterface = EuDebugInterface::create(drm.getSysFsPciPath());
if (!IoctlHelperXe::queryDeviceIdAndRevision(this->drm)) {
return false;
}
drm_xe_device_query queryConfig = {};
queryConfig.query = DRM_XE_DEVICE_QUERY_CONFIG;
@@ -174,8 +208,6 @@ bool IoctlHelperXe::initialize() {
IoctlHelper::ioctl(DrmIoctl::query, &queryConfig);
auto hwInfo = this->drm.getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->platform.usDeviceID = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
hwInfo->platform.usRevId = static_cast<int>((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff);
hwInfo->capabilityTable.gpuAddressSpace = (1ull << config->info[DRM_XE_QUERY_CONFIG_VA_BITS]) - 1;
hwInfo->capabilityTable.cxlType = 0;

View File

@@ -36,6 +36,8 @@ class IoctlHelperXe : public IoctlHelper {
public:
using IoctlHelper::IoctlHelper;
static std::unique_ptr<IoctlHelperXe> create(Drm &drmArg);
static bool queryDeviceIdAndRevision(const Drm &drm);
IoctlHelperXe(Drm &drmArg);
~IoctlHelperXe() override;
int ioctl(DrmIoctl request, void *arg) override;

View File

@@ -10,6 +10,7 @@ set(neo_libult_common_SRCS_LIB_ULT_LINUX_XE
${CMAKE_CURRENT_SOURCE_DIR}/mock_drm_xe.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_drm_xe.inl
${CMAKE_CURRENT_SOURCE_DIR}/mock_drm_xe_definitions.inl
${CMAKE_CURRENT_SOURCE_DIR}/xe_config_fixture.h
)
if(UNIX)

View File

@@ -30,9 +30,6 @@ struct DrmMockXe : public DrmMockCustom {
int gemMmapOffsetCalled = 0;
int gemDestroyContextCalled = 0;
const uint16_t revId = 0x12;
const uint16_t devId = 0xabc;
uint64_t queryConfig[7]{}; // 1 qword for num params and 1 qwords per param
uint32_t mockExecQueueId = 1234;
static constexpr int32_t mockMaxExecQueuePriority = 3;

View File

@@ -224,7 +224,7 @@ void DrmMockXe::initInstance() {
auto xeQueryConfig = reinterpret_cast<drm_xe_query_config *>(this->queryConfig);
xeQueryConfig->num_params = 6;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] = (this->revId << 16) | this->devId;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] = 0; // this should be queried by ioctl sys call
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_VA_BITS] = 48;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY] = mockMaxExecQueuePriority;

View File

@@ -46,11 +46,13 @@ struct MockIoctlHelperXe : IoctlHelperXe {
if (failPerfDisable) {
return -1;
}
return 0;
}
if (request == DrmIoctl::perfEnable) {
if (failPerfEnable) {
return -1;
}
return 0;
}
return IoctlHelperXe::ioctl(fd, request, arg);
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
namespace NEO {
class XeConfigFixture {
public:
XeConfigFixture() {
const auto &hwInfo = *defaultHwInfo;
static uint64_t queryConfig[2]{}; // 1 qword for num params and 1 qwords per param
auto xeQueryConfig = reinterpret_cast<drm_xe_query_config *>(queryConfig);
xeQueryConfig->num_params = 1;
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] = (hwInfo.platform.usRevId << 16) | hwInfo.platform.usDeviceID;
SysCalls::sysCallsIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
if (request == DRM_IOCTL_XE_DEVICE_QUERY) {
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
if (deviceQuery->query == DRM_XE_DEVICE_QUERY_CONFIG) {
if (deviceQuery->data) {
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryConfig, sizeof(queryConfig));
}
deviceQuery->size = sizeof(queryConfig);
return 0;
}
}
return -1;
};
}
void setUp(){};
void tearDown(){};
VariableBackup<decltype(SysCalls::sysCallsIoctl)> mockIoctl{&SysCalls::sysCallsIoctl};
};
} // namespace NEO

View File

@@ -21,12 +21,14 @@
#include "shared/test/common/mocks/linux/mock_os_time_linux.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/os_interface/linux/xe/xe_config_fixture.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
TEST(IoctlHelperXeTest, whenCallingDebuggerOpenIoctlThenProperValueIsReturned) {
using IoctlHelperXeTest = Test<XeConfigFixture>;
TEST_F(IoctlHelperXeTest, whenCallingDebuggerOpenIoctlThenProperValueIsReturned) {
int ret;
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -40,7 +42,7 @@ TEST(IoctlHelperXeTest, whenCallingDebuggerOpenIoctlThenProperValueIsReturned) {
EXPECT_EQ(ret, drm->debuggerOpenRetval);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetIoctForDebuggerThenCorrectValueReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetIoctForDebuggerThenCorrectValueReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = drm->getIoctlHelper();
@@ -56,7 +58,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetIoctForDebuggerThenCorre
verifyIoctlRequestValue(EuDebugParam::connect, DrmIoctl::debuggerOpen);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetEudebugExtPropertyThenCorrectValueReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetEudebugExtPropertyThenCorrectValueReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->setDebuggingMode(DebuggingMode::offline);
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -162,14 +164,14 @@ HWTEST_F(IoctlHelperXeTestFixture, GivenContextCreatedForCopyEngineWhenCreateDrm
EXPECT_NE(ext.property, static_cast<uint32_t>(EuDebugParam::execQueueSetPropertyEuDebug));
}
TEST(IoctlHelperXeTest, GivenXeDriverThenDebugAttachReturnsTrue) {
TEST_F(IoctlHelperXeTest, GivenXeDriverThenDebugAttachReturnsTrue) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXeDebug *>(drm->ioctlHelper.get());
EXPECT_TRUE(xeIoctlHelper->isDebugAttachAvailable());
}
TEST(IoctlHelperXeTest, givenEuDebugSysFsContentWhenItIsZeroThenEuDebugInterfaceIsNotCreated) {
TEST_F(IoctlHelperXeTest, givenEuDebugSysFsContentWhenItIsZeroThenEuDebugInterfaceIsNotCreated) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -184,7 +186,7 @@ TEST(IoctlHelperXeTest, givenEuDebugSysFsContentWhenItIsZeroThenEuDebugInterface
EXPECT_EQ(nullptr, euDebugInterface);
}
TEST(IoctlHelperXeTest, givenInvalidPathWhenCreateEuDebugInterfaceThenReturnNullptr) {
TEST_F(IoctlHelperXeTest, givenInvalidPathWhenCreateEuDebugInterfaceThenReturnNullptr) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -195,7 +197,7 @@ TEST(IoctlHelperXeTest, givenInvalidPathWhenCreateEuDebugInterfaceThenReturnNull
EXPECT_EQ(nullptr, euDebugInterface);
}
TEST(IoctlHelperXeTest, whenEuDebugInterfaceIsCreatedThenEuDebugIsAvailable) {
TEST_F(IoctlHelperXeTest, whenEuDebugInterfaceIsCreatedThenEuDebugIsAvailable) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXeDebug *>(drm->ioctlHelper.get());
@@ -206,7 +208,7 @@ TEST(IoctlHelperXeTest, whenEuDebugInterfaceIsCreatedThenEuDebugIsAvailable) {
EXPECT_EQ(1, xeIoctlHelper->getEuDebugSysFsEnable());
}
TEST(IoctlHelperXeTest, givenXeRegisterResourceThenCorrectIoctlCalled) {
TEST_F(IoctlHelperXeTest, givenXeRegisterResourceThenCorrectIoctlCalled) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXeDebug *>(drm->ioctlHelper.get());
@@ -256,7 +258,7 @@ TEST(IoctlHelperXeTest, givenXeRegisterResourceThenCorrectIoctlCalled) {
EXPECT_EQ(drm->metadataType, static_cast<uint64_t>(EuDebugParam::metadataModuleArea));
}
TEST(IoctlHelperXeTest, givenXeunregisterResourceThenCorrectIoctlCalled) {
TEST_F(IoctlHelperXeTest, givenXeunregisterResourceThenCorrectIoctlCalled) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXeDebug *>(drm->ioctlHelper.get());
@@ -264,7 +266,7 @@ TEST(IoctlHelperXeTest, givenXeunregisterResourceThenCorrectIoctlCalled) {
EXPECT_EQ(drm->metadataID, 0x1234u);
}
TEST(IoctlHelperXeTest, whenGettingVmBindExtFromHandlesThenProperStructsAreReturned) {
TEST_F(IoctlHelperXeTest, whenGettingVmBindExtFromHandlesThenProperStructsAreReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXeDebug *>(drm->ioctlHelper.get());
@@ -287,7 +289,7 @@ TEST(IoctlHelperXeTest, whenGettingVmBindExtFromHandlesThenProperStructsAreRetur
EXPECT_EQ(reinterpret_cast<uintptr_t>(&vmBindExt[2]), vmBindExt[1].base.nextExtension);
}
TEST(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShouldBeRegisteredThenBoHasBindExtHandleAdded) {
TEST_F(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShouldBeRegisteredThenBoHasBindExtHandleAdded) {
const uint32_t rootDeviceIndex = 0u;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
@@ -336,7 +338,7 @@ TEST(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShould
}
}
TEST(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShouldNotBeRegisteredThenNoBindHandleCreated) {
TEST_F(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShouldNotBeRegisteredThenNoBindHandleCreated) {
const uint32_t rootDeviceIndex = 0u;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
@@ -356,7 +358,7 @@ TEST(IoctlHelperXeTest, givenResourceRegistrationEnabledWhenAllocationTypeShould
EXPECT_EQ(DrmResourceClass::maxSize, drm.registeredClass);
}
TEST(IoctlHelperXeTest, givenDebuggingEnabledWhenCallingVmBindThenWaitUserFenceIsCalledWithCorrectTimeout) {
TEST_F(IoctlHelperXeTest, givenDebuggingEnabledWhenCallingVmBindThenWaitUserFenceIsCalledWithCorrectTimeout) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();

View File

@@ -11,11 +11,13 @@
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
#include "shared/test/common/mocks/linux/mock_os_context_linux.h"
#include "shared/test/common/os_interface/linux/xe/mock_drm_xe.h"
#include "shared/test/common/os_interface/linux/xe/xe_config_fixture.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using IoctlHelperXeTest = Test<XeConfigFixture>;
TEST(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -24,7 +26,7 @@ TEST(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
EXPECT_FALSE(xeIoctlHelper.get()->getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 20u));
}
TEST(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -34,7 +36,7 @@ TEST(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
EXPECT_FALSE(xeIoctlHelper.get()->perfOpenEuStallStream(0u, properties, &invalidFd));
}
TEST(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -43,7 +45,7 @@ TEST(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned)
EXPECT_FALSE(xeIoctlHelper.get()->perfDisableEuStallStream(&invalidFd));
}
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfOpenThenZeroisReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfOpenThenZeroisReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -51,7 +53,7 @@ TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfOpenThenZeroisReturne
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfOpen));
}
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfEnableThenZeroisReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfEnableThenZeroisReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -59,7 +61,7 @@ TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfEnableThenZeroisRetur
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfEnable));
}
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfDisableThenZeroisReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfDisableThenZeroisReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -67,7 +69,7 @@ TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfDisableThenZeroisRetu
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfDisable));
}
TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlWithInvalidValuesThenZeroisReturned) {
TEST_F(IoctlHelperXeTest, whenCallingPerfOpenIoctlWithInvalidValuesThenZeroisReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -75,7 +77,7 @@ TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlWithInvalidValuesThenZeroisRetur
EXPECT_EQ(0, xeIoctlHelper.get()->perfOpenIoctl(DrmIoctl::perfOpen, nullptr));
}
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValueWithInvalidValueThenErrorReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetIoctlRequestValueWithInvalidValueThenErrorReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -83,7 +85,7 @@ TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValueWithInvalidValueThenError
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::version));
}
TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlThenProperValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingPerfOpenIoctlThenProperValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -91,16 +93,16 @@ TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlThenProperValueIsReturned) {
EXPECT_EQ(0, xeIoctlHelper.get()->ioctl(DrmIoctl::perfOpen, nullptr));
}
TEST(IoctlHelperXeTest, whenCallingPerfDisableIoctlThenProperValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingPerfDisableIoctlThenProperValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
EXPECT_NE(nullptr, xeIoctlHelper);
int32_t invalidFd = -1;
EXPECT_EQ(0, xeIoctlHelper.get()->ioctl(invalidFd, DrmIoctl::perfDisable, nullptr));
EXPECT_EQ(-1, xeIoctlHelper.get()->ioctl(invalidFd, DrmIoctl::perfDisable, nullptr));
}
TEST(IoctlHelperXeTest, whenCallingIsEuStallSupportedThenFalseIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingIsEuStallSupportedThenFalseIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);

View File

@@ -16,17 +16,20 @@
#include "shared/test/common/mocks/linux/mock_os_time_linux.h"
#include "shared/test/common/os_interface/linux/xe/mock_drm_xe.h"
#include "shared/test/common/os_interface/linux/xe/mock_ioctl_helper_xe.h"
#include "shared/test/common/os_interface/linux/xe/xe_config_fixture.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
TEST(IoctlHelperXeTest, givenXeDrmVersionsWhenGettingIoctlHelperThenValidIoctlHelperIsReturned) {
using IoctlHelperXeTest = Test<XeConfigFixture>;
TEST_F(IoctlHelperXeTest, givenXeDrmVersionsWhenGettingIoctlHelperThenValidIoctlHelperIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
EXPECT_NE(nullptr, xeIoctlHelper);
}
TEST(IoctlHelperXeTest, whenGettingIfImmediateVmBindIsRequiredThenTrueIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingIfImmediateVmBindIsRequiredThenTrueIsReturned) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperXe ioctlHelper{*drm};
@@ -34,7 +37,7 @@ TEST(IoctlHelperXeTest, whenGettingIfImmediateVmBindIsRequiredThenTrueIsReturned
EXPECT_TRUE(ioctlHelper.isImmediateVmBindRequired());
}
TEST(IoctlHelperXeTest, givenXeDrmWhenGetPciBarrierMmapThenReturnsNullptr) {
TEST_F(IoctlHelperXeTest, givenXeDrmWhenGetPciBarrierMmapThenReturnsNullptr) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperXe ioctlHelper{*drm};
@@ -43,7 +46,7 @@ TEST(IoctlHelperXeTest, givenXeDrmWhenGetPciBarrierMmapThenReturnsNullptr) {
EXPECT_EQ(ptr, nullptr);
}
TEST(IoctlHelperXeTest, whenChangingBufferBindingThenWaitIsNeededAlways) {
TEST_F(IoctlHelperXeTest, whenChangingBufferBindingThenWaitIsNeededAlways) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
@@ -116,7 +119,7 @@ TEST_F(IoctlHelperXeGemCreateExtTests, givenIoctlHelperXeWhenCallingGemCreateExt
EXPECT_EQ(DRM_XE_GEM_CPU_CACHING_WB, drm->createParamsCpuCaching);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenProperValuesSet) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenProperValuesSet) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(0);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -146,7 +149,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenP
EXPECT_EQ(handle, testValueGemCreate);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroThenProperValuesSet) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroThenProperValuesSet) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(0);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -176,7 +179,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroTh
EXPECT_EQ(handle, testValueGemCreate);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenProperValuesSet) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenProperValuesSet) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -206,7 +209,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenPro
EXPECT_EQ(handle, testValueGemCreate);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithRegionsAndCoherencyThenUncachedCPUCachingIsUsed) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithRegionsAndCoherencyThenUncachedCPUCachingIsUsed) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -225,7 +228,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithRegionsAndCohe
EXPECT_EQ(DRM_XE_GEM_CPU_CACHING_WC, drm->createParamsCpuCaching);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithOnlySystemRegionAndCoherencyThenWriteBackCPUCachingIsUsed) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithOnlySystemRegionAndCoherencyThenWriteBackCPUCachingIsUsed) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(0);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -244,7 +247,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateWithOnlySystemRegi
EXPECT_EQ(DRM_XE_GEM_CPU_CACHING_WB, drm->createParamsCpuCaching);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallSetGemTilingThenAlwaysTrue) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallSetGemTilingThenAlwaysTrue) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -257,7 +260,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallSetGemTilingThenAlwaysTrue) {
EXPECT_FALSE(drm->ioctlCalled);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGetGemTilingThenAlwaysTrue) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGetGemTilingThenAlwaysTrue) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -270,14 +273,14 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGetGemTilingThenAlwaysTrue) {
EXPECT_FALSE(drm->ioctlCalled);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeisVmBindPatIndexExtSupportedReturnsFalse) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeisVmBindPatIndexExtSupportedReturnsFalse) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
ASSERT_EQ(false, xeIoctlHelper->isVmBindPatIndexExtSupported());
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
@@ -448,7 +451,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
EXPECT_FALSE(xeIoctlHelper->getFabricLatency(fabricId, latency, bandwidth));
}
TEST(IoctlHelperXeTest, whenGettingFlagsForVmCreateThenPropertValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingFlagsForVmCreateThenPropertValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
@@ -463,7 +466,7 @@ TEST(IoctlHelperXeTest, whenGettingFlagsForVmCreateThenPropertValueIsReturned) {
EXPECT_EQ(static_cast<uint32_t>(DRM_XE_VM_CREATE_FLAG_LR_MODE), xeIoctlHelper->getFlagsForVmCreate(false, false, false));
}
TEST(IoctlHelperXeTest, whenGettingFlagsForVmBindThenPropertValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingFlagsForVmBindThenPropertValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
@@ -472,7 +475,7 @@ TEST(IoctlHelperXeTest, whenGettingFlagsForVmBindThenPropertValueIsReturned) {
EXPECT_EQ(static_cast<uint64_t>(0), xeIoctlHelper->getFlagsForVmBind(false, false, false, false, false));
}
TEST(IoctlHelperXeTest, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
@@ -497,7 +500,7 @@ TEST(IoctlHelperXeTest, whenGettingIoctlRequestValueThenPropertValueIsReturned)
verifyIoctlRequestValue(DRM_IOCTL_PRIME_HANDLE_TO_FD, DrmIoctl::primeHandleToFd);
}
TEST(IoctlHelperXeTest, verifyPublicFunctions) {
TEST_F(IoctlHelperXeTest, verifyPublicFunctions) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
@@ -571,7 +574,7 @@ TEST(IoctlHelperXeTest, verifyPublicFunctions) {
EXPECT_EQ(0, queryItem.length);
}
TEST(IoctlHelperXeTest, whenGettingFileNamesForFrequencyThenProperStringIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingFileNamesForFrequencyThenProperStringIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -581,7 +584,7 @@ TEST(IoctlHelperXeTest, whenGettingFileNamesForFrequencyThenProperStringIsReturn
EXPECT_STREQ("/device/tile1/gt2/freq0/rp0_freq", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
}
TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
int ret;
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -732,7 +735,7 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
drm->reset();
}
TEST(IoctlHelperXeTest, givenUnknownTopologyTypeWhenGetTopologyDataAndMapThenNotRecognizedTopologyIsIgnored) {
TEST_F(IoctlHelperXeTest, givenUnknownTopologyTypeWhenGetTopologyDataAndMapThenNotRecognizedTopologyIsIgnored) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -785,7 +788,7 @@ TEST(IoctlHelperXeTest, givenUnknownTopologyTypeWhenGetTopologyDataAndMapThenNot
}
}
TEST(IoctlHelperXeTest, givenVariousDssConfigInputsWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, givenVariousDssConfigInputsWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -836,7 +839,7 @@ TEST(IoctlHelperXeTest, givenVariousDssConfigInputsWhenGetTopologyDataAndMapThen
}
}
TEST(IoctlHelperXeTest, givenOnlyMediaTypeWhenGetTopologyDataAndMapThenSubsliceIndicesNotSet) {
TEST_F(IoctlHelperXeTest, givenOnlyMediaTypeWhenGetTopologyDataAndMapThenSubsliceIndicesNotSet) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -884,7 +887,7 @@ TEST(IoctlHelperXeTest, givenOnlyMediaTypeWhenGetTopologyDataAndMapThenSubsliceI
ASSERT_EQ(0u, topologyMap[tileId].subsliceIndices.size());
}
TEST(IoctlHelperXeTest, givenMainAndMediaTypesWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, givenMainAndMediaTypesWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -963,7 +966,7 @@ TEST(IoctlHelperXeTest, givenMainAndMediaTypesWhenGetTopologyDataAndMapThenResul
}
}
TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1021,7 +1024,7 @@ TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResu
}
}
TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1089,7 +1092,7 @@ TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopo
}
}
TEST(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1152,7 +1155,7 @@ TEST(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopolog
}
}
TEST(IoctlHelperXeTest, givenMissingDssGeometryOrDssComputeInTopologyWhenGetTopologyDataAndMapThenReturnFalse) {
TEST_F(IoctlHelperXeTest, givenMissingDssGeometryOrDssComputeInTopologyWhenGetTopologyDataAndMapThenReturnFalse) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1178,7 +1181,7 @@ TEST(IoctlHelperXeTest, givenMissingDssGeometryOrDssComputeInTopologyWhenGetTopo
EXPECT_TRUE(result);
}
TEST(IoctlHelperXeTest, givenMissingEuPerDssInTopologyWhenGetTopologyDataAndMapThenSetupEuCountToZeroAndReturnTrue) {
TEST_F(IoctlHelperXeTest, givenMissingEuPerDssInTopologyWhenGetTopologyDataAndMapThenSetupEuCountToZeroAndReturnTrue) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1215,7 +1218,7 @@ TEST(IoctlHelperXeTest, givenMissingEuPerDssInTopologyWhenGetTopologyDataAndMapT
EXPECT_EQ(0, topologyData.maxEusPerSubSlice);
}
TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) {
TEST_F(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1337,7 +1340,7 @@ TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) {
}
}
TEST(IoctlHelperXeTest, whenCreatingMemoryInfoThenProperMemoryBanksAreDiscovered) {
TEST_F(IoctlHelperXeTest, whenCreatingMemoryInfoThenProperMemoryBanksAreDiscovered) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -1378,7 +1381,7 @@ TEST(IoctlHelperXeTest, whenCreatingMemoryInfoThenProperMemoryBanksAreDiscovered
EXPECT_EQ(2 * MemoryConstants::gigaByte - MemoryConstants::megaByte, memoryRegions[1].unallocatedSize);
}
TEST(IoctlHelperXeTest, givenXeDrmMemoryManagerWhenGetLocalMemorySizeIsCalledThenReturnMemoryRegionSizeCorrectly) {
TEST_F(IoctlHelperXeTest, givenXeDrmMemoryManagerWhenGetLocalMemorySizeIsCalledThenReturnMemoryRegionSizeCorrectly) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
@@ -1417,7 +1420,7 @@ TEST(IoctlHelperXeTest, givenXeDrmMemoryManagerWhenGetLocalMemorySizeIsCalledThe
EXPECT_EQ(memoryManager.getLocalMemorySize(0, tileMask), lmemSizes[1]);
}
TEST(IoctlHelperXeTest, givenIoctlFailureWhenCreatingMemoryInfoThenNoMemoryBanksAreDiscovered) {
TEST_F(IoctlHelperXeTest, givenIoctlFailureWhenCreatingMemoryInfoThenNoMemoryBanksAreDiscovered) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1429,7 +1432,7 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenCreatingMemoryInfoThenNoMemoryBanks
EXPECT_EQ(nullptr, memoryInfo);
}
TEST(IoctlHelperXeTest, givenNoMemoryRegionsWhenCreatingMemoryInfoThenMemoryInfoIsNotCreated) {
TEST_F(IoctlHelperXeTest, givenNoMemoryRegionsWhenCreatingMemoryInfoThenMemoryInfoIsNotCreated) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1442,7 +1445,7 @@ TEST(IoctlHelperXeTest, givenNoMemoryRegionsWhenCreatingMemoryInfoThenMemoryInfo
EXPECT_EQ(nullptr, memoryInfo);
}
TEST(IoctlHelperXeTest, givenIoctlFailureWhenCreatingEngineInfoThenNoEnginesAreDiscovered) {
TEST_F(IoctlHelperXeTest, givenIoctlFailureWhenCreatingEngineInfoThenNoEnginesAreDiscovered) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1454,7 +1457,7 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenCreatingEngineInfoThenNoEnginesAreD
EXPECT_EQ(nullptr, engineInfo);
}
TEST(IoctlHelperXeTest, givenEnabledFtrMultiTileArchWhenCreatingEngineInfoThenMultiTileArchInfoIsProperlySet) {
TEST_F(IoctlHelperXeTest, givenEnabledFtrMultiTileArchWhenCreatingEngineInfoThenMultiTileArchInfoIsProperlySet) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
@@ -1475,7 +1478,7 @@ TEST(IoctlHelperXeTest, givenEnabledFtrMultiTileArchWhenCreatingEngineInfoThenMu
}
}
TEST(IoctlHelperXeTest, givenDisabledFtrMultiTileArchWhenCreatingEngineInfoThenMultiTileArchInfoIsNotSet) {
TEST_F(IoctlHelperXeTest, givenDisabledFtrMultiTileArchWhenCreatingEngineInfoThenMultiTileArchInfoIsNotSet) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
@@ -1573,7 +1576,7 @@ TEST_F(IoctlHelperXeFenceWaitTest, whenCallingVmBindThenWaitUserFenceIsCalled) {
}
}
TEST(IoctlHelperXeTest, givenVmBindWaitUserFenceTimeoutWhenCallingVmBindThenWaitUserFenceIsCalledWithSpecificTimeout) {
TEST_F(IoctlHelperXeTest, givenVmBindWaitUserFenceTimeoutWhenCallingVmBindThenWaitUserFenceIsCalledWithSpecificTimeout) {
DebugManagerStateRestore restorer;
debugManager.flags.VmBindWaitUserFenceTimeout.set(5000000000ll);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
@@ -1625,7 +1628,7 @@ TEST(IoctlHelperXeTest, givenVmBindWaitUserFenceTimeoutWhenCallingVmBindThenWait
}
}
TEST(IoctlHelperXeTest, whenGemVmBindFailsThenErrorIsPropagated) {
TEST_F(IoctlHelperXeTest, whenGemVmBindFailsThenErrorIsPropagated) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1653,7 +1656,7 @@ TEST(IoctlHelperXeTest, whenGemVmBindFailsThenErrorIsPropagated) {
EXPECT_EQ(0u, drm->waitUserFenceInputs.size());
}
TEST(IoctlHelperXeTest, whenUserFenceFailsThenErrorIsPropagated) {
TEST_F(IoctlHelperXeTest, whenUserFenceFailsThenErrorIsPropagated) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1679,7 +1682,7 @@ TEST(IoctlHelperXeTest, whenUserFenceFailsThenErrorIsPropagated) {
EXPECT_EQ(errorValue, xeIoctlHelper->vmUnbind(vmBindParams));
}
TEST(IoctlHelperXeTest, WhenSetupIpVersionIsCalledThenIpVersionIsCorrect) {
TEST_F(IoctlHelperXeTest, WhenSetupIpVersionIsCalledThenIpVersionIsCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1692,7 +1695,7 @@ TEST(IoctlHelperXeTest, WhenSetupIpVersionIsCalledThenIpVersionIsCorrect) {
EXPECT_EQ(config, hwInfo.ipVersion.value);
}
TEST(IoctlHelperXeTest, whenXeShowBindTableIsCalledThenBindLogsArePrinted) {
TEST_F(IoctlHelperXeTest, whenXeShowBindTableIsCalledThenBindLogsArePrinted) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1717,7 +1720,7 @@ TEST(IoctlHelperXeTest, whenXeShowBindTableIsCalledThenBindLogsArePrinted) {
EXPECT_NE(std::string::npos, output.find(expectedOutput2, expectedOutput1.size())) << output;
}
TEST(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenFalseIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenFalseIsReturned) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
@@ -1735,7 +1738,7 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenFalseIsRe
EXPECT_EQ(false, ret);
}
TEST(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenProperValuesAreSet) {
TEST_F(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenProperValuesAreSet) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
@@ -1761,7 +1764,7 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenProperVal
EXPECT_EQ(pGpuCpuTime.cpuTimeinNS, expectedTimestamp);
}
TEST(IoctlHelperXeTest, whenDeviceTimestampWidthSetThenProperValuesAreSet) {
TEST_F(IoctlHelperXeTest, whenDeviceTimestampWidthSetThenProperValuesAreSet) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
@@ -1790,7 +1793,7 @@ TEST(IoctlHelperXeTest, whenDeviceTimestampWidthSetThenProperValuesAreSet) {
EXPECT_EQ(pGpuCpuTime.gpuTimeStamp, expectedCycles);
}
TEST(IoctlHelperXeTest, whenSetDefaultEngineIsCalledThenProperEngineIsSet) {
TEST_F(IoctlHelperXeTest, whenSetDefaultEngineIsCalledThenProperEngineIsSet) {
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>(&hwInfo);
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1807,7 +1810,7 @@ TEST(IoctlHelperXeTest, whenSetDefaultEngineIsCalledThenProperEngineIsSet) {
EXPECT_THROW(xeIoctlHelper->getDefaultEngineClass(aub_stream::EngineType::ENGINE_VECS), std::exception);
}
TEST(IoctlHelperXeTest, whenGettingPreemptionSupportThenTrueIsReturned) {
TEST_F(IoctlHelperXeTest, whenGettingPreemptionSupportThenTrueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1815,7 +1818,7 @@ TEST(IoctlHelperXeTest, whenGettingPreemptionSupportThenTrueIsReturned) {
EXPECT_TRUE(xeIoctlHelper->isPreemptionSupported());
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenGetCpuCachingModeCalledThenCorrectValueIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenGetCpuCachingModeCalledThenCorrectValueIsReturned) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1837,7 +1840,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenGetCpuCachingModeCalledThenCorrect
EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false, false), DRM_XE_GEM_CPU_CACHING_WB);
}
TEST(IoctlHelperXeTest, whenCallingVmBindThenPatIndexIsSet) {
TEST_F(IoctlHelperXeTest, whenCallingVmBindThenPatIndexIsSet) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -1865,7 +1868,7 @@ TEST(IoctlHelperXeTest, whenCallingVmBindThenPatIndexIsSet) {
EXPECT_EQ(drm->vmBindInputs[0].bind.pat_index, expectedPatIndex);
}
TEST(IoctlHelperXeTest, whenBindingDrmContextWithoutVirtualEnginesThenProperEnginesAreSelected) {
TEST_F(IoctlHelperXeTest, whenBindingDrmContextWithoutVirtualEnginesThenProperEnginesAreSelected) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1889,7 +1892,7 @@ TEST(IoctlHelperXeTest, whenBindingDrmContextWithoutVirtualEnginesThenProperEngi
EXPECT_EQ(expectedGtId, ioctlHelper->contextParamEngine[0].gt_id);
}
TEST(IoctlHelperXeTest, whenBindingDrmContextWithVirtualEnginesThenProperEnginesAreSelected) {
TEST_F(IoctlHelperXeTest, whenBindingDrmContextWithVirtualEnginesThenProperEnginesAreSelected) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1923,7 +1926,7 @@ TEST(IoctlHelperXeTest, whenBindingDrmContextWithVirtualEnginesThenProperEngines
}
}
TEST(IoctlHelperXeTest, whenCallingGetResetStatsThenSuccessIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetResetStatsThenSuccessIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1938,7 +1941,7 @@ TEST(IoctlHelperXeTest, whenCallingGetResetStatsThenSuccessIsReturned) {
EXPECT_EQ(0, xeIoctlHelper->getResetStats(resetStats, nullptr, nullptr));
}
TEST(IoctlHelperXeTest, whenCallingGetStatusAndFlagsForResetStatsThenZeroIsReturned) {
TEST_F(IoctlHelperXeTest, whenCallingGetStatusAndFlagsForResetStatsThenZeroIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -1949,27 +1952,27 @@ TEST(IoctlHelperXeTest, whenCallingGetStatusAndFlagsForResetStatsThenZeroIsRetur
EXPECT_FALSE(ioctlHelper->validPageFault(0u));
}
TEST(IoctlHelperXeTest, whenInitializeThenProperHwInfoIsSet) {
TEST_F(IoctlHelperXeTest, whenInitializeThenProperHwInfoIsSet) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo();
hwInfo->platform.usDeviceID = 0;
hwInfo->platform.usRevId = 0;
hwInfo->platform.usDeviceID = defaultHwInfo->platform.usDeviceID + 1;
hwInfo->platform.usRevId = defaultHwInfo->platform.usRevId + 1;
hwInfo->capabilityTable.gpuAddressSpace = 0;
ioctlHelper->initialize();
EXPECT_EQ(drm->revId, hwInfo->platform.usRevId);
EXPECT_EQ(drm->devId, hwInfo->platform.usDeviceID);
EXPECT_EQ(defaultHwInfo->platform.usRevId, hwInfo->platform.usRevId);
EXPECT_EQ(defaultHwInfo->platform.usDeviceID, hwInfo->platform.usDeviceID);
EXPECT_EQ((1ull << 48) - 1, hwInfo->capabilityTable.gpuAddressSpace);
EXPECT_EQ(static_cast<uint32_t>(DrmMockXe::mockDefaultCxlType), hwInfo->capabilityTable.cxlType);
EXPECT_EQ(DrmMockXe::mockMaxExecQueuePriority, ioctlHelper->maxExecQueuePriority);
}
TEST(IoctlHelperXeTest, givenMultipleBindInfosWhenGemCloseIsCalledThenProperHandleIsTaken) {
TEST_F(IoctlHelperXeTest, givenMultipleBindInfosWhenGemCloseIsCalledThenProperHandleIsTaken) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2009,7 +2012,7 @@ TEST(IoctlHelperXeTest, givenMultipleBindInfosWhenGemCloseIsCalledThenProperHand
EXPECT_EQ(0ul, ioctlHelper->bindInfo.size());
}
TEST(IoctlHelperXeTest, givenMultipleBindInfosWhenVmBindIsCalledThenProperHandleIsTaken) {
TEST_F(IoctlHelperXeTest, givenMultipleBindInfosWhenVmBindIsCalledThenProperHandleIsTaken) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2072,7 +2075,7 @@ TEST(IoctlHelperXeTest, givenMultipleBindInfosWhenVmBindIsCalledThenProperHandle
ioctlHelper->bindInfo.clear();
}
TEST(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrectIndexIsUsedAndReturend) {
TEST_F(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrectIndexIsUsedAndReturend) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2087,7 +2090,7 @@ TEST(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrectI
EXPECT_EQ(2u, extIndex);
}
TEST(IoctlHelperXeTest, givenLowPriorityContextWhenCreatingDrmContextThenExtPropertyIsSetCorrectly) {
TEST_F(IoctlHelperXeTest, givenLowPriorityContextWhenCreatingDrmContextThenExtPropertyIsSetCorrectly) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -2103,7 +2106,7 @@ TEST(IoctlHelperXeTest, givenLowPriorityContextWhenCreatingDrmContextThenExtProp
EXPECT_EQ(0u, drm->execQueueProperties[0].value);
}
TEST(IoctlHelperXeTest, whenInitializeThenGtListDataIsQueried) {
TEST_F(IoctlHelperXeTest, whenInitializeThenGtListDataIsQueried) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2119,7 +2122,7 @@ TEST(IoctlHelperXeTest, whenInitializeThenGtListDataIsQueried) {
EXPECT_EQ(drm->queryGtList.size(), ioctlHelper->queryGtListData.size());
}
TEST(IoctlHelperXeTest, givenNoGtListDataWhenInitializeThenInitializationFails) {
TEST_F(IoctlHelperXeTest, givenNoGtListDataWhenInitializeThenInitializationFails) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2129,7 +2132,7 @@ TEST(IoctlHelperXeTest, givenNoGtListDataWhenInitializeThenInitializationFails)
EXPECT_FALSE(ioctlHelper->initialize());
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetFlagsForVmBindThenExpectedValueIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetFlagsForVmBindThenExpectedValueIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
@@ -2154,7 +2157,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetFlagsForVmBindThenExpect
}
}
TEST(IoctlHelperXeTest, whenGetFdFromVmExportIsCalledThenFalseIsReturned) {
TEST_F(IoctlHelperXeTest, whenGetFdFromVmExportIsCalledThenFalseIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2163,7 +2166,7 @@ TEST(IoctlHelperXeTest, whenGetFdFromVmExportIsCalledThenFalseIsReturned) {
EXPECT_FALSE(xeIoctlHelper->getFdFromVmExport(vmId, flags, &fd));
}
TEST(IoctlHelperXeTest, whenCheckingGpuHangThenBanPropertyIsQueried) {
TEST_F(IoctlHelperXeTest, whenCheckingGpuHangThenBanPropertyIsQueried) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -2178,7 +2181,7 @@ TEST(IoctlHelperXeTest, whenCheckingGpuHangThenBanPropertyIsQueried) {
EXPECT_TRUE(osContext.isHangDetected());
}
TEST(IoctlHelperXeVmBindTest, givenImmediateAndReadOnlyBindFlagsSupportedWhenGettingFlagsForVmBindThenCorrectFlagsAreReturned) {
TEST_F(IoctlHelperXeTest, givenImmediateAndReadOnlyBindFlagsSupportedWhenGettingFlagsForVmBindThenCorrectFlagsAreReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -2247,7 +2250,7 @@ struct DrmMockXeVmBind : public DrmMockXe {
DrmMockXeVmBind(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockXe(rootDeviceEnvironment) {}
};
TEST(IoctlHelperXeVmBindTest, whenInitializeIoctlHelperThenQueryPageFaultFlagsSupport) {
TEST_F(IoctlHelperXeTest, whenInitializeIoctlHelperThenQueryPageFaultFlagsSupport) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeVmBind::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -2260,7 +2263,7 @@ TEST(IoctlHelperXeVmBindTest, whenInitializeIoctlHelperThenQueryPageFaultFlagsSu
}
}
TEST(IoctlHelperXeVmBindTest, givenDeviceInFaultModeWhenInitializeIoctlHelperThenQueryFeaturesIsSuccessful) {
TEST_F(IoctlHelperXeTest, givenDeviceInFaultModeWhenInitializeIoctlHelperThenQueryFeaturesIsSuccessful) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXeVmBind::create(*executionEnvironment->rootDeviceEnvironments[0]);
drm->deviceIsInFaultMode = true;
@@ -2356,7 +2359,7 @@ TEST_F(IoctlHelperXeHwIpVersionTests, WhenSetupIpVersionIsCalledAndIoctlReturnsN
EXPECT_EQ(config, hwInfo.ipVersion.value);
}
TEST(IoctlHelperXeTest, givenIoctlHelperWhenSettingExtContextThenCallExternalIoctlFunction) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperWhenSettingExtContextThenCallExternalIoctlFunction) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperXe ioctlHelper{*drm};
@@ -2380,7 +2383,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperWhenSettingExtContextThenCallExternalIoc
EXPECT_TRUE(ioctlHelper.ioctl(DrmIoctl::getResetStats, &resetStats));
EXPECT_FALSE(ioctlCalled);
}
TEST(IoctlHelperXeTest, givenL3BankWhenGetTopologyDataAndMapThenResultsAreCorrect) {
TEST_F(IoctlHelperXeTest, givenL3BankWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
@@ -2405,7 +2408,7 @@ TEST(IoctlHelperXeTest, givenL3BankWhenGetTopologyDataAndMapThenResultsAreCorrec
EXPECT_EQ(12, topologyData.numL3Banks);
}
TEST(IoctlHelperXeTest, givenIoctlHelperWhenGettingFenceAddressThenReturnCorrectValue) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperWhenGettingFenceAddressThenReturnCorrectValue) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperXe ioctlHelper{*drm};
@@ -2418,7 +2421,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperWhenGettingFenceAddressThenReturnCorrect
EXPECT_EQ(osContext.getFenceAddr(0), fenceAddr);
}
TEST(IoctlHelperXeTest, givenIoctlWhenQueryDeviceParamsIsCalledThenFalseIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlWhenQueryDeviceParamsIsCalledThenFalseIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
@@ -2428,7 +2431,7 @@ TEST(IoctlHelperXeTest, givenIoctlWhenQueryDeviceParamsIsCalledThenFalseIsReturn
EXPECT_FALSE(xeIoctlHelper->queryDeviceParams(&moduleId, &serverType));
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchThenVmBindIsCalled) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchThenVmBindIsCalled) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
@@ -2456,7 +2459,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchThenVmBindIsCa
EXPECT_EQ(drm->vmBindInputs[0].bind.prefetch_mem_region_instance, targetMemoryRegion.memoryInstance);
}
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchOnSecondTileThenVmBindIsCalled) {
TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchOnSecondTileThenVmBindIsCalled) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
@@ -2484,7 +2487,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingSetVmPrefetchOnSecondTileTh
EXPECT_EQ(drm->vmBindInputs[0].bind.prefetch_mem_region_instance, targetMemoryRegion.memoryInstance);
}
TEST(IoctlHelperXeTest, givenIoctlFailureWhenCallingSetVmPrefetchThenFalseIsReturned) {
TEST_F(IoctlHelperXeTest, givenIoctlFailureWhenCallingSetVmPrefetchThenFalseIsReturned) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableLocalMemory.set(1);
@@ -2502,9 +2505,91 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenCallingSetVmPrefetchThenFalseIsRetu
EXPECT_EQ(0u, drm->vmBindInputs.size());
}
TEST(IoctlHelperXeTest, givenXeIoctlHelperWhenIsTimestampsRefreshEnabledCalledThenReturnTrue) {
TEST_F(IoctlHelperXeTest, givenXeIoctlHelperWhenIsTimestampsRefreshEnabledCalledThenReturnTrue) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
EXPECT_TRUE(xeIoctlHelper->isTimestampsRefreshEnabled());
}
TEST_F(IoctlHelperXeTest, whenIoctlFailsOnQueryConfigSizeThenQueryDeviceIdAndRevisionFails) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
return -1;
};
EXPECT_FALSE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
}
TEST_F(IoctlHelperXeTest, givenZeroConfigSizeWhenQueryDeviceIdAndRevisionThenFail) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
if (request == DRM_IOCTL_XE_DEVICE_QUERY) {
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
if (deviceQuery->query == DRM_XE_DEVICE_QUERY_CONFIG) {
deviceQuery->size = 0;
return 0;
}
}
return -1;
};
EXPECT_FALSE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
}
TEST_F(IoctlHelperXeTest, whenIoctlFailsOnQueryConfigThenQueryDeviceIdAndRevisionFails) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
if (request == DRM_IOCTL_XE_DEVICE_QUERY) {
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
if (deviceQuery->query == DRM_XE_DEVICE_QUERY_CONFIG) {
if (deviceQuery->data) {
return -1;
}
deviceQuery->size = 1;
return 0;
}
}
return -1;
};
EXPECT_FALSE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
}
TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionThenProperValuesAreSet) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
auto hwInfo = drm->getRootDeviceEnvironment().getMutableHardwareInfo();
static constexpr uint16_t mockDeviceId = 0x1234;
static constexpr uint16_t mockRevisionId = 0xB;
hwInfo->platform.usDeviceID = 0;
hwInfo->platform.usRevId = 0;
mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
if (request == DRM_IOCTL_XE_DEVICE_QUERY) {
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
if (deviceQuery->query == DRM_XE_DEVICE_QUERY_CONFIG) {
if (deviceQuery->data) {
struct drm_xe_query_config *config = reinterpret_cast<struct drm_xe_query_config *>(deviceQuery->data);
config->num_params = DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID + 1;
config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] = (static_cast<uint32_t>(mockRevisionId) << 16) | mockDeviceId;
} else {
deviceQuery->size = (DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID + 1) * sizeof(uint64_t);
}
return 0;
}
}
return -1;
};
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
EXPECT_EQ(mockDeviceId, hwInfo->platform.usDeviceID);
EXPECT_EQ(mockRevisionId, hwInfo->platform.usRevId);
}