refactor: Add allocation type parameter to ioctl helper functions
Related-To: NEO-12952 Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
parent
8353f68307
commit
0b46fb9f0d
|
@ -1462,7 +1462,7 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation,
|
|||
}
|
||||
|
||||
ioctlHelper->syncUserptrAlloc(*this, *gfxAllocation);
|
||||
ioctlHelper->releaseGpuRange(*this, gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex());
|
||||
ioctlHelper->releaseGpuRange(*this, gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex(), gfxAllocation->getAllocationType());
|
||||
alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr());
|
||||
|
||||
drmAlloc->freeRegisteredBOBindExtHandles(&getDrm(drmAlloc->getRootDeviceIndex()));
|
||||
|
@ -2604,15 +2604,15 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
|||
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
|
||||
auto canAllocateInHeapExtended = debugManager.flags.AllocateHostAllocationsInHeapExtendedHost.get();
|
||||
if (canAllocateInHeapExtended && allocationData.flags.isUSMHostAllocation && gfxPartition->getHeapLimit(HeapIndex::heapExtendedHost) > 0u) {
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::heapExtendedHost);
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type, HeapIndex::heapExtendedHost);
|
||||
}
|
||||
if (0 == preferredAddress) {
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::totalHeaps);
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type, HeapIndex::totalHeaps);
|
||||
}
|
||||
|
||||
auto cpuPointer = ioctlHelper->mmapFunction(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||
if (castToUint64(cpuPointer) != preferredAddress) {
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
preferredAddress = 0;
|
||||
}
|
||||
|
||||
|
@ -2626,7 +2626,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
|||
MemoryPoolHelper::isSystemMemoryPool(memoryPool), allocationData.flags.isUSMHostAllocation));
|
||||
|
||||
if (!bo) {
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
ioctlHelper->munmapFunction(*this, cpuBasePointer, totalSizeToAlloc);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2634,7 +2634,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
|||
uint64_t offset = 0;
|
||||
uint64_t mmapOffsetWb = ioctlHelper->getDrmParamValue(DrmParam::mmapOffsetWb);
|
||||
if (!retrieveMmapOffsetForBufferObject(allocationData.rootDeviceIndex, *bo, mmapOffsetWb, offset)) {
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
ioctlHelper->munmapFunction(*this, cpuPointer, size);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2761,15 +2761,15 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
|||
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
|
||||
auto canAllocateInHeapExtended = debugManager.flags.AllocateSharedAllocationsInHeapExtendedHost.get();
|
||||
if (canAllocateInHeapExtended && gfxPartition->getHeapLimit(HeapIndex::heapExtendedHost) > 0u && !allocationData.flags.resource48Bit) {
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::heapExtendedHost);
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type, HeapIndex::heapExtendedHost);
|
||||
}
|
||||
if (0 == preferredAddress) {
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::totalHeaps);
|
||||
preferredAddress = ioctlHelper->acquireGpuRange(*this, totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type, HeapIndex::totalHeaps);
|
||||
}
|
||||
|
||||
auto cpuPointer = ioctlHelper->mmapFunction(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||
if (castToUint64(cpuPointer) != preferredAddress) {
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
preferredAddress = 0;
|
||||
}
|
||||
|
||||
|
@ -2821,7 +2821,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
|||
|
||||
if (ret) {
|
||||
ioctlHelper->munmapFunction(*this, cpuPointer, totalSizeToAlloc);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2829,7 +2829,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
|||
|
||||
if (vmAdviseAttribute.has_value() && !ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute.value(), nullptr)) {
|
||||
ioctlHelper->munmapFunction(*this, cpuBasePointer, totalSizeToAlloc);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2838,7 +2838,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
|||
bo->setBOType(getBOTypeFromPatIndex(patIndex, productHelper.isVmBindPatIndexProgrammingSupported()));
|
||||
if (!retrieveMmapOffsetForBufferObject(allocationData.rootDeviceIndex, *bo, mmapOffsetWb, offset)) {
|
||||
ioctlHelper->munmapFunction(*this, cpuBasePointer, totalSizeToAlloc);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex);
|
||||
ioctlHelper->releaseGpuRange(*this, reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex, allocationData.type);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,14 +138,14 @@ uint64_t *IoctlHelper::getPagingFenceAddress(uint32_t vmHandleId, OsContextLinux
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t IoctlHelper::acquireGpuRange(DrmMemoryManager &memoryManager, size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex) {
|
||||
uint64_t IoctlHelper::acquireGpuRange(DrmMemoryManager &memoryManager, size_t &size, uint32_t rootDeviceIndex, AllocationType allocType, HeapIndex heapIndex) {
|
||||
if (heapIndex >= HeapIndex::totalHeaps) {
|
||||
return 0;
|
||||
}
|
||||
return memoryManager.acquireGpuRange(size, rootDeviceIndex, heapIndex);
|
||||
}
|
||||
|
||||
void IoctlHelper::releaseGpuRange(DrmMemoryManager &memoryManager, void *address, size_t size, uint32_t rootDeviceIndex) {
|
||||
void IoctlHelper::releaseGpuRange(DrmMemoryManager &memoryManager, void *address, size_t size, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
memoryManager.releaseGpuRange(address, size, rootDeviceIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -232,8 +232,8 @@ class IoctlHelper {
|
|||
virtual bool releaseInterrupt(uint32_t handle) { return false; }
|
||||
|
||||
virtual uint64_t *getPagingFenceAddress(uint32_t vmHandleId, OsContextLinux *osContext);
|
||||
virtual uint64_t acquireGpuRange(DrmMemoryManager &memoryManager, size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex);
|
||||
virtual void releaseGpuRange(DrmMemoryManager &memoryManager, void *address, size_t size, uint32_t rootDeviceIndex);
|
||||
virtual uint64_t acquireGpuRange(DrmMemoryManager &memoryManager, size_t &size, uint32_t rootDeviceIndex, AllocationType allocType, HeapIndex heapIndex);
|
||||
virtual void releaseGpuRange(DrmMemoryManager &memoryManager, void *address, size_t size, uint32_t rootDeviceIndex, AllocationType allocType);
|
||||
virtual void *mmapFunction(DrmMemoryManager &memoryManager, void *ptr, size_t size, int prot, int flags, int fd, off_t offset);
|
||||
virtual int munmapFunction(DrmMemoryManager &memoryManager, void *ptr, size_t size);
|
||||
virtual void registerMemoryToUnmap(DrmAllocation &allocation, void *pointer, size_t size, DrmAllocation::MemoryUnmapFunction unmapFunction);
|
||||
|
|
Loading…
Reference in New Issue