fix: use alignment when allocate by linux kmd

Related-To: NEO-14082
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2025-07-11 12:34:43 +00:00
committed by Compute-Runtime-Automation
parent 1816068765
commit 12ab2131d8
2 changed files with 24 additions and 1 deletions

View File

@@ -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<Gmm>(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) {

View File

@@ -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<ProductHelper>();
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);