diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 4ad93c6ba0..9973e0f3c5 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -58,10 +58,10 @@ struct MyMockCsr : UltCommandStreamReceiver { gfxAllocation.updateResidencyTaskCount(1, osContext->getContextId()); } - bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override { + SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override { processResidencyParameterization.wasCalled = true; processResidencyParameterization.receivedAllocationsForResidency = &allocationsForResidency; - return true; + return SubmissionStatus::SUCCESS; } void makeNonResident(GraphicsAllocation &gfxAllocation) override { diff --git a/shared/source/command_stream/aub_command_stream_receiver_hw.h b/shared/source/command_stream/aub_command_stream_receiver_hw.h index 142988a6fa..94318437a4 100644 --- a/shared/source/command_stream/aub_command_stream_receiver_hw.h +++ b/shared/source/command_stream/aub_command_stream_receiver_hw.h @@ -42,7 +42,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::expectMemory(const void *gfxAddress, } template -bool AUBCommandStreamReceiverHw::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { +SubmissionStatus AUBCommandStreamReceiverHw::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { if (subCaptureManager->isSubCaptureMode()) { if (!subCaptureManager->isSubCaptureEnabled()) { - return true; + return SubmissionStatus::SUCCESS; } } @@ -767,7 +767,7 @@ bool AUBCommandStreamReceiverHw::processResidency(const ResidencyCont } dumpAubNonWritable = false; - return true; + return SubmissionStatus::SUCCESS; } template diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index a5b543d497..2ccb902da8 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -98,7 +98,7 @@ class CommandStreamReceiver { MOCKABLE_VIRTUAL void makeResident(GraphicsAllocation &gfxAllocation); virtual void makeNonResident(GraphicsAllocation &gfxAllocation); MOCKABLE_VIRTUAL void makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency, bool clearAllocations); - virtual bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { return true; } + virtual SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { return SubmissionStatus::SUCCESS; } virtual void processEviction(); void makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation); diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.h b/shared/source/command_stream/tbx_command_stream_receiver_hw.h index 5027918d5b..3f369bd9c7 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.h +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.h @@ -51,7 +51,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::processEviction() { } template -bool TbxCommandStreamReceiverHw::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { +SubmissionStatus TbxCommandStreamReceiverHw::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { for (auto &gfxAllocation : allocationsForResidency) { if (dumpTbxNonWritable) { this->setTbxWritable(true, *gfxAllocation); @@ -528,7 +528,7 @@ bool TbxCommandStreamReceiverHw::processResidency(const ResidencyCont } dumpTbxNonWritable = false; - return true; + return SubmissionStatus::SUCCESS; } template diff --git a/shared/source/os_interface/linux/drm_command_stream.h b/shared/source/os_interface/linux/drm_command_stream.h index 6b1dc1ba86..235f1e29f7 100644 --- a/shared/source/os_interface/linux/drm_command_stream.h +++ b/shared/source/os_interface/linux/drm_command_stream.h @@ -45,7 +45,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver { ~DrmCommandStreamReceiver() override; SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override; - bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override; + SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override; bool isKmdWaitModeActive() override; diff --git a/shared/source/os_interface/linux/drm_command_stream.inl b/shared/source/os_interface/linux/drm_command_stream.inl index 91ed4068a7..ad9aea6d3c 100644 --- a/shared/source/os_interface/linux/drm_command_stream.inl +++ b/shared/source/os_interface/linux/drm_command_stream.inl @@ -247,9 +247,9 @@ int DrmCommandStreamReceiver::exec(const BatchBuffer &batchBuffer, ui } template -bool DrmCommandStreamReceiver::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) { +SubmissionStatus DrmCommandStreamReceiver::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) { if (drm->isVmBindAvailable()) { - return true; + return SubmissionStatus::SUCCESS; } int ret = 0; for (auto &alloc : inputAllocationsForResidency) { @@ -260,7 +260,7 @@ bool DrmCommandStreamReceiver::processResidency(const ResidencyContai } } - return ret == 0; + return Drm::getSubmissionStatusFromReturnCode(ret); } template diff --git a/shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl b/shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl index c545c74ef6..8f1982fd3f 100644 --- a/shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl +++ b/shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl @@ -12,9 +12,9 @@ namespace NEO { template SubmissionStatus DrmCommandStreamReceiver::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) { - bool processResidencySuccess = this->processResidency(allocationsForResidency, 0u); - if (processResidencySuccess == false) { - return SubmissionStatus::OUT_OF_MEMORY; + auto processResidencySuccess = this->processResidency(allocationsForResidency, 0u); + if (processResidencySuccess != SubmissionStatus::SUCCESS) { + return processResidencySuccess; } int ret = this->exec(batchBuffer, 0u, static_cast(osContext)->getDrmContextIds()[0], 0); diff --git a/shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl b/shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl index eff9868b25..812ecb736e 100644 --- a/shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl +++ b/shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl @@ -28,9 +28,9 @@ SubmissionStatus DrmCommandStreamReceiver::flushInternal(const BatchB tileIterator = contextIndex = DebugManager.flags.ForceExecutionTile.get(); } - bool processResidencySuccess = this->processResidency(allocationsForResidency, tileIterator); - if (processResidencySuccess == false) { - return SubmissionStatus::OUT_OF_MEMORY; + auto processResidencySuccess = this->processResidency(allocationsForResidency, tileIterator); + if (processResidencySuccess != SubmissionStatus::SUCCESS) { + return processResidencySuccess; } if (DebugManager.flags.PrintDeviceAndEngineIdOnSubmission.get()) { diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.h b/shared/source/os_interface/windows/wddm_device_command_stream.h index dbd7e15441..8e08c3abb8 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.h +++ b/shared/source/os_interface/windows/wddm_device_command_stream.h @@ -26,7 +26,7 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver ~WddmCommandStreamReceiver() override; SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override; - bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override; + SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override; void processEviction() override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override; diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.inl b/shared/source/os_interface/windows/wddm_device_command_stream.inl index 36e1d98f76..832fe08c9d 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.inl +++ b/shared/source/os_interface/windows/wddm_device_command_stream.inl @@ -77,19 +77,19 @@ SubmissionStatus WddmCommandStreamReceiver::flush(BatchBuffer &batchB batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->osContext->getContextId()); perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "Wddm CSR processing residency set: %zu\n", allocationsForResidency.size()); - bool ret = this->processResidency(allocationsForResidency, 0u); - if (ret == false) { - return SubmissionStatus::OUT_OF_MEMORY; + auto submissionStatus = this->processResidency(allocationsForResidency, 0u); + if (submissionStatus != SubmissionStatus::SUCCESS) { + return submissionStatus; } if (this->directSubmission.get()) { - ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); + auto ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); if (ret == false) { return SubmissionStatus::FAILED; } return SubmissionStatus::SUCCESS; } if (this->blitterDirectSubmission.get()) { - ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); + auto ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get())); if (ret == false) { return SubmissionStatus::FAILED; } @@ -133,8 +133,8 @@ SubmissionStatus WddmCommandStreamReceiver::flush(BatchBuffer &batchB } template -bool WddmCommandStreamReceiver::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { - return static_cast(this->osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency); +SubmissionStatus WddmCommandStreamReceiver::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { + return static_cast(this->osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency) ? SubmissionStatus::SUCCESS : SubmissionStatus::OUT_OF_MEMORY; } template diff --git a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h index 8688523a81..849090068c 100644 --- a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h +++ b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h @@ -77,7 +77,7 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiversubmissionAggregator.get(); } - ADDMETHOD(processResidency, bool, true, true, (const ResidencyContainer &allocationsForResidency, uint32_t handleId), (allocationsForResidency, handleId)); + ADDMETHOD(processResidency, SubmissionStatus, true, SubmissionStatus::SUCCESS, (const ResidencyContainer &allocationsForResidency, uint32_t handleId), (allocationsForResidency, handleId)); ADDMETHOD(exec, int, true, 0, (const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index), (batchBuffer, vmHandleId, drmContextId, index)); diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp index 6ecd88df0c..a8bc5ad165 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp @@ -601,7 +601,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhen mm->freeGraphicsMemory(commandBuffer); } -HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingProcessResidencyWhenFlushingThenFlushReturnsOutOfMemory) { +HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenProcessResidencyFailingOnOutOfMemoryWhenFlushingThenFlushReturnsOutOfMemory) { auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); LinearStream cs(commandBuffer); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -613,7 +613,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingProcessResidencyWhe auto testedCsr = static_cast *>(csr); testedCsr->processResidencyCallBase = false; - testedCsr->processResidencyResult = false; + testedCsr->processResidencyResult = SubmissionStatus::OUT_OF_MEMORY; SubmissionStatus ret = csr->flush(batchBuffer, csr->getResidencyAllocations()); EXPECT_EQ(SubmissionStatus::OUT_OF_MEMORY, ret); @@ -623,6 +623,28 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingProcessResidencyWhe mm->freeGraphicsMemory(commandBuffer); } +HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenProcessResidencyFailingOnOutOfHostMemoryWhenFlushingThenFlushReturnsOutOfHostMemory) { + auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); + LinearStream cs(commandBuffer); + CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); + EncodeNoop::alignToCacheLine(cs); + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false}; + + auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); + executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->makeResident(device.get(), ArrayRef(&allocation, 1)); + + auto testedCsr = static_cast *>(csr); + testedCsr->processResidencyCallBase = false; + testedCsr->processResidencyResult = SubmissionStatus::OUT_OF_HOST_MEMORY; + + SubmissionStatus ret = csr->flush(batchBuffer, csr->getResidencyAllocations()); + EXPECT_EQ(SubmissionStatus::OUT_OF_HOST_MEMORY, ret); + EXPECT_EQ(testedCsr->flushInternalCalled, 1u); + EXPECT_EQ(testedCsr->processResidencyCalled, 1u); + mm->freeGraphicsMemory(allocation); + mm->freeGraphicsMemory(commandBuffer); +} + HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingExecWhenFlushingThenFlushReturnsFailed) { auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); LinearStream cs(commandBuffer); @@ -635,7 +657,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingExecWhenFlushingThe auto testedCsr = static_cast *>(csr); testedCsr->processResidencyCallBase = true; - testedCsr->processResidencyResult = true; + testedCsr->processResidencyResult = SubmissionStatus::SUCCESS; testedCsr->execCallBase = false; testedCsr->execResult = -1; diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp index 8bd4253259..2da7605e56 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp @@ -275,7 +275,7 @@ class DrmCommandStreamForceTileTest : public ::testing::Test { : DrmCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield, mode), expectedHandleId(inputHandleId) { } - bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override { + SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override { EXPECT_EQ(handleId, expectedHandleId); return DrmCommandStreamReceiver::processResidency(allocationsForResidency, handleId); } @@ -587,11 +587,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenUseSingle execCalled++; return 0; } - bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { + SubmissionStatus processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { EXPECT_EQ(0u, processResidencyCalled); EXPECT_EQ(0u, handleId); processResidencyCalled++; - return true; + return SubmissionStatus::SUCCESS; } uint32_t execCalled = 0; @@ -628,11 +628,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenDisabledI execCalled++; return 0; } - bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { + SubmissionStatus processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { EXPECT_EQ(0u, processResidencyCalled); EXPECT_EQ(0u, handleId); processResidencyCalled++; - return true; + return SubmissionStatus::SUCCESS; } uint32_t execCalled = 0; @@ -665,9 +665,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenMultiTile execCalled++; return 0; } - bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { + SubmissionStatus processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override { EXPECT_EQ(execCalled, handleId); - return true; + return SubmissionStatus::SUCCESS; } uint32_t execCalled = 0;