Use nondefault rootDeviceIndex in DrmMemoryManagerWithExplicitExpectationTests

Related-To: NEO-4512
Change-Id: I5089980a705cfc0dfaaa54c9053458e7a86c2930
Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
Jablonski, Mateusz
2020-03-27 18:23:48 +01:00
committed by sys_ocldev
parent 441ff1fcdf
commit a409368fa3
4 changed files with 35 additions and 29 deletions

View File

@ -45,11 +45,11 @@ TestedDrmMemoryManager::TestedDrmMemoryManager(bool enableLocalMemory,
lseekCalledCount = 0;
}
void TestedDrmMemoryManager::injectPinBB(BufferObject *newPinBB) {
BufferObject *currentPinBB = pinBBs[0u];
pinBBs[0u] = nullptr;
void TestedDrmMemoryManager::injectPinBB(BufferObject *newPinBB, uint32_t rootDeviceIndex) {
BufferObject *currentPinBB = pinBBs[rootDeviceIndex];
pinBBs[rootDeviceIndex] = nullptr;
DrmMemoryManager::unreference(currentPinBB, true);
pinBBs[0u] = newPinBB;
pinBBs[rootDeviceIndex] = newPinBB;
}
DrmGemCloseWorker *TestedDrmMemoryManager::getgemCloseWorker() { return this->gemCloseWorker.get(); }

View File

@ -65,7 +65,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
bool allowForcePin,
bool validateHostPtrMemory,
ExecutionEnvironment &executionEnvironment);
void injectPinBB(BufferObject *newPinBB);
void injectPinBB(BufferObject *newPinBB, uint32_t rootDeviceIndex);
DrmGemCloseWorker *getgemCloseWorker();
void forceLimitedRangeAllocator(uint64_t range);

View File

@ -630,7 +630,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.execbuffer2 = 1;
MemoryManager::AllocationStatus result = memoryManager->populateOsHandles(storage, 0u);
MemoryManager::AllocationStatus result = memoryManager->populateOsHandles(storage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::InvalidHostPointer, result);
mock->testIoctls();
@ -640,7 +640,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
storage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(storage, 0);
memoryManager->cleanOsHandles(storage, rootDeviceIndex);
mock->ioctl_res_ext = &mock->NONE;
}
@ -778,7 +778,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.execbuffer2 = 1;
MemoryManager::AllocationStatus result = memoryManager->populateOsHandles(storage, 0u);
MemoryManager::AllocationStatus result = memoryManager->populateOsHandles(storage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::Error, result);
mock->testIoctls();
@ -788,7 +788,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
storage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(storage, 0);
memoryManager->cleanOsHandles(storage, rootDeviceIndex);
mock->ioctl_res_ext = &mock->NONE;
}
@ -2762,6 +2762,8 @@ TEST_F(DrmMemoryManagerBasic, DISABLED_givenMemoryManagerWith64KBPagesEnabledWhe
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEnabledValidateHostMemoryWhenPinBBAllocationFailsThenUnrecoverableIsCalled) {
this->mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->getDrm());
this->mock->reset();
this->mock->ioctl_res = -1;
this->mock->ioctl_expected.gemUserptr = 1;
EXPECT_THROW(
@ -2795,7 +2797,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
OsHandleStorage handleStorage;
handleStorage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
handleStorage.fragmentStorageData[0].fragmentSize = 4096;
auto result = memoryManager->populateOsHandles(handleStorage, 0u);
auto result = memoryManager->populateOsHandles(handleStorage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, result);
mock->testIoctls();
@ -2803,7 +2805,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
EXPECT_NE(nullptr, handleStorage.fragmentStorageData[0].osHandleStorage);
handleStorage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEnabledValidateHostMemoryWhenPopulateOsHandlesIsCalledWithFirstFragmentAlreadyAllocatedThenNewBosAreValidated) {
@ -2833,7 +2835,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
PinBufferObject *pinBB = new PinBufferObject(this->mock);
memoryManager->injectPinBB(pinBB);
memoryManager->injectPinBB(pinBB, rootDeviceIndex);
mock->reset();
mock->ioctl_expected.gemUserptr = 2;
@ -2853,7 +2855,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
handleStorage.fragmentStorageData[2].cpuPtr = reinterpret_cast<void *>(0x4000);
handleStorage.fragmentStorageData[2].fragmentSize = 4096;
auto result = memoryManager->populateOsHandles(handleStorage, 0u);
auto result = memoryManager->populateOsHandles(handleStorage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, result);
mock->testIoctls();
@ -2869,7 +2871,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
handleStorage.fragmentStorageData[1].freeTheFragment = true;
handleStorage.fragmentStorageData[2].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenValidateHostPtrMemoryEnabledWhenHostPtrAllocationIsCreatedWithoutForcingPinThenBufferObjectIsPinned) {
@ -2907,12 +2909,12 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
OsHandleStorage storage;
storage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
storage.fragmentStorageData[0].fragmentSize = 1;
auto result = memoryManager->populateOsHandles(storage, 0u);
auto result = memoryManager->populateOsHandles(storage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, result);
EXPECT_NE(nullptr, storage.fragmentStorageData[0].osHandleStorage);
storage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(storage, 0);
memoryManager->cleanOsHandles(storage, rootDeviceIndex);
}
TEST_F(DrmMemoryManagerTest, givenForcePinAndHostMemoryValidationEnabledWhenSmallAllocationIsCreatedThenBufferObjectIsPinned) {
@ -3127,7 +3129,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
handleStorage.fragmentStorageData[2].cpuPtr = reinterpret_cast<void *>(0x4000);
handleStorage.fragmentStorageData[2].fragmentSize = 4096;
auto result = memoryManager->populateOsHandles(handleStorage, 0u);
auto result = memoryManager->populateOsHandles(handleStorage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::InvalidHostPointer, result);
mock->testIoctls();
@ -3143,7 +3145,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
handleStorage.fragmentStorageData[1].freeTheFragment = true;
handleStorage.fragmentStorageData[2].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0u);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
mock->ioctl_res_ext = &mock->NONE;
}
@ -3177,7 +3179,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
handleStorage.fragmentStorageData[2].cpuPtr = reinterpret_cast<void *>(0x4000);
handleStorage.fragmentStorageData[2].fragmentSize = 4096;
auto result = memoryManager->populateOsHandles(handleStorage, 0u);
auto result = memoryManager->populateOsHandles(handleStorage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::InvalidHostPointer, result);
mock->testIoctls();
@ -3192,7 +3194,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
handleStorage.fragmentStorageData[1].freeTheFragment = true;
handleStorage.fragmentStorageData[2].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
mock->ioctl_res_ext = &mock->NONE;
}
@ -3213,7 +3215,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
handleStorage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
handleStorage.fragmentStorageData[0].fragmentSize = 4096;
auto result = memoryManager->populateOsHandles(handleStorage, 0u);
auto result = memoryManager->populateOsHandles(handleStorage, rootDeviceIndex);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, result);
mock->testIoctls();
@ -3223,7 +3225,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
EXPECT_NE(nullptr, hostPtrManager->getFragment(handleStorage.fragmentStorageData[0].cpuPtr));
handleStorage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCleanOsHandlesDeletesHandleDataThenOsHandleStorageAndResidencyIsSetToNullptr) {
@ -3244,7 +3246,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCl
handleStorage.fragmentStorageData[0].freeTheFragment = true;
handleStorage.fragmentStorageData[1].freeTheFragment = true;
memoryManager->cleanOsHandles(handleStorage, 0);
memoryManager->cleanOsHandles(handleStorage, rootDeviceIndex);
for (uint32_t i = 0; i < 2; i++) {
EXPECT_EQ(nullptr, handleStorage.fragmentStorageData[i].osHandleStorage);

View File

@ -120,18 +120,20 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
void SetUp() {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
mock = new DrmMockCustom();
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
for (auto &rootDeviceEnvironment : executionEnvironment->rootDeviceEnvironments) {
rootDeviceEnvironment->setHwInfo(defaultHwInfo.get());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom);
}
mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
ASSERT_NE(nullptr, memoryManager);
if (memoryManager->getgemCloseWorker()) {
memoryManager->getgemCloseWorker()->close(true);
}
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, rootDeviceIndex));
}
void TearDown() {
@ -141,5 +143,7 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
ExecutionEnvironment *executionEnvironment = nullptr;
std::unique_ptr<MockDevice> device;
DrmMockCustom::IoctlResExt ioctlResExt = {0, 0};
const uint32_t rootDeviceIndex = 1u;
const uint32_t numRootDevices = 2u;
};
} // namespace NEO