Enforce 64KB alignment when mmaping GPU_TIMESTAMP_DEVICE_BUFFER

Related-To: LOCI-3866

Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
Spruit, Neil R
2023-01-12 20:08:12 +00:00
committed by Compute-Runtime-Automation
parent 01017a5df3
commit d1ee840ba5
2 changed files with 38 additions and 1 deletions

View File

@@ -823,6 +823,32 @@ TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingSharedHandleThenSucceeds)
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhichRequiresHostMapThenCorrectAlignmentReturned) {
mock->ioctl_expected.primeFdToHandle = 1;
mock->ioctl_expected.gemWait = 1;
mock->ioctl_expected.gemClose = 1;
mock->ioctl_expected.gemMmapOffset = 1;
osHandle handle = 1u;
this->mock->outputHandle = 2u;
size_t size = 4096u;
std::vector<MemoryRegion> regionInfo(1);
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
this->mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
this->mock->queryEngineInfo();
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, false, {});
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false);
DrmAllocation *drmAlloc = (DrmAllocation *)graphicsAllocation;
EXPECT_TRUE(isAligned<MemoryConstants::pageSize64k>(drmAlloc->getMmapPtr()));
memoryManager->closeSharedHandle(graphicsAllocation);
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
TEST_F(DrmMemoryManagerTest, GivenAllocationWhenFreeingThenSucceeds) {
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemWait = 1;