Delay releasing memory in createAllocWithAlignment

When padding memory is needed, store it and release only when
the related allocation is being released.

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2022-01-11 14:13:30 +00:00
committed by Compute-Runtime-Automation
parent 22588edf86
commit 429fa1fbdd
4 changed files with 37 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -964,9 +964,10 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsU
auto allocation = memoryManager->createAllocWithAlignment(allocationData, MemoryConstants::pageSize, MemoryConstants::pageSize64k, MemoryConstants::pageSize64k, 0u);
EXPECT_EQ(alignUp(reinterpret_cast<void *>(0x12345678), MemoryConstants::pageSize64k), allocation->getMmapPtr());
EXPECT_EQ(munmapCalledCount, 2u);
munmapCalledCount = 0u;
EXPECT_EQ(0u, munmapCalledCount);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(3u, munmapCalledCount);
munmapCalledCount = 0u;
}
HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsAlignedThenCreateAllocWithAlignmentUnmapOneUnalignedPart, NonDefaultIoctlsSupported) {
@ -1001,9 +1002,10 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsA
auto allocation = memoryManager->createAllocWithAlignment(allocationData, MemoryConstants::pageSize, 1u, MemoryConstants::pageSize64k, 0u);
EXPECT_EQ(reinterpret_cast<void *>(0x12345678), allocation->getMmapPtr());
EXPECT_EQ(munmapCalledCount, 1u);
munmapCalledCount = 0u;
EXPECT_EQ(0u, munmapCalledCount);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(2u, munmapCalledCount);
munmapCalledCount = 0u;
}
TEST_F(DrmMemoryManagerLocalMemoryTest, givenAllocationWithInvalidCacheRegionWhenAllocatingInDevicePoolThenReturnNullptr) {