refactor: read scratch page options during init
Change scratch page logic to initialize during Drm::create. Related-To: GSD-7742 Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
parent
fd47030ad6
commit
06faaab5bb
|
@ -106,6 +106,9 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
|
|||
|
||||
drm->queryAdapterBDF();
|
||||
|
||||
drm->configureScratchPagePolicy();
|
||||
drm->configureGpuFaultCheckThreshold();
|
||||
|
||||
return drm.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -1043,24 +1043,20 @@ bool Drm::hasKmdMigrationSupport() const {
|
|||
return kmdMigrationSupported;
|
||||
}
|
||||
|
||||
bool Drm::checkToDisableScratchPage() {
|
||||
std::call_once(checkToDisableScratchPageOnce, [this]() {
|
||||
if (debugManager.flags.DisableScratchPages.get() != -1) {
|
||||
disableScratch = !!debugManager.flags.DisableScratchPages.get();
|
||||
return;
|
||||
}
|
||||
const auto &productHelper = this->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
disableScratch = (productHelper.isDisableScratchPagesSupported() &&
|
||||
!rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled());
|
||||
});
|
||||
return disableScratch;
|
||||
void Drm::configureScratchPagePolicy() {
|
||||
if (debugManager.flags.DisableScratchPages.get() != -1) {
|
||||
disableScratch = !!debugManager.flags.DisableScratchPages.get();
|
||||
return;
|
||||
}
|
||||
const auto &productHelper = this->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
disableScratch = (productHelper.isDisableScratchPagesSupported() &&
|
||||
!rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled());
|
||||
}
|
||||
|
||||
unsigned int Drm::getGpuFaultCheckThreshold() const {
|
||||
void Drm::configureGpuFaultCheckThreshold() {
|
||||
if (debugManager.flags.GpuFaultCheckThreshold.get() != -1) {
|
||||
return debugManager.flags.GpuFaultCheckThreshold.get();
|
||||
gpuFaultCheckThreshold = debugManager.flags.GpuFaultCheckThreshold.get();
|
||||
}
|
||||
return 10u;
|
||||
}
|
||||
|
||||
unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType, bool engineInstancedDevice) {
|
||||
|
|
|
@ -167,8 +167,10 @@ class Drm : public DriverModel {
|
|||
MOCKABLE_VIRTUAL void queryPageFaultSupport();
|
||||
bool hasPageFaultSupport() const;
|
||||
bool hasKmdMigrationSupport() const;
|
||||
bool checkToDisableScratchPage();
|
||||
unsigned int getGpuFaultCheckThreshold() const;
|
||||
bool checkToDisableScratchPage() { return disableScratch; }
|
||||
unsigned int getGpuFaultCheckThreshold() const { return gpuFaultCheckThreshold; }
|
||||
void configureScratchPagePolicy();
|
||||
void configureGpuFaultCheckThreshold();
|
||||
|
||||
bool checkGpuPageFaultRequired() {
|
||||
return (checkToDisableScratchPage() && getGpuFaultCheckThreshold() != 0);
|
||||
|
@ -338,7 +340,6 @@ class Drm : public DriverModel {
|
|||
std::once_flag checkSetPairOnce;
|
||||
std::once_flag checkChunkingOnce;
|
||||
std::once_flag checkCompletionFenceOnce;
|
||||
std::once_flag checkToDisableScratchPageOnce;
|
||||
|
||||
RootDeviceEnvironment &rootDeviceEnvironment;
|
||||
|
||||
|
@ -357,6 +358,7 @@ class Drm : public DriverModel {
|
|||
bool completionFenceSupported = false;
|
||||
bool vmBindPatIndexProgrammingSupported = false;
|
||||
bool disableScratch = false;
|
||||
uint32_t gpuFaultCheckThreshold = 10u;
|
||||
|
||||
std::atomic<uint32_t> gpuFaultCheckCounter{0u};
|
||||
|
||||
|
|
|
@ -1155,7 +1155,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest,
|
|||
for (int gpuFaultCheckThreshold : {0, 10}) {
|
||||
debugManager.flags.DisableScratchPages.set(disableScratchPage);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(gpuFaultCheckThreshold);
|
||||
mock->disableScratch = disableScratchPage;
|
||||
mock->configureScratchPagePolicy();
|
||||
mock->configureGpuFaultCheckThreshold();
|
||||
|
||||
TestedDrmCommandStreamReceiver<FamilyType> *testedCsr =
|
||||
new TestedDrmCommandStreamReceiver<FamilyType>(GemCloseWorkerMode::gemCloseWorkerInactive,
|
||||
|
|
|
@ -7372,7 +7372,9 @@ TEST_F(DrmMemoryManagerTest, givenDrmAllocationWithDifferentScratchPageOptionsWh
|
|||
for (int gpuFaultCheckThreshold : {0, 10}) {
|
||||
debugManager.flags.DisableScratchPages.set(disableScratchPage);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(gpuFaultCheckThreshold);
|
||||
mock->disableScratch = disableScratchPage;
|
||||
|
||||
mock->configureScratchPagePolicy();
|
||||
mock->configureGpuFaultCheckThreshold();
|
||||
|
||||
mock->ioctlCnt.reset();
|
||||
mock->waitUserFenceCall.called = 0u;
|
||||
|
|
|
@ -300,6 +300,8 @@ TEST(DrmBufferObjectTestPrelim, givenDisableScratchPagesWhenCreateDrmVirtualMemo
|
|||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
@ -314,6 +316,8 @@ TEST(DrmBufferObjectPrelim, givenDebuggingEnabledWithoutDisableScratchPagesFlagS
|
|||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
@ -329,6 +333,8 @@ TEST(DrmBufferObjectTestPrelim, givenDisableScratchPagesAndDebuggingEnabledWhenC
|
|||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t vmId = 0;
|
||||
drm.createDrmVirtualMemory(vmId);
|
||||
|
|
|
@ -1430,6 +1430,8 @@ TEST(DrmDeathTest, GivenResetStatsWithValidFaultWhenIsGpuHangIsCalledThenProcess
|
|||
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
DrmMock drm{*executionEnvironment.rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
uint32_t contextId{0};
|
||||
EngineDescriptor engineDescriptor{EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular})};
|
||||
auto ioctlHelper = std::make_unique<MockIoctlHelperResetStats>(drm);
|
||||
|
@ -1460,6 +1462,8 @@ HWTEST2_F(DrmDisableScratchPagesDefaultTest,
|
|||
givenDefaultDisableScratchPagesThenCheckingGpuFaultCheckIsSetToDefaultValueAndScratchPageIsDisabled, IsPVC) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockCheckPageFault drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
EXPECT_TRUE(drm.checkToDisableScratchPage());
|
||||
EXPECT_EQ(10u, drm.getGpuFaultCheckThreshold());
|
||||
}
|
||||
|
@ -1468,6 +1472,8 @@ HWTEST2_F(DrmDisableScratchPagesDefaultTest,
|
|||
givenDefaultDisableScratchPagesThenCheckingGpuFaultCheckIsSetToDefaultAndScratchPageIsEnabled, IsNotPVC) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockCheckPageFault drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
EXPECT_FALSE(drm.checkToDisableScratchPage());
|
||||
EXPECT_EQ(10u, drm.getGpuFaultCheckThreshold());
|
||||
}
|
||||
|
@ -1484,24 +1490,32 @@ TEST(DrmTest, givenDisableScratchPagesWhenSettingGpuFaultCheckThresholdThenThesh
|
|||
debugManager.flags.DisableScratchPages.set(false);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(-1);
|
||||
DrmMockCheckPageFault drm1{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm1.configureScratchPagePolicy();
|
||||
drm1.configureGpuFaultCheckThreshold();
|
||||
EXPECT_FALSE(drm1.checkToDisableScratchPage());
|
||||
EXPECT_EQ(10u, drm1.getGpuFaultCheckThreshold());
|
||||
|
||||
debugManager.flags.DisableScratchPages.set(true);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(-1);
|
||||
DrmMockCheckPageFault drm2{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm2.configureScratchPagePolicy();
|
||||
drm2.configureGpuFaultCheckThreshold();
|
||||
EXPECT_TRUE(drm2.checkToDisableScratchPage());
|
||||
EXPECT_EQ(10u, drm2.getGpuFaultCheckThreshold());
|
||||
|
||||
debugManager.flags.DisableScratchPages.set(true);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(threshold);
|
||||
DrmMockCheckPageFault drm3{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm3.configureScratchPagePolicy();
|
||||
drm3.configureGpuFaultCheckThreshold();
|
||||
EXPECT_TRUE(drm3.checkToDisableScratchPage());
|
||||
EXPECT_EQ(threshold, drm3.getGpuFaultCheckThreshold());
|
||||
|
||||
debugManager.flags.DisableScratchPages.set(false);
|
||||
debugManager.flags.GpuFaultCheckThreshold.set(threshold);
|
||||
DrmMockCheckPageFault drm4{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm4.configureScratchPagePolicy();
|
||||
drm4.configureGpuFaultCheckThreshold();
|
||||
EXPECT_FALSE(drm4.checkToDisableScratchPage());
|
||||
EXPECT_EQ(threshold, drm4.getGpuFaultCheckThreshold());
|
||||
}
|
||||
|
@ -1532,6 +1546,8 @@ TEST(DrmTest, givenDisableScratchPagesSetWhenSettingGpuFaultCheckThresholdThenFa
|
|||
auto memoryManager = new MockDrmMemoryManagerCheckPageFault(GemCloseWorkerMode::gemCloseWorkerInactive, false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
auto &drm = *executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<DrmMock>();
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t contextId{0};
|
||||
EngineDescriptor engineDescriptor{EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular})};
|
||||
|
@ -1573,6 +1589,8 @@ TEST(DrmTest, givenDisableScratchPagesSetWhenSettingGpuFaultCheckThresholdToZero
|
|||
auto memoryManager = new MockDrmMemoryManagerCheckPageFault(GemCloseWorkerMode::gemCloseWorkerInactive, false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
auto &drm = *executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<DrmMock>();
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t contextId{0};
|
||||
EngineDescriptor engineDescriptor{EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular})};
|
||||
|
@ -1607,6 +1625,8 @@ TEST(DrmTest, whenNotDisablingScratchPagesThenFaultCheckingDoesNotHappen) {
|
|||
auto memoryManager = new MockDrmMemoryManagerCheckPageFault(GemCloseWorkerMode::gemCloseWorkerInactive, false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
auto &drm = *executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<DrmMock>();
|
||||
drm.configureScratchPagePolicy();
|
||||
drm.configureGpuFaultCheckThreshold();
|
||||
|
||||
uint32_t contextId{0};
|
||||
EngineDescriptor engineDescriptor{EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular})};
|
||||
|
|
Loading…
Reference in New Issue