diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 2d59deb54a..0fe8dc1c65 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -456,7 +456,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignmentFromUserptr(const Alloc } auto ioctlHelper = getDrm(allocationData.rootDeviceIndex).getIoctlHelper(); - std::unique_ptr bo(ioctlHelper->allocUserptr(*this, reinterpret_cast(res), size, allocationData.rootDeviceIndex)); + std::unique_ptr bo(ioctlHelper->allocUserptr(*this, allocationData, reinterpret_cast(res), size, allocationData.rootDeviceIndex)); if (!bo) { alignedFreeWrapper(res); return nullptr; @@ -605,7 +605,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(con return nullptr; } auto ioctlHelper = getDrm(rootDeviceIndex).getIoctlHelper(); - std::unique_ptr bo(ioctlHelper->allocUserptr(*this, reinterpret_cast(alignedPtr), realAllocationSize, rootDeviceIndex)); + std::unique_ptr bo(ioctlHelper->allocUserptr(*this, allocationData, reinterpret_cast(alignedPtr), realAllocationSize, rootDeviceIndex)); if (!bo) { releaseGpuRange(reinterpret_cast(gpuVirtualAddress), alignedSize, rootDeviceIndex); return nullptr; @@ -1386,6 +1386,7 @@ void DrmMemoryManager::handleFenceCompletion(GraphicsAllocation *allocation) { } else { static_cast(allocation)->getBO()->wait(-1); } + drm.getIoctlHelper()->syncUserptrAllocs(*this); } GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) { diff --git a/shared/source/os_interface/linux/drm_memory_manager.h b/shared/source/os_interface/linux/drm_memory_manager.h index ec584c1824..1ad1c4d75c 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.h +++ b/shared/source/os_interface/linux/drm_memory_manager.h @@ -126,6 +126,7 @@ class DrmMemoryManager : public MemoryManager { MOCKABLE_VIRTUAL void releaseGpuRange(void *address, size_t size, uint32_t rootDeviceIndex); BufferObject *allocUserptr(uintptr_t address, size_t size, uint32_t rootDeviceIndex); + size_t getUserptrAlignment(); decltype(&mmap) mmapFunction = mmap; decltype(&munmap) munmapFunction = munmap; @@ -143,7 +144,6 @@ class DrmMemoryManager : public MemoryManager { void emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const; uint32_t getDefaultDrmContextId(uint32_t rootDeviceIndex) const; OsContextLinux *getDefaultOsContext(uint32_t rootDeviceIndex) const; - size_t getUserptrAlignment(); StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties) override; GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override; diff --git a/shared/source/os_interface/linux/ioctl_helper.cpp b/shared/source/os_interface/linux/ioctl_helper.cpp index da370e0628..4cc7621ec5 100644 --- a/shared/source/os_interface/linux/ioctl_helper.cpp +++ b/shared/source/os_interface/linux/ioctl_helper.cpp @@ -115,7 +115,7 @@ 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) { +BufferObject *IoctlHelper::allocUserptr(DrmMemoryManager &memoryManager, const AllocationData &allocData, uintptr_t address, size_t size, uint32_t rootDeviceIndex) { return memoryManager.allocUserptr(address, size, rootDeviceIndex); } diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 0e6416b3c8..1f080719fb 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -229,7 +229,8 @@ 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 BufferObject *allocUserptr(DrmMemoryManager &memoryManager, const AllocationData &allocData, uintptr_t address, size_t size, uint32_t rootDeviceIndex); + virtual void syncUserptrAllocs(DrmMemoryManager &memoryManager) { return; }; virtual bool queryDeviceParams(uint32_t *moduleId, uint16_t *serverType) { return false; }