From 10bccdb32a8cb42ae0df76c611760210e1d13f71 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Thu, 18 May 2023 15:34:42 +0000 Subject: [PATCH] fix: correct batch buffer level for debugger address tracking commands Related-To: NEO-7807 Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- .../test_l0_debugger_sba_tracking.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 4b894413e2..53add95777 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -2800,7 +2800,7 @@ void CommandListCoreFamily::programStateBaseAddress(NEO::CommandC NEO::EncodeStateBaseAddress::setSbaTrackingForL0DebuggerIfEnabled(sbaTrackingEnabled, *this->device->getNEODevice(), *container.getCommandStream(), - sba, this->isFlushTaskSubmissionEnabled); + sba, (this->isFlushTaskSubmissionEnabled || this->dispatchCmdListBatchBufferAsPrimary)); } template diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp index 0577b764ea..82d6df19e0 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp @@ -279,9 +279,11 @@ HWTEST2_F(L0DebuggerTest, givenL0DebuggerAndDebuggerLogsDisabledWhenCommandQueue HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledWhenNonCopyCommandListIsInititalizedOrResetThenSSHAddressIsTracked, Gen12Plus) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; DebugManagerStateRestore dbgRestorer; DebugManager.flags.EnableStateBaseAddressTracking.set(0); + DebugManager.flags.DispatchCmdlistCmdBufferPrimary.set(0); size_t usedSpaceBefore = 0; ze_result_t returnValue; @@ -304,10 +306,34 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledWhenNonCopyCommandListIsInititali EXPECT_EQ(expectedGpuVa, sshGpuVa); EXPECT_EQ(1u, getMockDebuggerL0Hw()->captureStateBaseAddressCount); + auto bbStartList = findAll(cmdList.begin(), cmdList.end()); + for (const auto &bbStartIt : bbStartList) { + auto bbStartCmd = reinterpret_cast(*bbStartIt); + EXPECT_EQ(MI_BATCH_BUFFER_START::SECOND_LEVEL_BATCH_BUFFER_SECOND_LEVEL_BATCH, bbStartCmd->getSecondLevelBatchBuffer()); + } + commandList->reset(); EXPECT_EQ(2u, getMockDebuggerL0Hw()->captureStateBaseAddressCount); commandList->destroy(); + + DebugManager.flags.DispatchCmdlistCmdBufferPrimary.set(1); + commandListHandle = CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle(); + commandList = CommandList::fromHandle(commandListHandle); + + cmdList.clear(); + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + bbStartList = findAll(cmdList.begin(), cmdList.end()); + for (const auto &bbStartIt : bbStartList) { + auto bbStartCmd = reinterpret_cast(*bbStartIt); + EXPECT_EQ(MI_BATCH_BUFFER_START::SECOND_LEVEL_BATCH_BUFFER_FIRST_LEVEL_BATCH, bbStartCmd->getSecondLevelBatchBuffer()); + } + + commandList->destroy(); } HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledWhenCommandListIsExecutedThenSbaBufferIsPushedToResidencyContainer, Gen12Plus) {