From a1a224c3bc47617a5b00a2fdeaa4101d3f9cb9bb Mon Sep 17 00:00:00 2001 From: "Hoppe, Mateusz" Date: Mon, 21 May 2018 10:57:28 +0200 Subject: [PATCH] Add Clear SLM workaround for BDW - set ProtectedMemoryDisable in PC prior to setting new L3 config Change-Id: I2ecbfe9535ef45159b48fffa41faad66db55d074 --- .../command_stream_receiver_hw.h | 1 + .../command_stream_receiver_hw.inl | 5 ++++ runtime/gen8/command_stream_receiver_hw.cpp | 5 ++++ .../command_stream_receiver_hw_tests_gen8.cpp | 27 +++++++++++++++++++ unit_tests/mocks/mock_csr.h | 3 +++ 5 files changed, 41 insertions(+) diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 8988dc56ec..4a090555e3 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -92,6 +92,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void addPipeControlWA(LinearStream &commandStream, bool flushDC); void addDcFlushToPipeControl(typename GfxFamily::PIPE_CONTROL *pCmd, bool flushDC); + void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd); PIPE_CONTROL *addPipeControlCmd(LinearStream &commandStream); uint64_t getScratchPatchAddress(); diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index 928e6568c9..ee6814a3b6 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -653,6 +653,7 @@ inline void CommandStreamReceiverHw::programL3(LinearStream &csr, Dis *pCmd = GfxFamily::cmdInitPipeControl; pCmd->setCommandStreamerStallEnable(true); pCmd->setDcFlushEnable(true); + addClearSLMWorkAround(pCmd); PreambleHelper::programL3(&csr, newL3Config); this->lastSentL3Config = newL3Config; @@ -727,4 +728,8 @@ void CommandStreamReceiverHw::resetKmdNotifyHelper(KmdNotifyHelper *n } } +template +void CommandStreamReceiverHw::addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd) { +} + } // namespace OCLRT diff --git a/runtime/gen8/command_stream_receiver_hw.cpp b/runtime/gen8/command_stream_receiver_hw.cpp index 58c691756a..cdcb502ab4 100644 --- a/runtime/gen8/command_stream_receiver_hw.cpp +++ b/runtime/gen8/command_stream_receiver_hw.cpp @@ -58,6 +58,11 @@ void populateFactoryTable>() { commandStreamReceiverFactory[gfxCore] = DeviceCommandStreamReceiver::create; } +template <> +void CommandStreamReceiverHw::addClearSLMWorkAround(Family::PIPE_CONTROL *pCmd) { + pCmd->setProtectedMemoryDisable(1); +} + // Explicitly instantiate CommandStreamReceiverHw for this device family template class CommandStreamReceiverHw; diff --git a/unit_tests/gen8/command_stream_receiver_hw_tests_gen8.cpp b/unit_tests/gen8/command_stream_receiver_hw_tests_gen8.cpp index 2c97c3d71d..7689d921c5 100644 --- a/unit_tests/gen8/command_stream_receiver_hw_tests_gen8.cpp +++ b/unit_tests/gen8/command_stream_receiver_hw_tests_gen8.cpp @@ -49,3 +49,30 @@ GEN8TEST_F(CommandStreamReceiverHwTestGen8, GivenKernelWithSlmWhenPreviousNOSLML GEN8TEST_F(CommandStreamReceiverHwTestGen8, GivenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblocking) { givenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigAfterUnblockingImpl(); } + +GEN8TEST_F(CommandStreamReceiverHwTestGen8, GivenChangedL3ConfigWhenL3IsProgrammedThenClearSLMWorkAroundIsAdded) { + MockCsrHw2 csr(pDevice->getHardwareInfo()); + csr.csrSizeRequestFlags.l3ConfigChanged = true; + csr.isPreambleSent = true; + + size_t bufferSize = 2 * sizeof(typename FamilyType::MI_LOAD_REGISTER_IMM) + sizeof(typename FamilyType::PIPE_CONTROL); + void *buffer = alignedMalloc(bufferSize, 64); + + LinearStream stream(buffer, bufferSize); + DispatchFlags flags; + uint32_t l3Config = 0x12345678; + + csr.programL3(stream, flags, l3Config); + + this->parseCommands(stream); + + typename FamilyType::PIPE_CONTROL *pc = getCommand(); + ASSERT_NE(nullptr, pc); + EXPECT_TRUE(pc->getProtectedMemoryDisable() != 0); + + typename FamilyType::MI_LOAD_REGISTER_IMM *lri = getCommand(); + ASSERT_NE(nullptr, lri); + EXPECT_EQ(l3Config, lri->getDataDword()); + + alignedFree(buffer); +} diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index d7b92635e8..68e8eeb292 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -149,12 +149,15 @@ template class MockCsrHw2 : public CommandStreamReceiverHw { public: using CommandStreamReceiverHw::flushStamp; + using CommandStreamReceiverHw::programL3; + using CommandStreamReceiverHw::csrSizeRequestFlags; using CommandStreamReceiver::commandStream; using CommandStreamReceiver::dispatchMode; using CommandStreamReceiver::lastSentCoherencyRequest; using CommandStreamReceiver::mediaVfeStateDirty; using CommandStreamReceiver::taskCount; using CommandStreamReceiver::taskLevel; + using CommandStreamReceiver::isPreambleSent; MockCsrHw2(const HardwareInfo &hwInfoIn) : CommandStreamReceiverHw(hwInfoIn) {}