fix: do not unregister shared allocation

Allocations imported from shared handle are not using registerAlloc in drm
manager but on free, unregister was called.

This could lead to problems with allocation size tracking.

This change will skip the unregisterAllocation call if allocation is
imported from shared handle.

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2024-10-02 14:47:22 +00:00
committed by Compute-Runtime-Automation
parent 14c8f1f15d
commit ac8dcdb298
4 changed files with 38 additions and 2 deletions

View File

@@ -3055,6 +3055,22 @@ TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIs
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIsCalledThenAllocationIsNotRegisteredNorUnregistered) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false,
false,
true,
executionEnvironment));
TestedDrmMemoryManager::OsHandleData osHandleData{1u};
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::sharedBuffer, false, {});
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
EXPECT_NE(nullptr, allocation);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(0u, memoryManager->registerSysMemAllocCalled);
EXPECT_EQ(0u, memoryManager->registerLocalMemAllocCalled);
EXPECT_EQ(0u, memoryManager->unregisterAllocationCalled);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEnabledValidateHostMemoryWhenPinBBAllocationFailsThenUnrecoverableIsCalled) {
this->mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<Drm>());
this->mock->reset();