From 6175a3e78524f4f11e7cd2179e0f81b1f151c0ff Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Fri, 23 Sep 2022 14:13:06 +0000 Subject: [PATCH] Debug flag to force stateless mocs encryption bit Signed-off-by: Dunajski, Bartosz --- ...and_stream_receiver_flush_task_1_tests.cpp | 25 ++++++++++++++++--- .../debug_settings/debug_variables_base.inl | 1 + .../source/gen8/state_base_address_gen8.cpp | 2 ++ shared/source/gmm_helper/gmm_helper.cpp | 6 +++++ shared/source/gmm_helper/gmm_helper.h | 1 + .../helpers/state_base_address_base.inl | 2 ++ .../state_base_address_xehp_and_later.inl | 10 ++++++-- shared/test/common/test_files/igdrcl.config | 3 ++- 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 3b314c713d..aaf3216143 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -122,7 +122,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrInBatch mockCsr.getCS(1024u); auto &csrCommandStream = mockCsr.commandStream; - //we do level change that will emit PPC, fill all the space so only BB end fits. + // we do level change that will emit PPC, fill all the space so only BB end fits. taskLevel++; auto ppcSize = MemorySynchronizationCommands::getSizeForSingleBarrier(false); auto fillSize = MemoryConstants::cacheLineSize - ppcSize - sizeof(typename FamilyType::MI_BATCH_BUFFER_END); @@ -516,7 +516,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushAfterThenSend HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenStaleCqWhenFlushingTaskThenCompletionStampIsValid) { auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); - //simulate our CQ is stale for 10 TL's + // simulate our CQ is stale for 10 TL's commandStreamReceiver.taskLevel = taskLevel + 10; auto completionStamp = flushTask(commandStreamReceiver); @@ -574,6 +574,25 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, WhenFlushingTas EXPECT_EQ(stateHeapMocs, cmd.getInstructionMemoryObjectControlState()); } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenDebugVariableSetWhenProgrammingSbaThenSetStatelessMocsEncryptionBit) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + + DebugManagerStateRestore restorer; + DebugManager.flags.ForceStatelessMocsEncryptionBit.set(1); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + flushTask(commandStreamReceiver); + + auto &commandStreamCSR = commandStreamReceiver.commandStream; + parseCommands(commandStreamCSR, 0); + HardwareParse::findHardwareCommands(); + + ASSERT_NE(nullptr, cmdStateBaseAddress); + auto cmd = reinterpret_cast(cmdStateBaseAddress); + + EXPECT_EQ(1u, cmd->getStatelessDataPortAccessMemoryObjectControlState() & 1); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStateBaseAddressWhenItIsRequiredThenThereIsPipeControlPriorToItWithTextureCacheFlush) { typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS; auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); @@ -1072,7 +1091,7 @@ HWTEST_F(CommandStreamReceiverCQFlushTaskTests, WhenGettingCsThenReturnCsWithEno auto currentUsed = commandStream.getUsed(); EXPECT_EQ(0u, currentUsed % MemoryConstants::cacheLineSize); - //depending on the size of commands we may need whole additional cacheline for alignment + // depending on the size of commands we may need whole additional cacheline for alignment if (currentUsed != expectedSize) { EXPECT_EQ(expectedSize - MemoryConstants::cacheLineSize, currentUsed); } else { diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 5ee3e14a7a..af4f7fb4a3 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -219,6 +219,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideCmdListCmdBufferSizeInKb, -1, "-1: defau DECLARE_DEBUG_VARIABLE(int32_t, OverrideL1CachePolicyInSurfaceStateAndStateless, -1, "-1: default, >=0 : following policy will be programmed in render surface state (for regular buffers) and stateless L1 caching") DECLARE_DEBUG_VARIABLE(int32_t, PlaformSupportEvictIfNecessaryFlag, -1, "-1: default - platform specific, 0: disable, 1: enable") DECLARE_DEBUG_VARIABLE(int32_t, ForceEvictOnlyIfNecessaryFlag, -1, "-1: default - driver selects when to use, 0: force never use this flag, 1: force always use this flag") +DECLARE_DEBUG_VARIABLE(int32_t, ForceStatelessMocsEncryptionBit, -1, "-1: default - 1: set encryption bit") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") diff --git a/shared/source/gen8/state_base_address_gen8.cpp b/shared/source/gen8/state_base_address_gen8.cpp index d95a780bd3..e0473fd51d 100644 --- a/shared/source/gen8/state_base_address_gen8.cpp +++ b/shared/source/gen8/state_base_address_gen8.cpp @@ -64,6 +64,8 @@ void StateBaseAddressHelper::programStateBaseAddress( args.statelessMocsIndex = args.statelessMocsIndex << 1; + GmmHelper::applyMocsEncryptionBit(args.statelessMocsIndex); + args.stateBaseAddressCmd->setStatelessDataPortAccessMemoryObjectControlState(args.statelessMocsIndex); appendStateBaseAddressParameters(args, true); diff --git a/shared/source/gmm_helper/gmm_helper.cpp b/shared/source/gmm_helper/gmm_helper.cpp index f0eb11cef9..b1c8a368fa 100644 --- a/shared/source/gmm_helper/gmm_helper.cpp +++ b/shared/source/gmm_helper/gmm_helper.cpp @@ -38,6 +38,12 @@ uint32_t GmmHelper::getMOCS(uint32_t type) const { return static_cast(mocs.DwordValue); } +void GmmHelper::applyMocsEncryptionBit(uint32_t &index) { + if (DebugManager.flags.ForceStatelessMocsEncryptionBit.get() == 1) { + index |= 1; + } +} + GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hwInfo(pHwInfo) { auto hwInfoAddressWidth = Math::log2(hwInfo->capabilityTable.gpuAddressSpace + 1); addressWidth = std::max(hwInfoAddressWidth, 48u); diff --git a/shared/source/gmm_helper/gmm_helper.h b/shared/source/gmm_helper/gmm_helper.h index 8adeb09ad1..38cddb5b0d 100644 --- a/shared/source/gmm_helper/gmm_helper.h +++ b/shared/source/gmm_helper/gmm_helper.h @@ -22,6 +22,7 @@ class GmmHelper { const HardwareInfo *getHardwareInfo(); uint32_t getMOCS(uint32_t type) const; + static void applyMocsEncryptionBit(uint32_t &index); void forceAllResourcesUncached() { allResourcesUncached = true; }; static constexpr uint64_t maxPossiblePitch = (1ull << 31); diff --git a/shared/source/helpers/state_base_address_base.inl b/shared/source/helpers/state_base_address_base.inl index 32de5de3a3..d846779ce5 100644 --- a/shared/source/helpers/state_base_address_base.inl +++ b/shared/source/helpers/state_base_address_base.inl @@ -93,6 +93,8 @@ void StateBaseAddressHelper::programStateBaseAddress( args.statelessMocsIndex = args.statelessMocsIndex << 1; + GmmHelper::applyMocsEncryptionBit(args.statelessMocsIndex); + args.stateBaseAddressCmd->setStatelessDataPortAccessMemoryObjectControlState(args.statelessMocsIndex); appendStateBaseAddressParameters(args, overrideBindlessSurfaceStateBase); diff --git a/shared/source/helpers/state_base_address_xehp_and_later.inl b/shared/source/helpers/state_base_address_xehp_and_later.inl index 4240785b41..80f0738ed6 100644 --- a/shared/source/helpers/state_base_address_xehp_and_later.inl +++ b/shared/source/helpers/state_base_address_xehp_and_later.inl @@ -86,8 +86,14 @@ void StateBaseAddressHelper::appendStateBaseAddressParameters( setSbaStatelessCompressionParams(args.stateBaseAddressCmd, args.memoryCompressionState); } - if (args.stateBaseAddressCmd->getStatelessDataPortAccessMemoryObjectControlState() == args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) && DebugManager.flags.ForceL1Caching.get() != 0) { - args.stateBaseAddressCmd->setStatelessDataPortAccessMemoryObjectControlState(args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST)); + bool l3MocsEnabled = (args.stateBaseAddressCmd->getStatelessDataPortAccessMemoryObjectControlState() >> 1) == (args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1); + bool constMocsAllowed = (l3MocsEnabled && (DebugManager.flags.ForceL1Caching.get() != 0)); + + if (constMocsAllowed) { + auto constMocsIndex = args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); + GmmHelper::applyMocsEncryptionBit(constMocsIndex); + + args.stateBaseAddressCmd->setStatelessDataPortAccessMemoryObjectControlState(constMocsIndex); } appendExtraCacheSettings(args); diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 90b99f71ab..366130a5b7 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -457,4 +457,5 @@ ForceCsrLockInBcsEnqueueOnlyForGpgpuSubmission = -1 ExperimentalEnableTileAttach = 0 DirectSubmissionDisablePrefetcher = -1 ForceDefaultGrfCompilationMode = 0 -ForceLargeGrfCompilationMode = 0 \ No newline at end of file +ForceLargeGrfCompilationMode = 0 +ForceStatelessMocsEncryptionBit = -1 \ No newline at end of file