refactor: Gate shared system mem caps with KMD cap

If KMD not capable then set sharedSystemAllocCapabilities=0

Related-To: NEO-12988

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski
2025-05-16 18:59:54 +00:00
committed by Compute-Runtime-Automation
parent 0e0cf3f742
commit 468c62086e
17 changed files with 77 additions and 33 deletions

View File

@@ -37,13 +37,15 @@ TEST(PrefetchManagerTests, givenPrefetchManagerWhenCallingInterfaceFunctionsThen
auto &hwInfo = *device->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
auto svmData = svmManager->getSVMAlloc(ptr);
ASSERT_NE(nullptr, svmData);
auto ptr2 = malloc(1024);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
EXPECT_EQ(0u, prefetchContext.allocations.size());
prefetchManager->insertAllocation(prefetchContext, *svmManager.get(), *device, ptr, 4096);

View File

@@ -336,10 +336,12 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenSharedSystemAllocationWhenPrefetchMemor
auto &hwInfo = *device->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
csr->setupContext(*device->getDefaultEngine().osContext);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
auto ptr = malloc(4096);
EXPECT_NE(nullptr, ptr);

View File

@@ -9,6 +9,7 @@
#include "shared/source/os_interface/linux/memory_info.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/source/unified_memory/usm_memory_support.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
@@ -2805,6 +2806,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirror
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
EXPECT_TRUE(drm->isSharedSystemAllocEnabled());
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
drm->adjustSharedSystemMemCapabilities();
EXPECT_EQ(caps, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
EXPECT_TRUE(drm->hasPageFaultSupport());
}
@@ -2858,6 +2863,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndConfigFlagHasGpuAddrMir
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
EXPECT_FALSE(drm->isSharedSystemAllocEnabled());
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
drm->adjustSharedSystemMemCapabilities();
EXPECT_EQ(0lu, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
}
TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndSharedSystemUsmSupportDebugFlagClearThenSharedSystemAllocEnableFalse) {
@@ -2884,6 +2893,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndSharedSystemUsmSupportD
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
EXPECT_FALSE(drm->isSharedSystemAllocEnabled());
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
drm->adjustSharedSystemMemCapabilities();
EXPECT_EQ(0lu, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
EXPECT_FALSE(drm->hasPageFaultSupport());
}

View File

@@ -71,18 +71,26 @@ HWTEST_F(ProductHelperTest, givenDebugFlagSetWhenAskingForHostMemCapabilitesThen
HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingSharedSystemMemCapabilitiesThenCorrectValueIsReturned) {
DebugManagerStateRestore restore;
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
pInHwInfo.capabilityTable.sharedSystemMemCapabilities = caps;
for (auto enable : {-1, 0, 1}) {
debugManager.flags.EnableSharedSystemUsmSupport.set(enable);
if (enable > 0) {
auto caps = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess;
EXPECT_EQ(caps, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
} else {
if (enable != 1) {
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
} else {
for (auto pf_enable : {-1, 0, 1}) {
debugManager.flags.EnableRecoverablePageFaults.set(pf_enable);
if (pf_enable != 0) {
EXPECT_EQ(caps, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
} else {
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
}
}
}
}
pInHwInfo.capabilityTable.sharedSystemMemCapabilities = caps;
}
HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedIfIsBlitSplitEnqueueWARequiredThenReturnFalse) {