Add support for SVM CPU allocations to DRM memory manager

Related-To: NEO-2687

Change-Id: I8987054d2fd12a1c2c01857eca1883476b0f5e04
Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2019-07-17 23:31:38 +02:00
parent 22c22f75d5
commit c93b011ac6
3 changed files with 75 additions and 0 deletions

View File

@@ -223,10 +223,32 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignment(const Alloc
bo->setAllocationType(allocType);
}
uint64_t reservedGpuAddress = 0;
size_t reserveSizeAligned = 0;
if (allocationData.type == GraphicsAllocation::AllocationType::SVM_CPU) {
//add 2MB padding in case reserved addr is not 2MB aligned
reserveSizeAligned = alignUp(cSize, cAlignment) + cAlignment;
reservedGpuAddress = GmmHelper::canonize(gfxPartition.heapAllocate(HeapIndex::HEAP_STANDARD, reserveSizeAligned));
if (!reservedGpuAddress) {
bo->close();
delete bo;
alignedFreeWrapper(res);
return nullptr;
}
bo->gpuAddress = alignUp(reservedGpuAddress, cAlignment);
bo->isAllocated = false;
}
emitPinningRequest(bo, allocationData);
auto allocation = new DrmAllocation(allocationData.type, bo, res, bo->gpuAddress, cSize, MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable);
allocation->setDriverAllocatedCpuPtr(isLimitedRange() ? res : nullptr);
if (GraphicsAllocation::AllocationType::SVM_CPU == allocationData.type) {
allocation->setDriverAllocatedCpuPtr(res);
allocation->setReservedAddressRange(reinterpret_cast<void *>(reservedGpuAddress), reserveSizeAligned);
}
return allocation;
}