diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 4dbfa4afda..c47d7faf72 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -929,7 +929,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData & gmmRequirements.preferCompressed = allocationData.flags.preferCompressed; auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(); auto gmm = std::make_unique(gmmHelper, allocationData.hostPtr, - allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper, gmmHelper->getHardwareInfo()), systemMemoryStorageInfo, gmmRequirements); + allocationData.size, allocationData.alignment, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper, gmmHelper->getHardwareInfo()), systemMemoryStorageInfo, gmmRequirements); size_t bufferSize = allocationData.size; auto alignment = allocationData.alignment; if (bufferSize >= 2 * MemoryConstants::megaByte) { diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 8401c8dc48..051437f4c8 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -2080,6 +2080,29 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateG memoryManager->freeGraphicsMemory(allocation); } +HWTEST_TEMPLATED_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateByKmdThenAlignmentIsCorrect) { + mock->ioctlHelper.reset(new MockIoctlHelper(*mock)); + mock->queryMemoryInfo(); + + auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); + if (debugManager.flags.UseGemCreateExtInAllocateMemoryByKMD.get() == 0 || + !productHelper.useGemCreateExtInAllocateMemoryByKMD()) { + mock->ioctlExpected.gemCreate = 1; + } else { + mock->ioctlExpected.gemCreateExt = 1; + } + mock->ioctlExpected.gemWait = 1; + mock->ioctlExpected.gemClose = 1; + + allocationData.size = MemoryConstants::pageSize; + allocationData.alignment = 8388608; + auto allocation = memoryManager->allocateMemoryByKMD(allocationData); + auto gmm = allocation->getDefaultGmm(); + EXPECT_EQ(gmm->resourceParams.BaseAlignment, allocationData.alignment); + + memoryManager->freeGraphicsMemory(allocation); +} + HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenAllocateMemoryByKMDWhenPreferCompressedThenCompressionEnabled) { DebugManagerStateRestore restorer; debugManager.flags.RenderCompressedBuffersEnabled.set(true);