mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
refactor: Unify getters to check platform support for KMD migration
Related-To: NEO-6465 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d236bcbba9
commit
ac9a96c07f
@@ -336,12 +336,9 @@ bool DrmAllocation::shouldAllocationPageFault(const Drm *drm) {
|
||||
return DebugManager.flags.EnableImplicitMigrationOnFaultableHardware.get();
|
||||
}
|
||||
|
||||
auto &productHelper = drm->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
auto isKmdMigrationSupported = productHelper.isKmdMigrationSupported();
|
||||
|
||||
switch (this->allocationType) {
|
||||
case AllocationType::UNIFIED_SHARED_MEMORY:
|
||||
return (DebugManager.flags.UseKmdMigration.get() == -1) ? isKmdMigrationSupported : DebugManager.flags.UseKmdMigration.get();
|
||||
return drm->hasKmdMigrationSupport();
|
||||
case AllocationType::BUFFER:
|
||||
return DebugManager.flags.UseKmdMigrationForBuffers.get() > 0;
|
||||
default:
|
||||
|
||||
@@ -245,14 +245,8 @@ bool DrmMemoryManager::hasPageFaultsEnabled(const Device &neoDevice) {
|
||||
}
|
||||
|
||||
bool DrmMemoryManager::isKmdMigrationAvailable(uint32_t rootDeviceIndex) {
|
||||
const auto &productHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHelper<ProductHelper>();
|
||||
auto useKmdMigration = productHelper.isKmdMigrationSupported();
|
||||
|
||||
if (DebugManager.flags.UseKmdMigration.get() != -1) {
|
||||
useKmdMigration = DebugManager.flags.UseKmdMigration.get();
|
||||
}
|
||||
|
||||
return useKmdMigration;
|
||||
auto &drm = this->getDrm(rootDeviceIndex);
|
||||
return drm.hasKmdMigrationSupport();
|
||||
}
|
||||
|
||||
bool DrmMemoryManager::setMemAdvise(GraphicsAllocation *gfxAllocation, MemAdviseFlags flags, uint32_t rootDeviceIndex) {
|
||||
|
||||
@@ -1132,6 +1132,17 @@ bool Drm::hasPageFaultSupport() const {
|
||||
return pageFaultSupported;
|
||||
}
|
||||
|
||||
bool Drm::hasKmdMigrationSupport() const {
|
||||
const auto &productHelper = this->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
auto kmdMigrationSupported = hasPageFaultSupport() && productHelper.isKmdMigrationSupported();
|
||||
|
||||
if (DebugManager.flags.UseKmdMigration.get() != -1) {
|
||||
return !!DebugManager.flags.UseKmdMigration.get();
|
||||
}
|
||||
|
||||
return kmdMigrationSupported;
|
||||
}
|
||||
|
||||
unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType, bool engineInstancedDevice) {
|
||||
auto engineInfo = this->engineInfo.get();
|
||||
|
||||
|
||||
@@ -169,6 +169,7 @@ class Drm : public DriverModel {
|
||||
|
||||
MOCKABLE_VIRTUAL void queryPageFaultSupport();
|
||||
bool hasPageFaultSupport() const;
|
||||
bool hasKmdMigrationSupport() const;
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size);
|
||||
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
|
||||
|
||||
@@ -403,3 +403,39 @@ TEST(DrmQueryTest, givenEnableImplicitMigrationOnFaultableHardwareWhenShouldAllo
|
||||
MockDrmAllocation allocation(0u, AllocationType::BUFFER, MemoryPool::MemoryNull);
|
||||
EXPECT_TRUE(allocation.shouldAllocationPageFault(&drm));
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, givenUseKmdMigrationSetWhenCallingHasKmdMigrationSupportThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restorer;
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm.pageFaultSupported = true;
|
||||
|
||||
for (auto useKmdMigration : {-1, 0, 1}) {
|
||||
DebugManager.flags.UseKmdMigration.set(useKmdMigration);
|
||||
if (useKmdMigration == -1) {
|
||||
auto &productHelper = drm.getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
EXPECT_EQ(productHelper.isKmdMigrationSupported(), drm.hasKmdMigrationSupport());
|
||||
} else {
|
||||
EXPECT_EQ(useKmdMigration, drm.hasKmdMigrationSupport());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, givenKmdMigrationSupportedWhenShouldAllocationPageFaultIsCalledOnUnifiedSharedMemoryThenReturnTrue) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm.pageFaultSupported = true;
|
||||
|
||||
MockBufferObject bo(0u, &drm, 3, 0, 0, 1);
|
||||
MockDrmAllocation allocation(0u, AllocationType::UNIFIED_SHARED_MEMORY, MemoryPool::LocalMemory);
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
|
||||
EXPECT_EQ(drm.hasKmdMigrationSupport(), allocation.shouldAllocationPageFault(&drm));
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ TEST(DrmVmBindTest, givenUseKmdMigrationWhenCallingBindBoOnUnifiedSharedMemoryTh
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
}
|
||||
|
||||
TEST(DrmVmBindTest, givenDefaultDriverSettingsWhenCallingBindBoOnUnifiedSharedMemoryThenMarkAllocationShouldPageFaultWhenKmdMigrationIsSupported) {
|
||||
TEST(DrmVmBindTest, givenDrmWithPageFaultSupportWhenCallingBindBoOnUnifiedSharedMemoryThenMarkAllocationShouldPageFaultWhenKmdMigrationIsSupported) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
@@ -142,7 +142,15 @@ TEST(DrmVmBindTest, givenDefaultDriverSettingsWhenCallingBindBoOnUnifiedSharedMe
|
||||
allocation.bindBO(&bo, &osContext, vmHandleId, nullptr, true);
|
||||
|
||||
auto &productHelper = drm.getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
auto isKmdMigrationSupported = productHelper.isKmdMigrationSupported();
|
||||
auto kmdMigrationSupported = productHelper.isKmdMigrationSupported();
|
||||
|
||||
EXPECT_EQ(isKmdMigrationSupported, allocation.shouldAllocationPageFault(&drm));
|
||||
if (kmdMigrationSupported) {
|
||||
EXPECT_TRUE(allocation.shouldAllocationPageFault(&drm));
|
||||
EXPECT_FALSE(bo.isExplicitResidencyRequired());
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
} else {
|
||||
EXPECT_FALSE(allocation.shouldAllocationPageFault(&drm));
|
||||
EXPECT_TRUE(bo.isExplicitResidencyRequired());
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag() | DrmPrelimHelper::getMakeResidentVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user