Fail create allocation if map is unsuccessful.

- This way we will fail whenever mapping is unsuccessful instead of creating
Graphics Allocation that is in undefined state.

Change-Id: I50358d4564cd3fba0f6d05ab47cbbbaffbd9ce1c
This commit is contained in:
Mrozek, Michal
2019-06-18 13:53:14 +02:00
committed by sys_ocldev
parent 52e3f12b69
commit d6dd229543
2 changed files with 20 additions and 2 deletions

View File

@ -487,14 +487,16 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
}
osHandles.fragmentStorageData[allocationIndex].osHandleStorage->handle = AllocationInfo[i].hAllocation;
bool success = mapGpuVirtualAddress(&osHandles.fragmentStorageData[allocationIndex]);
allocationIndex++;
if (!success) {
osHandles.fragmentStorageData[allocationIndex].freeTheFragment = true;
DBG_LOG(PrintDebugMessages, __FUNCTION__, "mapGpuVirtualAddress: ", success);
DEBUG_BREAK_IF(true);
break;
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
}
allocationIndex++;
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, AllocationInfo[i].hAllocation, gdi->escape);
}

View File

@ -603,6 +603,22 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocat
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAreClearedAndNullptrIsReturned) {
this->wddm->callBaseMapGpuVa = false;
this->wddm->mapGpuVaStatus = false;
void *hostPtr = reinterpret_cast<void *>(wddm->virtualAllocAddress + 0x1234);
auto size = 1234u;
wddm->mapGpuVirtualAddressResult.called = 0u;
wddm->destroyAllocationResult.called = 0u;
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{false, size}, hostPtr);
EXPECT_EQ(1u, wddm->mapGpuVirtualAddressResult.called);
EXPECT_EQ(1u, wddm->destroyAllocationResult.called);
EXPECT_EQ(nullptr, gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAllocationAndMakeResident) {
void *hostPtr = reinterpret_cast<void *>(memoryManager->getAlignedMallocRestrictions()->minAddress - 0x1000);
auto size = 0x2000u;