diff --git a/runtime/helpers/task_information.cpp b/runtime/helpers/task_information.cpp index 83cd76f292..2d62ff1b9c 100644 --- a/runtime/helpers/task_information.cpp +++ b/runtime/helpers/task_information.cpp @@ -76,9 +76,8 @@ CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) { dispatchFlags, cmdQ.getDevice()); - cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); - if (!memObj.isMemObjZeroCopy()) { + cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); if (op == MAP) { memObj.transferDataToHostPtr(copySize, copyOffset); } else if (!readOnly) { @@ -283,8 +282,6 @@ CompletionStamp &CommandMarker::submit(uint32_t taskLevel, bool terminated) { dispatchFlags, cmdQ.getDevice()); - cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); - return completionStamp; } } // namespace NEO diff --git a/unit_tests/command_queue/command_queue_hw_tests.cpp b/unit_tests/command_queue/command_queue_hw_tests.cpp index 0ef110206a..5a0d8dfea3 100644 --- a/unit_tests/command_queue/command_queue_hw_tests.cpp +++ b/unit_tests/command_queue/command_queue_hw_tests.cpp @@ -177,7 +177,7 @@ HWTEST_F(CommandQueueHwTest, addMapUnmapToWaitlistEventsDoesntAddDependenciesInt buffer->decRefInternal(); } -HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsBeingWaited) { +HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsNotBeingWaited) { auto buffer = new MockBuffer; CommandQueueHw *pHwQ = reinterpret_cast *>(pCmdQ); @@ -194,6 +194,28 @@ HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenT EXPECT_NE(nullptr, pHwQ->virtualEvent); pHwQ->virtualEvent->setStatus(CL_COMPLETE); + EXPECT_EQ(std::numeric_limits::max(), pHwQ->latestTaskCountWaited); + buffer->decRefInternal(); +} + +HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedOnNonZeroCopyBufferThenTaskCountIsBeingWaited) { + auto buffer = new MockBuffer; + buffer->isZeroCopy = false; + CommandQueueHw *pHwQ = reinterpret_cast *>(pCmdQ); + + MockEventBuilder eventBuilder; + MemObjSizeArray size = {{1, 1, 1}}; + MemObjOffsetArray offset = {{0, 0, 0}}; + pHwQ->enqueueBlockedMapUnmapOperation(nullptr, + 0, + MAP, + buffer, + size, offset, false, + eventBuilder); + + EXPECT_NE(nullptr, pHwQ->virtualEvent); + pHwQ->virtualEvent->setStatus(CL_COMPLETE); + EXPECT_EQ(1u, pHwQ->latestTaskCountWaited); buffer->decRefInternal(); } diff --git a/unit_tests/mocks/mock_buffer.h b/unit_tests/mocks/mock_buffer.h index b8fa51da4e..3d7b3ffa8b 100644 --- a/unit_tests/mocks/mock_buffer.h +++ b/unit_tests/mocks/mock_buffer.h @@ -29,6 +29,7 @@ class MockBuffer : public MockBufferStorage, public Buffer { public: using Buffer::magic; using Buffer::offset; + using MemObj::isZeroCopy; using MockBufferStorage::device; MockBuffer(GraphicsAllocation &alloc)