mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 14:33:04 +08:00
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:
committed by
Compute-Runtime-Automation
parent
e23b8430da
commit
8b7aa340ad
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user