Skip to content

Commit 22e6e32

Browse files
refactor: Use helper to check platform support for KMD migration
Related-To: NEO-6465 Signed-off-by: Milczarek, Slawomir <[email protected]>
1 parent 7b207d5 commit 22e6e32

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

shared/source/os_interface/linux/drm_allocation.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "shared/source/os_interface/linux/drm_allocation.h"
99

1010
#include "shared/source/debug_settings/debug_settings_manager.h"
11+
#include "shared/source/execution_environment/root_device_environment.h"
1112
#include "shared/source/helpers/basic_math.h"
1213
#include "shared/source/memory_manager/residency.h"
1314
#include "shared/source/os_interface/linux/cache_info.h"
@@ -17,6 +18,7 @@
1718
#include "shared/source/os_interface/linux/ioctl_helper.h"
1819
#include "shared/source/os_interface/linux/os_context_linux.h"
1920
#include "shared/source/os_interface/os_context.h"
21+
#include "shared/source/os_interface/product_helper.h"
2022

2123
#include <sstream>
2224

@@ -334,9 +336,12 @@ bool DrmAllocation::shouldAllocationPageFault(const Drm *drm) {
334336
return DebugManager.flags.EnableImplicitMigrationOnFaultableHardware.get();
335337
}
336338

339+
auto &productHelper = drm->getRootDeviceEnvironment().getHelper<ProductHelper>();
340+
auto isKmdMigrationSupported = productHelper.isKmdMigrationSupported();
341+
337342
switch (this->allocationType) {
338343
case AllocationType::UNIFIED_SHARED_MEMORY:
339-
return DebugManager.flags.UseKmdMigration.get() > 0;
344+
return (DebugManager.flags.UseKmdMigration.get() == -1) ? isKmdMigrationSupported : DebugManager.flags.UseKmdMigration.get();
340345
case AllocationType::BUFFER:
341346
return DebugManager.flags.UseKmdMigrationForBuffers.get() > 0;
342347
default:

shared/test/unit_test/os_interface/linux/drm_vm_bind_prelim_tests.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "shared/source/execution_environment/execution_environment.h"
99
#include "shared/source/execution_environment/root_device_environment.h"
1010
#include "shared/source/os_interface/linux/os_context_linux.h"
11+
#include "shared/source/os_interface/product_helper.h"
1112
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1213
#include "shared/test/common/helpers/engine_descriptor_helper.h"
1314
#include "shared/test/common/libult/linux/drm_query_mock.h"
@@ -121,3 +122,27 @@ TEST(DrmVmBindTest, givenUseKmdMigrationWhenCallingBindBoOnUnifiedSharedMemoryTh
121122
EXPECT_FALSE(bo.isExplicitResidencyRequired());
122123
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
123124
}
125+
126+
TEST(DrmVmBindTest, givenDefaultDriverSettingsWhenCallingBindBoOnUnifiedSharedMemoryThenMarkAllocationShouldPageFaultWhenKmdMigrationIsSupported) {
127+
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
128+
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
129+
executionEnvironment->initializeMemoryManager();
130+
131+
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
132+
drm.pageFaultSupported = true;
133+
134+
OsContextLinux osContext(drm, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
135+
osContext.ensureContextInitialized();
136+
uint32_t vmHandleId = 0;
137+
138+
MockBufferObject bo(0u, &drm, 3, 0, 0, 1);
139+
MockDrmAllocation allocation(0u, AllocationType::UNIFIED_SHARED_MEMORY, MemoryPool::LocalMemory);
140+
allocation.bufferObjects[0] = &bo;
141+
142+
allocation.bindBO(&bo, &osContext, vmHandleId, nullptr, true);
143+
144+
auto &productHelper = drm.getRootDeviceEnvironment().getHelper<ProductHelper>();
145+
auto isKmdMigrationSupported = productHelper.isKmdMigrationSupported();
146+
147+
EXPECT_EQ(isKmdMigrationSupported, allocation.shouldAllocationPageFault(&drm));
148+
}

0 commit comments

Comments
 (0)