mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-01 04:23:00 +08:00
Fix unmap unalignment part at end of mmap allocation
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7e9461ffa0
commit
2eaf830aff
@@ -83,8 +83,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
||||
cpuPointer = alignUp(cpuPointer, alignment);
|
||||
|
||||
auto pointerDiff = ptrDiff(cpuPointer, cpuBasePointer);
|
||||
auto allocSize = totalSizeToAlloc - pointerDiff;
|
||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(this->createBufferObjectInMemoryRegion(&this->getDrm(allocationData.rootDeviceIndex), reinterpret_cast<uintptr_t>(cpuPointer), allocSize, 0u, maxOsContextCount));
|
||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(this->createBufferObjectInMemoryRegion(&this->getDrm(allocationData.rootDeviceIndex), reinterpret_cast<uintptr_t>(cpuPointer), alignedSize, 0u, maxOsContextCount));
|
||||
|
||||
if (!bo) {
|
||||
this->munmapFunction(cpuBasePointer, totalSizeToAlloc);
|
||||
@@ -101,20 +100,22 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
[[maybe_unused]] auto retPtr = this->mmapFunction(cpuPointer, allocSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, getDrm(allocationData.rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(gemMmap.offset));
|
||||
[[maybe_unused]] auto retPtr = this->mmapFunction(cpuPointer, alignedSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, getDrm(allocationData.rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(gemMmap.offset));
|
||||
DEBUG_BREAK_IF(retPtr != cpuPointer);
|
||||
|
||||
obtainGpuAddress(allocationData, bo.get(), gpuAddress);
|
||||
emitPinningRequest(bo.get(), allocationData);
|
||||
|
||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, bo->gpuAddress, allocSize, MemoryPool::System4KBPages);
|
||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, bo->gpuAddress, alignedSize, MemoryPool::System4KBPages);
|
||||
allocation->setMmapPtr(cpuPointer);
|
||||
allocation->setMmapSize(allocSize);
|
||||
allocation->setMmapSize(alignedSize);
|
||||
if (pointerDiff != 0) {
|
||||
[[maybe_unused]] auto retCode = this->munmapFunction(cpuBasePointer, pointerDiff);
|
||||
DEBUG_BREAK_IF(retCode != 0);
|
||||
}
|
||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), allocSize);
|
||||
[[maybe_unused]] auto retCode = this->munmapFunction(ptrOffset(cpuPointer, alignedSize), alignment - pointerDiff);
|
||||
DEBUG_BREAK_IF(retCode != 0);
|
||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), alignedSize);
|
||||
|
||||
bo.release();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user