mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Use ioctl helper when creating VM
Related-To: NEO-6999, NEO-6852 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e2991c3b13
commit
9938b4001d
@@ -92,6 +92,14 @@ int DrmMock::ioctl(DrmIoctl request, void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((request == DrmIoctl::GemVmCreate) && (arg != nullptr)) {
|
||||
ioctlCount.gemVmCreate++;
|
||||
auto gemVmControl = static_cast<GemVmControl *>(arg);
|
||||
receivedGemVmControl = *gemVmControl;
|
||||
gemVmControl->vmId = ++latestCreatedVmId;
|
||||
return storedRetValForVmCreate;
|
||||
}
|
||||
|
||||
if ((request == DrmIoctl::GemContextDestroy) && (arg != nullptr)) {
|
||||
ioctlCount.contextDestroy++;
|
||||
auto destroy = static_cast<GemContextDestroy *>(arg);
|
||||
|
||||
@@ -180,6 +180,7 @@ class DrmMock : public Drm {
|
||||
int storedRetValForPooledEU = 0;
|
||||
int storedRetValForMinEUinPool = 0;
|
||||
int storedRetValForPersistant = 0;
|
||||
int storedRetValForVmCreate = 0;
|
||||
int storedPreemptionSupport =
|
||||
I915_SCHEDULER_CAP_ENABLED |
|
||||
I915_SCHEDULER_CAP_PRIORITY |
|
||||
@@ -239,6 +240,9 @@ class DrmMock : public Drm {
|
||||
//DRM_IOCTL_GEM_CLOSE
|
||||
int storedRetValForGemClose = 0;
|
||||
|
||||
GemVmControl receivedGemVmControl{};
|
||||
uint32_t latestCreatedVmId = 0u;
|
||||
|
||||
uint64_t storedGTTSize = 1ull << 47;
|
||||
uint64_t storedParamSseu = ULONG_MAX;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class DrmQueryMock : public DrmMock {
|
||||
setupIoctlHelper(IGFX_UNKNOWN);
|
||||
|
||||
EXPECT_TRUE(queryMemoryInfo());
|
||||
EXPECT_EQ(2u, ioctlCallsCount);
|
||||
EXPECT_EQ(2u + virtualMemoryIds.size(), ioctlCallsCount);
|
||||
ioctlCallsCount = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ void Ioctls::reset() {
|
||||
gemCreate = 0;
|
||||
gemSetTiling = 0;
|
||||
gemGetTiling = 0;
|
||||
gemGetAperture = 0;
|
||||
gemVmCreate = 0;
|
||||
primeFdToHandle = 0;
|
||||
handleToPrimeFd = 0;
|
||||
gemMmap = 0;
|
||||
|
||||
@@ -40,7 +40,7 @@ class Ioctls {
|
||||
std::atomic<int32_t> gemCreate;
|
||||
std::atomic<int32_t> gemSetTiling;
|
||||
std::atomic<int32_t> gemGetTiling;
|
||||
std::atomic<int32_t> gemGetAperture;
|
||||
std::atomic<int32_t> gemVmCreate;
|
||||
std::atomic<int32_t> primeFdToHandle;
|
||||
std::atomic<int32_t> handleToPrimeFd;
|
||||
std::atomic<int32_t> gemMmap;
|
||||
|
||||
@@ -32,13 +32,8 @@ int closeFuncRetVal = 0;
|
||||
int dlOpenFlags = 0;
|
||||
bool dlOpenCalled = 0;
|
||||
constexpr int fakeFileDescriptor = 123;
|
||||
uint32_t vmId = 0;
|
||||
bool makeFakeDevicePath = false;
|
||||
bool allowFakeDevicePath = false;
|
||||
uint32_t ioctlVmCreateCalled = 0u;
|
||||
int ioctlVmCreateReturned = 0u;
|
||||
uint32_t vmFlags = 0u;
|
||||
uint64_t ioctlVmCreateExtensionArg = 0ull;
|
||||
constexpr unsigned long int invalidIoctl = static_cast<unsigned long int>(-1);
|
||||
int setErrno = 0;
|
||||
int fstatFuncRetVal = 0;
|
||||
@@ -48,6 +43,7 @@ uint32_t mmapFuncCalled = 0u;
|
||||
uint32_t munmapFuncCalled = 0u;
|
||||
bool isInvalidAILTest = false;
|
||||
const char *drmVersion = "i915";
|
||||
uint32_t ioctlVmDestroyCalled = 0u;
|
||||
|
||||
int (*sysCallsOpen)(const char *pathname, int flags) = nullptr;
|
||||
ssize_t (*sysCallsPread)(int fd, void *buf, size_t count, off_t offset) = nullptr;
|
||||
@@ -96,18 +92,9 @@ int ioctl(int fileDescriptor, unsigned long int request, void *arg) {
|
||||
memcpy_s(pVersion->name, pVersion->nameLen, drmVersion, std::min(pVersion->nameLen, strlen(drmVersion) + 1));
|
||||
}
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_VM_CREATE) {
|
||||
ioctlVmCreateCalled++;
|
||||
auto control = static_cast<GemVmControl *>(arg);
|
||||
ioctlVmCreateExtensionArg = control->extensions;
|
||||
control->vmId = ++vmId;
|
||||
vmFlags |= control->flags;
|
||||
return ioctlVmCreateReturned;
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_VM_DESTROY) {
|
||||
ioctlVmDestroyCalled++;
|
||||
auto control = static_cast<GemVmControl *>(arg);
|
||||
vmId--;
|
||||
vmFlags = 0;
|
||||
return (control->vmId > 0) ? 0 : -1;
|
||||
}
|
||||
if (request == invalidIoctl) {
|
||||
|
||||
@@ -21,5 +21,6 @@ extern int (*sysCallsPoll)(struct pollfd *pollFd, unsigned long int numberOfFds,
|
||||
extern ssize_t (*sysCallsRead)(int fd, void *buf, size_t count);
|
||||
|
||||
extern const char *drmVersion;
|
||||
extern uint32_t ioctlVmDestroyCalled;
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
@@ -37,6 +37,7 @@ TEST_F(DrmDebugTest, whenRegisterResourceClassesCalledThenTrueIsReturned) {
|
||||
TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
|
||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drmMock.ioctlCallsCount = 0;
|
||||
auto handle = drmMock.registerResource(DrmResourceClass::MaxSize, nullptr, 0);
|
||||
EXPECT_EQ(0u, handle);
|
||||
drmMock.unregisterResource(handle);
|
||||
@@ -46,6 +47,7 @@ TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
|
||||
TEST_F(DrmDebugTest, whenRegisterIsaCookieCalledThenImplementationIsEmpty) {
|
||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drmMock.ioctlCallsCount = 0;
|
||||
const uint32_t isaHandle = 2;
|
||||
auto handle = drmMock.registerIsaCookie(isaHandle);
|
||||
EXPECT_EQ(0u, handle);
|
||||
@@ -54,6 +56,7 @@ TEST_F(DrmDebugTest, whenRegisterIsaCookieCalledThenImplementationIsEmpty) {
|
||||
|
||||
TEST_F(DrmDebugTest, whenCheckingContextDebugSupportThenNoIoctlIsCalled) {
|
||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drmMock.ioctlCallsCount = 0;
|
||||
drmMock.checkContextDebugSupport();
|
||||
EXPECT_FALSE(drmMock.isContextDebugSupported());
|
||||
|
||||
@@ -62,6 +65,7 @@ TEST_F(DrmDebugTest, whenCheckingContextDebugSupportThenNoIoctlIsCalled) {
|
||||
|
||||
TEST_F(DrmDebugTest, whenNotifyCommandQueueCreateDestroyAreCalledThenImplementationsAreEmpty) {
|
||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drmMock.ioctlCallsCount = 0;
|
||||
|
||||
auto handle = drmMock.notifyFirstCommandQueueCreated();
|
||||
EXPECT_EQ(0u, handle);
|
||||
|
||||
@@ -19,7 +19,7 @@ TEST(DrmTest, whenQueryingEngineInfoThenSingleIoctlIsCalled) {
|
||||
EXPECT_NE(nullptr, drm);
|
||||
|
||||
drm->queryEngineInfo();
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(1u + drm->virtualMemoryIds.size(), drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST(EngineInfoTest, givenEngineInfoQuerySupportedWhenQueryingEngineInfoThenEngineInfoIsCreatedWithEngines) {
|
||||
@@ -32,7 +32,7 @@ TEST(EngineInfoTest, givenEngineInfoQuerySupportedWhenQueryingEngineInfoThenEngi
|
||||
{{0, 0}, 0, 0}};
|
||||
drm->memoryInfo.reset(new MemoryInfo(memRegions));
|
||||
drm->queryEngineInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(2u + drm->virtualMemoryIds.size(), drm->ioctlCallsCount);
|
||||
auto engineInfo = drm->getEngineInfo();
|
||||
|
||||
ASSERT_NE(nullptr, engineInfo);
|
||||
@@ -46,7 +46,7 @@ TEST(EngineInfoTest, whenQueryingEngineInfoWithoutMemoryInfoThenEngineInfoCreate
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
drm->queryEngineInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(2u + drm->virtualMemoryIds.size(), drm->ioctlCallsCount);
|
||||
auto engineInfo = drm->getEngineInfo();
|
||||
|
||||
ASSERT_NE(nullptr, engineInfo);
|
||||
|
||||
@@ -16,14 +16,6 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
extern uint32_t ioctlVmCreateCalled;
|
||||
extern int ioctlVmCreateReturned;
|
||||
extern uint64_t ioctlVmCreateExtensionArg;
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
TEST(MemoryInfoPrelim, givenMemoryRegionQueryNotSupportedWhenQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
@@ -106,19 +98,12 @@ struct DrmVmTestFixture {
|
||||
|
||||
drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0], testHwInfo);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
backupIoctlVmCreateCount = std::make_unique<VariableBackup<uint32_t>>(&NEO::SysCalls::ioctlVmCreateCalled, 0u);
|
||||
backupIoctlVmCreateReturn = std::make_unique<VariableBackup<int>>(&NEO::SysCalls::ioctlVmCreateReturned, 0u);
|
||||
backupIoctlVmCreateExtensionArg = std::make_unique<VariableBackup<uint64_t>>(&NEO::SysCalls::ioctlVmCreateExtensionArg, 0ull);
|
||||
}
|
||||
|
||||
void TearDown() {} // NOLINT(readability-identifier-naming)
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
|
||||
std::unique_ptr<VariableBackup<uint32_t>> backupIoctlVmCreateCount;
|
||||
std::unique_ptr<VariableBackup<int>> backupIoctlVmCreateReturn;
|
||||
std::unique_ptr<VariableBackup<uint64_t>> backupIoctlVmCreateExtensionArg;
|
||||
std::unique_ptr<DrmQueryMock> drm;
|
||||
|
||||
NEO::HardwareInfo *testHwInfo = nullptr;
|
||||
@@ -139,10 +124,11 @@ TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedWhenCreatingVirtualMemoryT
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(1u + tileCount, memoryInfo->getDrmRegionInfos().size());
|
||||
|
||||
drm->ioctlCount.reset();
|
||||
bool ret = drm->createVirtualMemoryAddressSpace(tileCount);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(tileCount, NEO::SysCalls::ioctlVmCreateCalled);
|
||||
EXPECT_NE(0ull, NEO::SysCalls::ioctlVmCreateExtensionArg);
|
||||
EXPECT_EQ(tileCount, drm->ioctlCount.gemVmCreate.load());
|
||||
EXPECT_NE(0ull, drm->receivedGemVmControl.extensions);
|
||||
}
|
||||
|
||||
TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedAndDebugKeyDisabledWhenCreatingVirtualMemoryThenVmCreatedNotUsingRegion) {
|
||||
@@ -157,16 +143,17 @@ TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedAndDebugKeyDisabledWhenCre
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(1u + tileCount, memoryInfo->getDrmRegionInfos().size());
|
||||
|
||||
drm->ioctlCount.reset();
|
||||
bool ret = drm->createVirtualMemoryAddressSpace(tileCount);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(tileCount, NEO::SysCalls::ioctlVmCreateCalled);
|
||||
EXPECT_EQ(0ull, NEO::SysCalls::ioctlVmCreateExtensionArg);
|
||||
EXPECT_EQ(tileCount, drm->ioctlCount.gemVmCreate.load());
|
||||
EXPECT_EQ(0ull, drm->receivedGemVmControl.extensions);
|
||||
}
|
||||
|
||||
TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedWhenCreatingVirtualMemoryFailsThenExpectDebugInformation) {
|
||||
NEO::DebugManager.flags.PrintDebugMessages.set(1);
|
||||
NEO::DebugManager.flags.EnableLocalMemory.set(1);
|
||||
NEO::SysCalls::ioctlVmCreateReturned = 1;
|
||||
drm->storedRetValForVmCreate = 1;
|
||||
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
@@ -177,11 +164,12 @@ TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedWhenCreatingVirtualMemoryF
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(1u + tileCount, memoryInfo->getDrmRegionInfos().size());
|
||||
|
||||
drm->ioctlCount.reset();
|
||||
testing::internal::CaptureStderr();
|
||||
bool ret = drm->createVirtualMemoryAddressSpace(tileCount);
|
||||
EXPECT_FALSE(ret);
|
||||
EXPECT_EQ(1u, NEO::SysCalls::ioctlVmCreateCalled);
|
||||
EXPECT_NE(0ull, NEO::SysCalls::ioctlVmCreateExtensionArg);
|
||||
EXPECT_EQ(1, drm->ioctlCount.gemVmCreate.load());
|
||||
EXPECT_NE(0ull, drm->receivedGemVmControl.extensions);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
auto pos = output.find("INFO: Cannot create Virtual Memory at memory bank");
|
||||
|
||||
@@ -25,6 +25,7 @@ TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemory
|
||||
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
drm->queryMemoryInfo();
|
||||
|
||||
@@ -41,6 +42,7 @@ TEST(MemoryInfo, givenMemoryRegionQueryNotSupportedWhenQueryingMemoryInfoThenMem
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
drm->i915QuerySuccessCount = 0;
|
||||
drm->queryMemoryInfo();
|
||||
@@ -56,6 +58,7 @@ TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreat
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
drm->queryMemoryRegionInfoSuccessCount = 0;
|
||||
drm->queryMemoryInfo();
|
||||
@@ -64,6 +67,7 @@ TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreat
|
||||
|
||||
drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
drm->i915QuerySuccessCount = 1;
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(nullptr, drm->getMemoryInfo());
|
||||
@@ -71,6 +75,7 @@ TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreat
|
||||
|
||||
drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
drm->queryMemoryRegionInfoSuccessCount = 1;
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(nullptr, drm->getMemoryInfo());
|
||||
@@ -215,6 +220,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
@@ -242,6 +248,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingle
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->ioctlCallsCount = 0;
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(drm.get(), 1, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
|
||||
@@ -9,21 +9,16 @@
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock_prelim_context.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
extern uint32_t vmFlags;
|
||||
extern uint64_t ioctlVmCreateExtensionArg;
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
TEST(DrmQueryTest, givenDirectSubmissionActiveWhenCreateDrmContextThenProperFlagIsSet) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
@@ -235,7 +230,7 @@ TEST(DrmBufferObjectTestPrelim, givenDisableScratchPagesWhenCreateDrmVirtualMemo
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
||||
EXPECT_TRUE(NEO::SysCalls::vmFlags & DrmPrelimHelper::getDisableScratchVmCreateFlag());
|
||||
EXPECT_TRUE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getDisableScratchVmCreateFlag());
|
||||
}
|
||||
|
||||
TEST(DrmBufferObjectTestPrelim, givenLocalMemoryDisabledWhenCreateDrmVirtualMemoryThenVmRegionExtensionIsNotPassed) {
|
||||
@@ -250,7 +245,7 @@ TEST(DrmBufferObjectTestPrelim, givenLocalMemoryDisabledWhenCreateDrmVirtualMemo
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
||||
EXPECT_EQ(NEO::SysCalls::ioctlVmCreateExtensionArg, 0ull);
|
||||
EXPECT_EQ(drm.receivedGemVmControl.extensions, 0ull);
|
||||
}
|
||||
|
||||
TEST(DrmBufferObjectTestPrelim, givenLocalMemoryEnabledWhenCreateDrmVirtualMemoryThenVmRegionExtensionIsPassed) {
|
||||
@@ -271,7 +266,7 @@ TEST(DrmBufferObjectTestPrelim, givenLocalMemoryEnabledWhenCreateDrmVirtualMemor
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
||||
EXPECT_NE(NEO::SysCalls::ioctlVmCreateExtensionArg, 0ull);
|
||||
EXPECT_NE(drm.receivedGemVmControl.extensions, 0ull);
|
||||
}
|
||||
|
||||
TEST(DrmBufferObjectTestPrelim, givenBufferObjectSetToColourWithBindWhenBindingThenSetProperAddressAndSize) {
|
||||
@@ -303,7 +298,7 @@ TEST(DrmBufferObjectTestPrelim, givenPageFaultNotSupportedWhenCallingCreateDrmVi
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
||||
EXPECT_FALSE(NEO::SysCalls::vmFlags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
EXPECT_FALSE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
|
||||
drm.destroyDrmVirtualMemory(vmId);
|
||||
}
|
||||
@@ -319,15 +314,19 @@ TEST(DrmBufferObjectTestPrelim, givenPageFaultSupportedWhenVmBindIsAvailableThen
|
||||
drm.bindAvailable = vmBindAvailable;
|
||||
|
||||
uint32_t vmId = 0;
|
||||
drm.ioctlCount.gemVmCreate = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
EXPECT_EQ(1, drm.ioctlCount.gemVmCreate.load());
|
||||
|
||||
if (drm.isVmBindAvailable()) {
|
||||
EXPECT_TRUE(NEO::SysCalls::vmFlags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
EXPECT_TRUE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
} else {
|
||||
EXPECT_FALSE(NEO::SysCalls::vmFlags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
EXPECT_FALSE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getEnablePageFaultVmCreateFlag());
|
||||
}
|
||||
|
||||
VariableBackup<uint32_t> ioctlCountBackup(&SysCalls::ioctlVmDestroyCalled, 0u);
|
||||
drm.destroyDrmVirtualMemory(vmId);
|
||||
EXPECT_EQ(1u, SysCalls::ioctlVmDestroyCalled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ TEST(DrmSystemInfoTest, whenQueryingSystemInfoThenSystemInfoIsNotCreatedAndIoctl
|
||||
EXPECT_FALSE(drm.querySystemInfo());
|
||||
|
||||
EXPECT_EQ(nullptr, drm.getSystemInfo());
|
||||
EXPECT_EQ(1u, drm.ioctlCallsCount);
|
||||
EXPECT_EQ(1u + drm.virtualMemoryIds.size(), drm.ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST(DrmSystemInfoTest, givenSystemInfoCreatedWhenQueryingSpecificAtrributesThenReturnZero) {
|
||||
@@ -98,7 +98,7 @@ TEST(DrmSystemInfoTest, whenQueryingSystemInfoThenSystemInfoIsCreatedAndReturnsN
|
||||
EXPECT_NE(0u, systemInfo->getMaxRCS());
|
||||
EXPECT_NE(0u, systemInfo->getMaxCCS());
|
||||
|
||||
EXPECT_EQ(2u, drm.ioctlCallsCount);
|
||||
EXPECT_EQ(2u + drm.virtualMemoryIds.size(), drm.ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST(DrmSystemInfoTest, givenSystemInfoCreatedFromDeviceBlobWhenQueryingSpecificAtrributesThenReturnCorrectValues) {
|
||||
|
||||
@@ -495,7 +495,9 @@ TEST(DrmTest, givenDrmWhenCreatingOsContextThenCreateDrmContextWithVmId) {
|
||||
OsContextLinux osContext(drmMock, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
|
||||
EXPECT_EQ(SysCalls::vmId, drmMock.getVirtualMemoryAddressSpace(0));
|
||||
drmMock.latestCreatedVmId = 0u;
|
||||
auto expectedVmId = drmMock.latestCreatedVmId + 1;
|
||||
EXPECT_EQ(expectedVmId, drmMock.getVirtualMemoryAddressSpace(0));
|
||||
|
||||
auto &contextIds = osContext.getDrmContextIds();
|
||||
EXPECT_EQ(1u, contextIds.size());
|
||||
@@ -682,6 +684,7 @@ TEST(DrmTest, givenPrintIoctlDebugFlagSetWhenGettingTimestampFrequencyThenCaptur
|
||||
testing::internal::CaptureStdout(); // start capturing
|
||||
|
||||
int ret = drm.getTimestampFrequency(frequency);
|
||||
DebugManager.flags.PrintIoctlEntries.set(false);
|
||||
std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing
|
||||
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
@@ -108,6 +108,7 @@ TEST(IoctlHelperPrelimTest, whenVmUnbindIsCalledThenProperValueIsReturnedBasedOn
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
@@ -135,12 +136,14 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPr
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCallIoctlThenProperIoctlRegistered) {
|
||||
GemContextCreateExt arg{};
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto ret = IoctlHelper::ioctl(drm.get(), DrmIoctl::GemContextCreateExt, &arg);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocThenReturnCorrectRegion) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto cacheRegion = ioctlHelper->closAlloc(drm.get());
|
||||
|
||||
@@ -150,7 +153,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocThenReturnCorrectRegio
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosAllocThenReturnNone) {
|
||||
drm->ioctlRetVal = -1;
|
||||
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto cacheRegion = ioctlHelper->closAlloc(drm.get());
|
||||
|
||||
@@ -160,6 +163,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosAll
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosFreeThenReturnCorrectRegion) {
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto cacheRegion = ioctlHelper->closFree(drm.get(), CacheRegion::Region2);
|
||||
|
||||
EXPECT_EQ(CacheRegion::Region2, cacheRegion);
|
||||
@@ -168,6 +172,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosFreeThenReturnCorrectRegion
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosFreeThenReturnNone) {
|
||||
drm->ioctlRetVal = -1;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto cacheRegion = ioctlHelper->closFree(drm.get(), CacheRegion::Region2);
|
||||
@@ -177,6 +182,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosFre
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocWaysThenReturnCorrectRegion) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto numWays = ioctlHelper->closAllocWays(drm.get(), CacheRegion::Region2, 3, 10);
|
||||
|
||||
@@ -186,6 +192,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocWaysThenReturnCorrectR
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosAllocWaysThenReturnNone) {
|
||||
drm->ioctlRetVal = -1;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto numWays = ioctlHelper->closAllocWays(drm.get(), CacheRegion::Region2, 3, 10);
|
||||
@@ -205,6 +212,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenWaitUserFenceThenCorrectValueRe
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemAdviseFailsThenDontUpdateMemAdviceFlags) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
drm->ioctlRetVal = -1;
|
||||
|
||||
MockBufferObject bo(drm.get(), 3, 0, 0, 1);
|
||||
@@ -222,6 +230,7 @@ TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemAdviseFailsThenDont
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemAdviseWithNonAtomicIsCalledThenUpdateTheCorrespondingVmAdviceForBufferObject) {
|
||||
MockBufferObject bo(drm.get(), 3, 0, 0, 1);
|
||||
drm->ioctlCallsCount = 0;
|
||||
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
|
||||
@@ -237,6 +246,7 @@ TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemAdviseWithNonAtomic
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenDrmAllocationWhenSetMemAdviseWithDevicePreferredLocationIsCalledThenUpdateTheCorrespondingVmAdviceForBufferObject) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
MockBufferObject bo(drm.get(), 3, 0, 0, 1);
|
||||
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
@@ -313,6 +323,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenQueryDistancesThenCorrectDistan
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoWithDeviceMemoryThenDistancesUsedAndMultileValuesSet) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
|
||||
@@ -343,6 +354,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoWithDeviceMemoryT
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoThenCorrectCCSFlagsSet) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
|
||||
@@ -358,6 +370,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoThenCorrectCCSFla
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenSysmanQueryEngineInfoThenAdditionalEnginesUsed) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
|
||||
@@ -378,6 +391,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenSysmanQueryEngineInfoThenAdditio
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoAndFailIoctlThenFalseReturned) {
|
||||
drm->ioctlCallsCount = 0;
|
||||
drm->queryDistanceIoctlRetVal = -1;
|
||||
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
@@ -396,6 +410,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoAndFailIoctlThenF
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateContextWithAccessCountersIsCalledThenErrorIsReturned) {
|
||||
drm->ioctlRetVal = EINVAL;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
GemContextCreateExt gcc{};
|
||||
@@ -405,6 +420,7 @@ TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateContextWithAccessCou
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlSuccessWhenCreateContextWithAccessCountersIsCalledThenSuccessIsReturned) {
|
||||
drm->ioctlRetVal = 0;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
GemContextCreateExt gcc{};
|
||||
@@ -414,6 +430,7 @@ TEST_F(IoctlHelperPrelimFixture, givenIoctlSuccessWhenCreateContextWithAccessCou
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateCooperativeContexIsCalledThenErrorIsReturned) {
|
||||
drm->ioctlRetVal = EINVAL;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
GemContextCreateExt gcc{};
|
||||
@@ -423,6 +440,7 @@ TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateCooperativeContexIsC
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlSuccessWhenCreateCooperativeContexIsCalledThenSuccessIsReturned) {
|
||||
drm->ioctlRetVal = 0u;
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
GemContextCreateExt gcc{};
|
||||
|
||||
@@ -41,6 +41,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
@@ -61,6 +62,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmMockProdDg1>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
@@ -83,6 +85,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1AndMemoryRegionQuerySupportedWhenQuerying
|
||||
|
||||
auto drm = std::make_unique<DrmMockProdDg1>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
|
||||
@@ -251,6 +251,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenQueryEngineInfoWithoutDeviceMemo
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0}};
|
||||
drm->memoryInfo.reset(new MemoryInfo(memRegions));
|
||||
@@ -270,6 +271,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenQueryEngineInfoWithDeviceMemoryA
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
drm->ioctlCallsCount = 0;
|
||||
std::vector<MemoryRegion> memRegions{
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
|
||||
|
||||
Reference in New Issue
Block a user