feature: Add ioctl helper function to allocate user ptr

Related-To: NEO-12846

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2024-11-15 20:48:49 +00:00
committed by Compute-Runtime-Automation
parent e23b8430da
commit 8b7aa340ad
4 changed files with 9 additions and 2 deletions

View File

@@ -602,7 +602,8 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(con
if (!gpuVirtualAddress) {
return nullptr;
}
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(allocUserptr(reinterpret_cast<uintptr_t>(alignedPtr), realAllocationSize, rootDeviceIndex));
auto ioctlHelper = getDrm(rootDeviceIndex).getIoctlHelper();
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(ioctlHelper->allocUserptr(*this, reinterpret_cast<uintptr_t>(alignedPtr), realAllocationSize, rootDeviceIndex));
if (!bo) {
releaseGpuRange(reinterpret_cast<void *>(gpuVirtualAddress), alignedSize, rootDeviceIndex);
return nullptr;

View File

@@ -125,6 +125,8 @@ class DrmMemoryManager : public MemoryManager {
MOCKABLE_VIRTUAL uint64_t acquireGpuRange(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex);
MOCKABLE_VIRTUAL void releaseGpuRange(void *address, size_t size, uint32_t rootDeviceIndex);
BufferObject *allocUserptr(uintptr_t address, size_t size, uint32_t rootDeviceIndex);
decltype(&mmap) mmapFunction = mmap;
decltype(&munmap) munmapFunction = munmap;
@@ -136,7 +138,6 @@ class DrmMemoryManager : public MemoryManager {
MOCKABLE_VIRTUAL BufferObject *findAndReferenceSharedBufferObject(int boHandle, uint32_t rootDeviceIndex);
void eraseSharedBufferObject(BufferObject *bo);
void pushSharedBufferObject(BufferObject *bo);
BufferObject *allocUserptr(uintptr_t address, size_t size, uint32_t rootDeviceIndex);
bool setDomainCpu(GraphicsAllocation &graphicsAllocation, bool writeEnable);
MOCKABLE_VIRTUAL uint64_t acquireGpuRangeWithCustomAlignment(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex, size_t alignment);
void emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const;

View File

@@ -115,4 +115,8 @@ void IoctlHelper::registerMemoryToUnmap(DrmAllocation &allocation, void *pointer
return allocation.registerMemoryToUnmap(pointer, size, unmapFunction);
}
BufferObject *IoctlHelper::allocUserptr(DrmMemoryManager &memoryManager, uintptr_t address, size_t size, uint32_t rootDeviceIndex) {
return memoryManager.allocUserptr(address, size, rootDeviceIndex);
}
} // namespace NEO

View File

@@ -229,6 +229,7 @@ class IoctlHelper {
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);
virtual BufferObject *allocUserptr(DrmMemoryManager &memoryManager, uintptr_t address, size_t size, uint32_t rootDeviceIndex);
virtual bool queryDeviceParams(uint32_t *moduleId, uint16_t *serverType) { return false; }