Align mmaped bo address properly

Change-Id: I010f6619821ad715bb6f0e9640be19943a45abd8
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2020-10-12 15:11:40 +02:00
committed by sys_ocldev
parent eb8f5fa301
commit 8892ee3f1f
6 changed files with 25 additions and 12 deletions

View File

@ -260,6 +260,9 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoWhenAllocateWithAlignment
auto allocation = memoryManager->allocateGraphicsMemoryWithAlignment(allocationData);
EXPECT_NE(allocation, nullptr);
EXPECT_NE(allocation->getMmapPtr(), nullptr);
EXPECT_NE(allocation->getMmapSize(), 0u);
EXPECT_EQ(allocation->getAllocationOffset(), 0u);
EXPECT_EQ(1u, mock->createExt.handle);
memoryManager->freeGraphicsMemory(allocation);

View File

@ -2805,14 +2805,16 @@ TEST_F(DrmMemoryManagerUSMHostAllocationTests, givenMmapPtrWhenFreeGraphicsMemor
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemClose = 1;
const size_t size = 16384;
AllocationData allocationData;
allocationData.size = 16384;
allocationData.size = size;
allocationData.rootDeviceIndex = rootDeviceIndex;
auto alloc = memoryManager->allocateGraphicsMemoryWithAlignment(allocationData);
EXPECT_NE(nullptr, alloc);
auto ptr = memoryManager->mmapFunction(0, alloc->getUnderlyingBufferSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0);
auto ptr = memoryManager->mmapFunction(0, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0);
static_cast<DrmAllocation *>(alloc)->setMmapPtr(ptr);
static_cast<DrmAllocation *>(alloc)->setMmapSize(size);
memoryManager->freeGraphicsMemoryImpl(alloc);
}