From 72c91c2f13a4d6050199d36102b145fbe400f424 Mon Sep 17 00:00:00 2001 From: Aravind Gopalakrishnan Date: Tue, 22 Sep 2020 15:54:01 -0700 Subject: [PATCH] Do not program SBA for copy engine Doing so causes hangs when reusing a copy command list Change-Id: I1bd069942e9caee01636497f992dd35cbedcde1b Signed-off-by: Aravind Gopalakrishnan --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 4 +++- .../sources/cmdlist/test_cmdlist_1.cpp | 16 ++++++++++++++++ .../test_cmdlist_append_launch_kernel.cpp | 8 ++++++++ 3 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 4de3134e8a..6911f222f8 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -1592,7 +1592,9 @@ ze_result_t CommandListCoreFamily::reset() { removeHostPtrAllocations(); commandContainer.reset(); - programStateBaseAddress(commandContainer); + if (!isCopyOnly()) { + programStateBaseAddress(commandContainer); + } return ZE_RESULT_SUCCESS; } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index 6a1c84b868..967f46f55e 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -363,6 +363,22 @@ HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenSetBarrierThenMiFlus EXPECT_NE(cmdList.end(), itor); } +HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenResetThenStateBaseAddressNotProgrammed) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, returnValue)); + auto &commandContainer = commandList->commandContainer; + commandList->reset(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + + EXPECT_EQ(cmdList.end(), itor); +} + HWTEST_F(CommandListCreate, givenCommandListWhenSetBarrierThenPipeControlIsProgrammed) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; ze_result_t returnValue; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel.cpp index 8b00f10521..92b9c9d7d8 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel.cpp @@ -463,6 +463,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenIndirectDispatchWhenAppendingThenWo } HWTEST_F(CommandListAppendLaunchKernel, givenCommandListWhenResetCalledThenStateIsCleaned) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; createKernel(); ze_result_t returnValue; @@ -512,6 +513,13 @@ HWTEST_F(CommandListAppendLaunchKernel, givenCommandListWhenResetCalledThenState ASSERT_EQ(commandListControl->commandContainer.isHeapDirty(heapType), commandList->commandContainer.isHeapDirty(heapType)); } + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed())); + + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); } HWTEST_F(CommandListAppendLaunchKernel, WhenAddingKernelsThenResidencyContainerDoesNotContainDuplicatesAfterClosingCommandList) {