mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
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:

committed by
sys_ocldev

parent
52e3f12b69
commit
d6dd229543
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user