diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index da162ef379..b9ab0251c3 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -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(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(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(allocationData.hostPtr), ptrOffset(gpuVirtualAddress, inputPointerOffset), + auto allocation = new DrmAllocation(allocationData.type, bo, const_cast(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); } diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 678563338b..35aa34d043 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -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);