Canonize graphics allocation base address in DrmMemoryManager

Related-To: NEO-2877

Change-Id: Id07dbef3b184660d95f91cb77361554049f02140
Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
Igor Venevtsev 2019-07-11 14:13:13 +02:00 committed by sys_ocldev
parent 2e2d5d53b4
commit 6dc4e9e775
2 changed files with 18 additions and 18 deletions

View File

@ -130,12 +130,12 @@ uint32_t DrmMemoryManager::unreference(NEO::BufferObject *bo, bool synchronousDe
uint64_t DrmMemoryManager::acquireGpuRange(size_t &size, StorageAllocatorType &storageType, bool specificBitness) {
if (specificBitness && this->force32bitAllocations) {
storageType = BIT32_ALLOCATOR_EXTERNAL;
return gfxPartition.heapAllocate(HeapIndex::HEAP_EXTERNAL, size);
return GmmHelper::canonize(gfxPartition.heapAllocate(HeapIndex::HEAP_EXTERNAL, size));
}
if (isLimitedRange()) {
storageType = INTERNAL_ALLOCATOR_WITH_DYNAMIC_BITRANGE;
return gfxPartition.heapAllocate(HeapIndex::HEAP_STANDARD, size);
return GmmHelper::canonize(gfxPartition.heapAllocate(HeapIndex::HEAP_STANDARD, size));
}
storageType = MMAP_ALLOCATOR;
@ -212,7 +212,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignment(const Alloc
// if limitedRangeAlloction is enabled, memory allocation for bo in the limited Range heap is required
if (isLimitedRange()) {
StorageAllocatorType allocType;
bo->gpuAddress = GmmHelper::canonize(acquireGpuRange(cSize, allocType, false));
bo->gpuAddress = acquireGpuRange(cSize, allocType, false);
if (!bo->gpuAddress) {
bo->close();
delete bo;
@ -263,7 +263,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(const Al
bo->isAllocated = false;
bo->setUnmapSize(alignedSize);
bo->gpuAddress = GmmHelper::canonize(gpuVirtualAddress);
bo->gpuAddress = gpuVirtualAddress;
bo->setAllocationType(allocType);
auto allocation = new DrmAllocation(allocationData.type, bo, const_cast<void *>(alignedPtr), gpuVirtualAddress,
@ -302,7 +302,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
return nullptr;
}
bo->size = allocationData.imgInfo->size;
bo->gpuAddress = GmmHelper::canonize(gpuRange);
bo->gpuAddress = gpuRange;
auto ret2 = bo->setTiling(I915_TILING_Y, static_cast<uint32_t>(allocationData.imgInfo->rowPitch));
DEBUG_BREAK_IF(ret2 != true);
@ -310,7 +310,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
bo->setUnmapSize(allocationData.imgInfo->size);
auto allocation = new DrmAllocation(allocationData.type, bo, nullptr, (uint64_t)gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible, false);
auto allocation = new DrmAllocation(allocationData.type, bo, nullptr, gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible, false);
bo->setAllocationType(allocatorType);
allocation->setDefaultGmm(gmm.release());
return allocation;
@ -342,10 +342,10 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
bo->setUnmapSize(realAllocationSize);
bo->gpuAddress = GmmHelper::canonize(gpuVirtualAddress);
bo->setAllocationType(allocatorType);
auto allocation = new DrmAllocation(allocationData.type, bo, const_cast<void *>(allocationData.hostPtr), ptrOffset(gpuVirtualAddress, inputPointerOffset),
auto allocation = new DrmAllocation(allocationData.type, bo, const_cast<void *>(allocationData.hostPtr), GmmHelper::canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)),
allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing, false);
allocation->set32BitAllocation(true);
allocation->setGpuBaseAddress(gfxPartition.getHeapBase(allocatorToUse));
allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition.getHeapBase(allocatorToUse)));
return allocation;
}
@ -379,11 +379,11 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
bo->gpuAddress = GmmHelper::canonize(res);
// softpin to the GPU address, res if it uses limitedRange Allocation
auto allocation = new DrmAllocation(allocationData.type, bo, ptrAlloc, res, alignedAllocationSize,
auto allocation = new DrmAllocation(allocationData.type, bo, ptrAlloc, GmmHelper::canonize(res), alignedAllocationSize,
MemoryPool::System4KBPagesWith32BitGpuAddressing, false);
allocation->set32BitAllocation(true);
allocation->setGpuBaseAddress(gfxPartition.getHeapBase(allocatorToUse));
allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition.getHeapBase(allocatorToUse)));
allocation->setDriverAllocatedCpuPtr(ptrAlloc);
return allocation;
}
@ -414,7 +414,7 @@ BufferObject *DrmMemoryManager::createSharedBufferObject(int boHandle, size_t si
}
bo->size = size;
bo->gpuAddress = GmmHelper::canonize(gpuRange);
bo->gpuAddress = gpuRange;
bo->setUnmapSize(size);
bo->setAllocationType(storageType);
return bo;
@ -493,10 +493,10 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation
if (!bo) {
return nullptr;
}
bo->gpuAddress = GmmHelper::canonize(gpuRange);
bo->gpuAddress = gpuRange;
bo->setUnmapSize(sizeWithPadding);
bo->setAllocationType(storageType);
return new DrmAllocation(inputGraphicsAllocation->getAllocationType(), bo, srcPtr, ptrOffset(gpuRange, offset), sizeWithPadding,
return new DrmAllocation(inputGraphicsAllocation->getAllocationType(), bo, srcPtr, GmmHelper::canonize(ptrOffset(gpuRange, offset)), sizeWithPadding,
inputGraphicsAllocation->getMemoryPool(), false);
}

View File

@ -732,7 +732,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32
EXPECT_GE(bo->peekUnmapSize(), 0u);
EXPECT_TRUE(allocation->is32BitAllocation());
EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(), allocation->getGpuBaseAddress());
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress()), allocation->getGpuBaseAddress());
EXPECT_EQ(bo->peekAllocationType(), StorageAllocatorType::BIT32_ALLOCATOR_EXTERNAL);
@ -2154,7 +2154,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAllocatorWithHeapAllocatorWhenLargerFragm
auto bo = graphicsAlloaction->getBO();
EXPECT_EQ(allocationSize, bo->peekUnmapSize());
EXPECT_EQ(pages3size, bo->peekSize());
EXPECT_EQ((uint64_t)(uintptr_t)ptr, graphicsAlloaction->getGpuAddress());
EXPECT_EQ(GmmHelper::canonize(ptr), graphicsAlloaction->getGpuAddress());
memoryManager->freeGraphicsMemory(graphicsAlloaction);
}
@ -2243,7 +2243,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = memoryManager->getInternalHeapBaseAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);
@ -2281,7 +2281,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = memoryManager->getInternalHeapBaseAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);
@ -2343,7 +2343,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = memoryManager->getInternalHeapBaseAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);