mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Munmap unaligned part from mmap
Releated-To: NEO-5397 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6a80177dbf
commit
5cf4530748
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -82,7 +82,9 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
||||
auto cpuBasePointer = cpuPointer;
|
||||
cpuPointer = alignUp(cpuPointer, alignment);
|
||||
|
||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(this->createBufferObjectInMemoryRegion(&this->getDrm(allocationData.rootDeviceIndex), reinterpret_cast<uintptr_t>(cpuPointer), alignedSize, 0u, maxOsContextCount));
|
||||
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));
|
||||
|
||||
if (!bo) {
|
||||
this->munmapFunction(cpuBasePointer, totalSizeToAlloc);
|
||||
@@ -99,15 +101,20 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->mmapFunction(cpuPointer, alignedSize, 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, allocSize, 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, alignedSize, MemoryPool::System4KBPages);
|
||||
allocation->setMmapPtr(cpuBasePointer);
|
||||
allocation->setMmapSize(totalSizeToAlloc);
|
||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), alignedSize);
|
||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, bo->gpuAddress, allocSize, MemoryPool::System4KBPages);
|
||||
allocation->setMmapPtr(cpuPointer);
|
||||
allocation->setMmapSize(allocSize);
|
||||
if (pointerDiff != 0) {
|
||||
[[maybe_unused]] auto retCode = this->munmapFunction(cpuBasePointer, pointerDiff);
|
||||
DEBUG_BREAK_IF(retCode != 0);
|
||||
}
|
||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), allocSize);
|
||||
|
||||
bo.release();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -64,6 +64,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
||||
using DrmMemoryManager::allocateGraphicsMemoryWithHostPtr;
|
||||
using DrmMemoryManager::allocateShareableMemory;
|
||||
using DrmMemoryManager::allocUserptr;
|
||||
using DrmMemoryManager::createAllocWithAlignment;
|
||||
using DrmMemoryManager::createGraphicsAllocation;
|
||||
using DrmMemoryManager::createSharedBufferObject;
|
||||
using DrmMemoryManager::eraseSharedBufferObject;
|
||||
@@ -75,6 +76,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
||||
using DrmMemoryManager::lockResourceInLocalMemoryImpl;
|
||||
using DrmMemoryManager::memoryForPinBBs;
|
||||
using DrmMemoryManager::mmapFunction;
|
||||
using DrmMemoryManager::munmapFunction;
|
||||
using DrmMemoryManager::pinBBs;
|
||||
using DrmMemoryManager::pinThreshold;
|
||||
using DrmMemoryManager::pushSharedBufferObject;
|
||||
|
||||
Reference in New Issue
Block a user