diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.inl b/shared/source/command_stream/tbx_command_stream_receiver_hw.inl index b4944869ad..70df725198 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.inl +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.inl @@ -85,7 +85,7 @@ bool TbxCommandStreamReceiverHw::isAllocTbxFaultable(GraphicsAllocati } auto allocType = gfxAlloc->getAllocationType(); - if (allocType == AllocationType::bufferHostMemory || allocType == AllocationType::timestampPacketTagBuffer) { + if (allocType == AllocationType::bufferHostMemory) { return true; } return false; diff --git a/shared/source/debug_settings/debug_settings_manager.h b/shared/source/debug_settings/debug_settings_manager.h index e4f7c9e96e..aec137f59f 100644 --- a/shared/source/debug_settings/debug_settings_manager.h +++ b/shared/source/debug_settings/debug_settings_manager.h @@ -198,7 +198,10 @@ class DebugSettingsManager : NEO::NonCopyableAndNonMovableClass { auto setCsr = flags.SetCommandStreamReceiver.get(); auto isTbxMode = (setCsr == static_cast(CommandStreamReceiverType::tbx)) || (setCsr == static_cast(CommandStreamReceiverType::tbxWithAub)); - auto isFaultManagerEnabledInEnvVars = flags.EnableTbxPageFaultManager.get(); + auto isFaultManagerEnabledInEnvVars = true; + if (flags.EnableTbxPageFaultManager.get() == 0) { + isFaultManagerEnabledInEnvVars = false; + } return isFaultManagerEnabledInEnvVars && isTbxMode; } diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 2c4e9dfd7c..69a33958d9 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -41,7 +41,7 @@ DECLARE_DEBUG_VARIABLE(bool, AUBDumpAllocsOnEnqueueSVMMemcpyOnly, false, "Force DECLARE_DEBUG_VARIABLE(bool, AUBDumpForceAllToLocalMemory, false, "Force placing every allocation in local memory address space") DECLARE_DEBUG_VARIABLE(bool, GenerateAubFilePerProcessId, true, "Generate aub file with process id") DECLARE_DEBUG_VARIABLE(bool, SetBufferHostMemoryAlwaysAubWritable, false, "Make buffer host memory allocation always uploaded to AUB/TBX") -DECLARE_DEBUG_VARIABLE(bool, EnableTbxPageFaultManager, false, "Enables experimental page fault manager for host buffers and some other alloc types, replaces SetBufferHostMemoryAlwaysAubWritable") +DECLARE_DEBUG_VARIABLE(int32_t, EnableTbxPageFaultManager, -1, "Enable/Disable TbxPageFaultManager, overrides SetBufferHostMemoryAlwaysAubWritable to false if enabled: default 1, 0 - disable, 1 - enable") /*DEBUG FLAGS*/ DECLARE_DEBUG_VARIABLE(bool, EnableSWTags, false, "Enable software tagging in batch buffer") diff --git a/shared/source/page_fault_manager/tbx_page_fault_manager.cpp b/shared/source/page_fault_manager/tbx_page_fault_manager.cpp index 6e9685248d..ec66d9537d 100644 --- a/shared/source/page_fault_manager/tbx_page_fault_manager.cpp +++ b/shared/source/page_fault_manager/tbx_page_fault_manager.cpp @@ -24,7 +24,7 @@ bool TbxPageFaultManager::verifyAndHandlePageFault(void *ptr, bool handleFault) if (allocPtr != nullptr) { auto faultData = memoryData[allocPtr]; if (faultData.domain == CpuPageFaultManager::AllocationDomain::gpu) { - this->allowCPUMemoryAccess(ptr, faultData.size); + this->allowCPUMemoryAccess(allocPtr, faultData.size); } } } diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 8041af38b6..97898d325f 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -36,7 +36,7 @@ AUBDumpAllocsOnEnqueueSVMMemcpyOnly = 0 AUBDumpForceAllToLocalMemory = 0 GenerateAubFilePerProcessId = 1 SetBufferHostMemoryAlwaysAubWritable = 0 -EnableTbxPageFaultManager = 0 +EnableTbxPageFaultManager = -1 EnableSWTags = 0 DumpSWTagsBXML = 0 ForceDeviceId = unk diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index 6dfe681c32..43322767a6 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -1303,7 +1303,7 @@ class MockTbxCsrForPageFaultTests : public MockTbxCsr { HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostWritesHostAllocThenAllocShouldBeDownloadedAndWritable) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1358,7 +1358,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostWritesHostAllocThenAllocShou HWTEST_F(TbxCommandStreamTests, givenTbxWithModeWhenHostBufferNotWritableAndProtectedThenDownloadShouldNotCrash) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1390,7 +1390,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxWithModeWhenHostBufferNotWritableAndProt HWTEST_F(TbxCommandStreamTests, givenAllocationWithNoDriverAllocatedCpuPtrThenIsAllocTbxFaultableShouldReturnFalse) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1417,7 +1417,7 @@ HWTEST_F(TbxCommandStreamTests, givenAllocationWithNoDriverAllocatedCpuPtrThenIs HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostReadsHostAllocThenAllocShouldBeDownloadedButNotWritable) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1466,7 +1466,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostReadsHostAllocThenAllocShoul HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHandleFaultFalseThenTbxFaultableTypesShouldNotBeHandled) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1510,7 +1510,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHandleFaultFalseThenTbxFaultable HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsDisabledThenIsAllocTbxFaultableShouldReturnFalse) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(false); + debugManager.flags.EnableTbxPageFaultManager.set(0); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1531,7 +1531,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsDisabledThenIs HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsNotAvailableThenIsAllocTbxFaultableShouldReturnFalse) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(false); + debugManager.flags.EnableTbxPageFaultManager.set(0); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); tbxCsr->tbxFaultManager.reset(nullptr); @@ -1574,7 +1574,7 @@ static constexpr std::array onceWritableAllocTypesForTbx{ HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerIsAvailableAndAllocIsTbxFaultableThenTbxFaultableTypesShouldReturnTrue) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); @@ -1590,7 +1590,7 @@ HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerI for (const auto &allocType : onceWritableAllocTypesForTbx) { gfxAlloc1->setAllocationType(allocType); - if (allocType == AllocationType::bufferHostMemory || allocType == AllocationType::timestampPacketTagBuffer) { + if (allocType == AllocationType::bufferHostMemory) { EXPECT_TRUE(tbxCsr->isAllocTbxFaultable(gfxAlloc1)); } } @@ -1603,7 +1603,7 @@ HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerI HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerIsAvailableAndAllocIsNotTbxFaultableThenTbxFaultableTypesShouldReturnFalse) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); - debugManager.flags.EnableTbxPageFaultManager.set(true); + debugManager.flags.EnableTbxPageFaultManager.set(1); std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); diff --git a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp index ed0d111fd3..d10a3e4ffc 100644 --- a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp +++ b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp @@ -514,7 +514,7 @@ TEST(DurationLogTest, givenDurationGetTimeStringThenTimeStringIsCorrect) { TEST(DebugSettingsManager, GivenTbxOrTbxWithAubCsrTypeAndTbxFaultsEnabledWhenCallingIsTbxMngrEnabledThenReturnTrue) { DebugManagerStateRestore restorer; - NEO::debugManager.flags.EnableTbxPageFaultManager.set(true); + NEO::debugManager.flags.EnableTbxPageFaultManager.set(1); NEO::debugManager.flags.SetCommandStreamReceiver.set(2); EXPECT_TRUE(NEO::debugManager.isTbxPageFaultManagerEnabled()); @@ -523,16 +523,25 @@ TEST(DebugSettingsManager, GivenTbxOrTbxWithAubCsrTypeAndTbxFaultsEnabledWhenCal EXPECT_TRUE(NEO::debugManager.isTbxPageFaultManagerEnabled()); } +TEST(DebugSettingsManager, GivenTbxOrTbxWithAubCsrTypeAndAllElseDefaultWhenCallingIsTbxMngrEnabledThenReturnTrue) { + DebugManagerStateRestore restorer; + NEO::debugManager.flags.SetCommandStreamReceiver.set(2); + EXPECT_TRUE(NEO::debugManager.isTbxPageFaultManagerEnabled()); + + NEO::debugManager.flags.SetCommandStreamReceiver.set(4); + EXPECT_TRUE(NEO::debugManager.isTbxPageFaultManagerEnabled()); +} + TEST(DebugSettingsManager, GivenTbxFaultsDisabledWhenCallingIsTbxMngrEnabledThenReturnFalse) { DebugManagerStateRestore restorer; - NEO::debugManager.flags.EnableTbxPageFaultManager.set(false); + NEO::debugManager.flags.EnableTbxPageFaultManager.set(0); EXPECT_FALSE(NEO::debugManager.isTbxPageFaultManagerEnabled()); } TEST(DebugSettingsManager, GivenHardwareOrHardwareWithAubCsrTypeAndTbxFaultsEnabledWhenCallingIsTbxMngrEnabledThenReturnFalse) { DebugManagerStateRestore restorer; - NEO::debugManager.flags.EnableTbxPageFaultManager.set(true); + NEO::debugManager.flags.EnableTbxPageFaultManager.set(1); NEO::debugManager.flags.SetCommandStreamReceiver.set(1); EXPECT_FALSE(NEO::debugManager.isTbxPageFaultManagerEnabled()); @@ -579,4 +588,4 @@ TEST(DebugSettingsManager, whenDebugVariableDoesntMatchScopeThenIgnoreIt) { EXPECT_EQ(0, debugManager.flags.ForceOCLVersion.get()); EXPECT_STREQ("default", debugManager.flags.ZE_AFFINITY_MASK.get().c_str()); } -} \ No newline at end of file +}