Add isa cookie registration

Related-To: NEO-4552

Change-Id: I0a53deb92d19a2b6f2ce9385c17d82998d2a26d6
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-10-26 14:48:20 +01:00
committed by sys_ocldev
parent 5ab3e9966d
commit d380f6898c
6 changed files with 52 additions and 0 deletions

View File

@ -40,3 +40,14 @@ TEST(DrmTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
drmMock.unregisterResource(handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST(DrmTest, whenRegisterIsaCookieCalledThenImplementationIsEmpty) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
const uint32_t isaHandle = 2;
auto handle = drmMock.registerIsaCookie(isaHandle);
EXPECT_EQ(0u, handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}

View File

@ -4071,4 +4071,28 @@ TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenAllocationIsRegister
EXPECT_TRUE(bo.isMarkedForCapture());
}
TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenCookieIsAddedToBoHandle) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
drm.classHandles.push_back(i);
}
drm.registeredClass = Drm::ResourceClass::MaxSize;
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(2u, bo.bindExtHandles.size());
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
EXPECT_EQ(drm.currentCookie - 1, bo.bindExtHandles[1]);
allocation.freeRegisteredBOBindExtHandles(&drm);
EXPECT_EQ(2u, drm.unregisterCalledCount);
}
} // namespace NEO

View File

@ -235,6 +235,10 @@ class DrmMockResources : public DrmMock {
unregisteredHandle = handle;
}
uint32_t registerIsaCookie(uint32_t isaHanlde) override {
return currentCookie++;
}
static const uint32_t registerResourceReturnHandle;
uint32_t unregisteredHandle = 0;
@ -243,4 +247,5 @@ class DrmMockResources : public DrmMock {
bool registerClassesCalled = false;
uint64_t registeredData[128];
size_t registeredDataSize;
uint32_t currentCookie = 2;
};