Return error when there is no memory to evict

We want to return error code to the application instead of aborting when
we are not able to make more memory resident.

Related-To: NEO-7289
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2022-09-13 14:26:03 +00:00
committed by Compute-Runtime-Automation
parent 501873d0e0
commit 645600d141
20 changed files with 159 additions and 55 deletions

View File

@@ -58,9 +58,10 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
gfxAllocation.updateResidencyTaskCount(1, osContext->getContextId());
}
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
processResidencyParameterization.wasCalled = true;
processResidencyParameterization.receivedAllocationsForResidency = &allocationsForResidency;
return true;
}
void makeNonResident(GraphicsAllocation &gfxAllocation) override {

View File

@@ -1403,8 +1403,8 @@ struct MockMergeResidencyContainerMemoryOperationsHandler : public DrmMemoryOper
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeResidentWithinOsContextFailsThenFlushReturnsError) {
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return 0;
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return SubmissionStatus::SUCCESS;
}
};
@@ -1435,8 +1435,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeResidentWithinOsContex
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeResidentWithinOsContextOutOfMemoryThenFlushReturnsError) {
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return 0;
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return SubmissionStatus::SUCCESS;
}
};
@@ -1467,8 +1467,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeResidentWithinOsContex
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContainerFailsThenFlushReturnsError) {
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return 0;
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return SubmissionStatus::SUCCESS;
}
};
@@ -1498,8 +1498,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContaine
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContainerReturnsOutOfMemoryThenFlushReturnsError) {
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return 0;
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
return SubmissionStatus::SUCCESS;
}
};
@@ -1533,11 +1533,11 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenNoAllocsInMemoryOperationH
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
EXPECT_TRUE(memoryOperationsInterface->mutex.try_lock());
memoryOperationsInterface->mutex.unlock();
return 0;
return SubmissionStatus::SUCCESS;
}
};
@@ -1565,10 +1565,10 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocsInMemoryOperationHan
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
EXPECT_FALSE(memoryOperationsInterface->mutex.try_lock());
return 0;
return SubmissionStatus::SUCCESS;
}
};

View File

@@ -1599,6 +1599,17 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentFailThenExpectTrimR
EXPECT_FALSE(logger->makeResidentCall);
}
TEST_F(WddmTest, GivenInvalidHandleAndCantTrimFurtherSetToTrueWhenCallingMakeResidentThenFalseIsReturned) {
wddm->callBaseMakeResident = true;
D3DKMT_HANDLE handle = INVALID_HANDLE;
uint64_t bytesToTrim = 4 * 4096;
bool retVal = wddm->makeResident(&handle, 1, true, &bytesToTrim, 0x1000);
EXPECT_FALSE(retVal);
}
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenEnterWaitCalledThenExpectInternalFlagOn) {
if (!NEO::wddmResidencyLoggingAvailable) {
GTEST_SKIP();

View File

@@ -42,7 +42,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void makeResidentExternal(AllocationView &allocationView);
void makeNonResidentExternal(uint64_t gpuAddress);

View File

@@ -736,10 +736,10 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(const void *gfxAddress,
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
bool AUBCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) {
return;
return true;
}
}
@@ -761,6 +761,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyCont
}
dumpAubNonWritable = false;
return true;
}
template <typename GfxFamily>

View File

@@ -99,7 +99,7 @@ class CommandStreamReceiver {
MOCKABLE_VIRTUAL void makeResident(GraphicsAllocation &gfxAllocation);
virtual void makeNonResident(GraphicsAllocation &gfxAllocation);
MOCKABLE_VIRTUAL void makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency, bool clearAllocations);
virtual void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {}
virtual bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) { return true; }
virtual void processEviction();
void makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation);

View File

@@ -50,7 +50,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void downloadAllocationTbx(GraphicsAllocation &gfxAllocation);
void processEviction() override;
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override;
bool writeMemory(GraphicsAllocation &gfxAllocation) override;
void writeMMIO(uint32_t offset, uint32_t value) override;

View File

@@ -516,7 +516,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::processEviction() {
}
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
bool TbxCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
for (auto &gfxAllocation : allocationsForResidency) {
if (dumpTbxNonWritable) {
this->setTbxWritable(true, *gfxAllocation);
@@ -529,6 +529,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyCont
}
dumpTbxNonWritable = false;
return true;
}
template <typename GfxFamily>

View File

@@ -45,7 +45,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
~DrmCommandStreamReceiver() override;
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
bool isKmdWaitModeActive() override;
@@ -66,7 +66,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
using CommandStreamReceiver::pageTableManager;
protected:
MOCKABLE_VIRTUAL int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
MOCKABLE_VIRTUAL SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
MOCKABLE_VIRTUAL int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index);
MOCKABLE_VIRTUAL int waitUserFence(uint32_t waitValue);
MOCKABLE_VIRTUAL void readBackAllocation(void *source);

View File

@@ -171,11 +171,7 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
this->getMemoryManager()->peekGemCloseWorker()->push(bb);
}
if (ret) {
return SubmissionStatus::FAILED;
}
return SubmissionStatus::SUCCESS;
return ret;
}
template <typename GfxFamily>
@@ -246,14 +242,18 @@ int DrmCommandStreamReceiver<GfxFamily>::exec(const BatchBuffer &batchBuffer, ui
}
template <typename GfxFamily>
void DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
bool DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
bool ret = 0;
if ((!drm->isVmBindAvailable()) || (DebugManager.flags.PassBoundBOToExec.get() == 1)) {
for (auto &alloc : inputAllocationsForResidency) {
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
ret = drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
if (ret != 0) {
break;
}
}
}
return ret == 0;
}
template <typename GfxFamily>

View File

@@ -11,11 +11,18 @@
namespace NEO {
template <typename GfxFamily>
int DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
this->processResidency(allocationsForResidency, 0u);
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
bool processResidencySuccess = this->processResidency(allocationsForResidency, 0u);
if (processResidencySuccess == false) {
return SubmissionStatus::OUT_OF_MEMORY;
}
int ret = this->exec(batchBuffer, 0u, static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[0], 0);
return ret;
if (ret) {
return SubmissionStatus::FAILED;
}
return SubmissionStatus::SUCCESS;
}
template <typename GfxFamily>

View File

@@ -13,7 +13,7 @@
namespace NEO {
template <typename GfxFamily>
int DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
if (drm->useVMBindImmediate()) {
auto osContextLinux = static_cast<OsContextLinux *>(this->osContext);
osContextLinux->waitForPagingFence();
@@ -28,25 +28,29 @@ int DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchB
tileIterator = contextIndex = DebugManager.flags.ForceExecutionTile.get();
}
this->processResidency(allocationsForResidency, tileIterator);
bool processResidencySuccess = this->processResidency(allocationsForResidency, tileIterator);
if (processResidencySuccess == false) {
return SubmissionStatus::OUT_OF_MEMORY;
}
if (DebugManager.flags.PrintDeviceAndEngineIdOnSubmission.get()) {
printf("%u: Drm Submission of contextIndex: %u, with context id %u\n", SysCalls::getProcessId(), contextIndex, drmContextIds[contextIndex]);
}
int ret = this->exec(batchBuffer, tileIterator, drmContextIds[contextIndex], contextIndex);
if (ret) {
return ret;
return SubmissionStatus::FAILED;
}
contextIndex++;
if (DebugManager.flags.EnableWalkerPartition.get() == 0 || batchBuffer.useSingleSubdevice) {
return 0;
return SubmissionStatus::SUCCESS;
}
}
}
return 0;
return SubmissionStatus::SUCCESS;
}
template <typename GfxFamily>

View File

@@ -485,7 +485,7 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
makeResident.NumAllocations = count;
makeResident.PriorityList = &priority;
makeResident.Flags.CantTrimFurther = cantTrimFurther ? 1 : 0;
makeResident.Flags.MustSucceed = cantTrimFurther ? 1 : 0;
makeResident.Flags.MustSucceed = 0;
status = getGdi()->makeResident(&makeResident);
if (status == STATUS_PENDING) {
@@ -498,9 +498,10 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
} else {
DEBUG_BREAK_IF(true);
perfLogResidencyTrimRequired(residencyLogger.get(), makeResident.NumBytesToTrim);
if (numberOfBytesToTrim != nullptr)
if (numberOfBytesToTrim != nullptr) {
*numberOfBytesToTrim = makeResident.NumBytesToTrim;
UNRECOVERABLE_IF(cantTrimFurther);
}
return false;
}
kmDafListener->notifyMakeResident(featureTable->flags.ftrKmdDaf, getAdapter(), device, handles, count, getGdi()->escape);

View File

@@ -26,7 +26,7 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily>
~WddmCommandStreamReceiver() override;
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void processEviction() override;
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;

View File

@@ -76,16 +76,20 @@ SubmissionStatus WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchB
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->osContext->getContextId());
perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "Wddm CSR processing residency set: %zu\n", allocationsForResidency.size());
this->processResidency(allocationsForResidency, 0u);
bool ret = this->processResidency(allocationsForResidency, 0u);
if (ret == false) {
return SubmissionStatus::OUT_OF_MEMORY;
}
if (this->directSubmission.get()) {
bool ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
if (ret == false) {
return SubmissionStatus::FAILED;
}
return SubmissionStatus::SUCCESS;
}
if (this->blitterDirectSubmission.get()) {
bool ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
ret = this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
if (ret == false) {
return SubmissionStatus::FAILED;
}
@@ -129,9 +133,8 @@ SubmissionStatus WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchB
}
template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
[[maybe_unused]] bool success = static_cast<OsContextWin *>(this->osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency);
DEBUG_BREAK_IF(!success);
bool WddmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
return static_cast<OsContextWin *>(this->osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency);
}
template <typename GfxFamily>

View File

@@ -73,6 +73,20 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
return this->submissionAggregator.get();
}
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
if (callBaseProcessResidency) {
return DrmCommandStreamReceiver<GfxFamily>::processResidency(allocationsForResidency, handleId);
}
return processResidencyResult;
}
int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index) override {
if (callBaseExec) {
return DrmCommandStreamReceiver<GfxFamily>::exec(batchBuffer, vmHandleId, drmContextId, index);
}
return execResult;
}
void overrideSubmissionAggregator(SubmissionAggregator *newSubmissionsAggregator) {
this->submissionAggregator.reset(newSubmissionsAggregator);
}
@@ -105,11 +119,11 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
}
}
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
if (callHwFlush) {
return DrmCommandStreamReceiver<GfxFamily>::flushInternal(batchBuffer, allocationsForResidency);
}
return 0;
return SubmissionStatus::SUCCESS;
}
void readBackAllocation(void *source) override {
@@ -119,6 +133,10 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
void *latestReadBackAddress = nullptr;
bool callHwFlush = true;
bool callBaseProcessResidency = true;
bool processResidencyResult = true;
bool callBaseExec = true;
int execResult = 0;
};
template <typename GfxFamily>

View File

@@ -599,6 +599,44 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhen
mm->freeGraphicsMemory(commandBuffer);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingProcessResidencyWhenFlushingThenFlushReturnsOutOfMemory) {
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::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<GraphicsAllocation *>(&allocation, 1));
static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->callBaseProcessResidency = false;
static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->processResidencyResult = false;
SubmissionStatus ret = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(SubmissionStatus::OUT_OF_MEMORY, ret);
mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(commandBuffer);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenFailingExecWhenFlushingThenFlushReturnsFailed) {
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::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<GraphicsAllocation *>(&allocation, 1));
static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->callBaseExec = false;
static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execResult = -1;
SubmissionStatus ret = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(SubmissionStatus::FAILED, ret);
mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(commandBuffer);
}
struct DrmCommandStreamDirectSubmissionTest : public DrmCommandStreamEnhancedTest {
template <typename GfxFamily>
void setUpT() {

View File

@@ -275,7 +275,7 @@ class DrmCommandStreamForceTileTest : public ::testing::Test {
: DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield, mode), expectedHandleId(inputHandleId) {
}
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
bool processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
EXPECT_EQ(handleId, expectedHandleId);
return DrmCommandStreamReceiver<GfxFamily>::processResidency(allocationsForResidency, handleId);
}
@@ -587,10 +587,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenUseSingle
execCalled++;
return 0;
}
void processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
EXPECT_EQ(0u, processResidencyCalled);
EXPECT_EQ(0u, handleId);
processResidencyCalled++;
return true;
}
uint32_t execCalled = 0;
@@ -627,10 +628,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenDisabledI
execCalled++;
return 0;
}
void processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
EXPECT_EQ(0u, processResidencyCalled);
EXPECT_EQ(0u, handleId);
processResidencyCalled++;
return true;
}
uint32_t execCalled = 0;
@@ -663,8 +665,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenMultiTile
execCalled++;
return 0;
}
void processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
bool processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) override {
EXPECT_EQ(execCalled, handleId);
return true;
}
uint32_t execCalled = 0;

View File

@@ -101,8 +101,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmCommandStreamMultiTileMemExecTest, GivenDrmSuppo
uint64_t expectedCompletionGpuAddress = testCsr->getTagAllocation()->getGpuAddress() + Drm::completionFenceOffset + testCsr->postSyncWriteOffset;
int ret = testCsr->flushInternal(batchBuffer, testCsr->getResidencyAllocations());
EXPECT_EQ(0, ret);
SubmissionStatus ret = testCsr->flushInternal(batchBuffer, testCsr->getResidencyAllocations());
EXPECT_EQ(SubmissionStatus::SUCCESS, ret);
EXPECT_EQ(expectedCompletionGpuAddress, bo.receivedCompletionGpuAddress);
EXPECT_EQ(testCsr->latestSentTaskCount, bo.receivedCompletionValue);

View File

@@ -306,6 +306,22 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenFailureFromMakeResidentWhenFlushingThenOutOfMemoryIsReturned) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
wddm->makeResidentStatus = false;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
SubmissionStatus retVal = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(SubmissionStatus::OUT_OF_MEMORY, retVal);
memoryManager->freeGraphicsMemory(commandBuffer);
}
struct WddmPreemptionHeaderFixture {
void setUp() {
executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);