diff --git a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp index b994876e36..2c40dd0fb9 100644 --- a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -40,6 +40,7 @@ class IpcImplicitScalingObtainFdMockGraphicsAllocation : public NEO::DrmAllocati NEO::osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) : NEO::DrmAllocation(rootDeviceIndex, + 1u /*num gmms*/, allocationType, bo, ptrIn, @@ -456,6 +457,7 @@ class IpcObtainFdMockGraphicsAllocation : public NEO::DrmAllocation { NEO::osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) : NEO::DrmAllocation(rootDeviceIndex, + 1u /*num gmms*/, allocationType, bo, ptrIn, diff --git a/shared/source/os_interface/linux/drm_allocation.h b/shared/source/os_interface/linux/drm_allocation.h index 9916b386be..52385360ea 100644 --- a/shared/source/os_interface/linux/drm_allocation.h +++ b/shared/source/os_interface/linux/drm_allocation.h @@ -36,27 +36,18 @@ class DrmAllocation : public GraphicsAllocation { MemoryUnmapFunction unmapFunction; }; - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) - : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, sizeIn, sharedHandle, pool, canonizedGpuAddress) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, sizeIn, sharedHandle, pool, MemoryManager::maxOsContextCount, canonizedGpuAddress), bufferObjects(EngineLimits::maxHandleCount) { bufferObjects[0] = bo; handles.resize(EngineLimits::maxHandleCount, std::numeric_limits::max()); } - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, canonizedGpuAddress, sizeIn, pool) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, canonizedGpuAddress, 0, sizeIn, pool, MemoryManager::maxOsContextCount), bufferObjects(EngineLimits::maxHandleCount) { bufferObjects[0] = bo; handles.resize(EngineLimits::maxHandleCount, std::numeric_limits::max()); } - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, 1, allocationType, bos, ptrIn, canonizedGpuAddress, sizeIn, pool) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, canonizedGpuAddress, 0, sizeIn, pool, MemoryManager::maxOsContextCount), bufferObjects(bos) { diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index dd50595a44..a04ff3208f 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -343,7 +343,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocation(OsHandleStorage & auto hostPtr = const_cast(allocationData.hostPtr); auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); - auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, hostPtr, canonizedGpuAddress, allocationData.size, MemoryPool::system4KBPages); + auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, nullptr, hostPtr, canonizedGpuAddress, allocationData.size, MemoryPool::system4KBPages); allocation->fragmentsStorage = handleStorage; if (!allocation->setCacheRegion(&this->getDrm(allocationData.rootDeviceIndex), static_cast(allocationData.cacheRegion))) { return nullptr; @@ -422,7 +422,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignmentFromUserptr(const Alloc auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(bo->peekAddress()); - auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, bo.get(), res, canonizedGpuAddress, size, MemoryPool::system4KBPages); + auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), res, canonizedGpuAddress, size, MemoryPool::system4KBPages); allocation->setDriverAllocatedCpuPtr(res); allocation->setReservedAddressRange(reinterpret_cast(gpuAddress), alignedSVMSize); if (!allocation->setCacheRegion(&this->getDrm(allocationData.rootDeviceIndex), static_cast(allocationData.cacheRegion))) { @@ -472,6 +472,7 @@ GraphicsAllocation *DrmMemoryManager::allocateUSMHostGraphicsMemory(const Alloca emitPinningRequest(bo.get(), allocationData); auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, + 1u /*num gmms*/, allocationData.type, bo.get(), bufferPtr, @@ -527,7 +528,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryWithGpuVa(const Allo pinBBs.at(allocationData.rootDeviceIndex)->pin(&boPtr, 1, osContextLinux, 0, osContextLinux->getDrmContextIds()[0]); } - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), res, bo->peekAddress(), alignedSize, MemoryPool::system4KBPages); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), res, bo->peekAddress(), alignedSize, MemoryPool::system4KBPages); allocation->storageInfo = allocationData.storageInfo; allocation->setDriverAllocatedCpuPtr(res); allocation->setOsContext(osContextLinux); @@ -578,7 +579,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(con } } - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), const_cast(allocationData.hostPtr), + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), const_cast(allocationData.hostPtr), gpuVirtualAddress, allocationData.size, MemoryPool::system4KBPages); allocation->setAllocationOffset(offsetInPage); @@ -643,7 +644,7 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const Allocat std::unique_ptr bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount)); - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), nullptr, 0u, bufferSize, memoryPool); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), nullptr, 0u, bufferSize, memoryPool); allocation->setDefaultGmm(gmm.release()); bo.release(); @@ -693,7 +694,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData & bo->setAddress(gpuRange); bo->setBOType(boType); - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), nullptr, gpuRange, bufferSize, memoryPool); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), nullptr, gpuRange, bufferSize, memoryPool); if (!allocation) { return nullptr; } @@ -734,7 +735,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A [[maybe_unused]] auto ret2 = bo->setTiling(ioctlHelper->getDrmParamValue(DrmParam::tilingY), static_cast(allocationData.imgInfo->rowPitch)); DEBUG_BREAK_IF(ret2 != true); - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), nullptr, gpuRange, allocationData.imgInfo->size, memoryPool); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), nullptr, gpuRange, allocationData.imgInfo->size, memoryPool); allocation->setDefaultGmm(gmm.release()); allocation->setReservedAddressRange(reinterpret_cast(gpuRange), allocationData.imgInfo->size); @@ -767,7 +768,7 @@ GraphicsAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allo bo->setAddress(gpuVirtualAddress); auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)); - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), const_cast(allocationData.hostPtr), + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), const_cast(allocationData.hostPtr), canonizedGpuAddress, allocationSize, MemoryPool::system4KBPagesWith32BitGpuAddressing); allocation->set32BitAllocation(true); @@ -806,7 +807,7 @@ GraphicsAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allo // softpin to the GPU address, res if it uses limitedRange Allocation auto canonizedGpuAddress = gmmHelper->canonize(gpuVA); - auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), ptrAlloc, + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), ptrAlloc, canonizedGpuAddress, alignedAllocationSize, MemoryPool::system4KBPagesWith32BitGpuAddressing); @@ -1092,7 +1093,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); - auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), + auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), handle, memoryPool, canonizedGpuAddress); if (requireSpecificBitness && this->force32bitAllocations) { @@ -2280,7 +2281,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData & auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(bo->peekAddress()); - auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, canonizedGpuAddress, alignedSize, memoryPool); + auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), cpuPointer, canonizedGpuAddress, alignedSize, memoryPool); allocation->setMmapPtr(cpuPointer); allocation->setMmapSize(alignedSize); if (pointerDiff != 0) { @@ -2487,7 +2488,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(reinterpret_cast(cpuPointer)); - auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, bos, cpuPointer, canonizedGpuAddress, size, memoryPool); + auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bos, cpuPointer, canonizedGpuAddress, size, memoryPool); allocation->setMmapPtr(cpuBasePointer); allocation->setMmapSize(totalSizeToAlloc); allocation->setReservedAddressRange(reinterpret_cast(preferredAddress), totalSizeToAlloc); @@ -2555,7 +2556,7 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); - auto allocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), + auto allocation = new DrmAllocation(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), handle, memoryPool, canonizedGpuAddress); allocation->setImportedMmapPtr(mappedPtr); return allocation; @@ -2572,6 +2573,7 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); auto drmAllocation = std::make_unique(properties.rootDeviceIndex, + 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), @@ -2646,7 +2648,7 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl pushSharedBufferObject(bo); - auto drmAllocation = std::make_unique(properties.rootDeviceIndex, properties.allocationType, bo, cpuPointer, bo->peekAddress(), bo->peekSize(), memoryPool); + auto drmAllocation = std::make_unique(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, cpuPointer, bo->peekAddress(), bo->peekSize(), memoryPool); drmAllocation->setMmapPtr(cpuPointer); drmAllocation->setMmapSize(size); drmAllocation->setReservedAddressRange(reinterpret_cast(cpuPointer), size); @@ -2664,7 +2666,7 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); - return new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), + return new DrmAllocation(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), handle, memoryPool, canonizedGpuAddress); } bool DrmMemoryManager::allowIndirectAllocationsAsPack(uint32_t rootDeviceIndex) { diff --git a/shared/test/common/mocks/linux/mock_drm_allocation.h b/shared/test/common/mocks/linux/mock_drm_allocation.h index 423f28384c..a9ac910618 100644 --- a/shared/test/common/mocks/linux/mock_drm_allocation.h +++ b/shared/test/common/mocks/linux/mock_drm_allocation.h @@ -64,7 +64,7 @@ class MockDrmAllocation : public DrmAllocation { using DrmAllocation::registeredBoBindHandles; MockDrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, allocationType, nullptr, nullptr, 0, static_cast(0), pool) { + : DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, allocationType, nullptr, nullptr, 0, static_cast(0), pool) { } MockDrmAllocation(AllocationType allocationType, MemoryPool pool, BufferObjects &bos) diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp index e4fbfcaf35..7aedcb253a 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -272,7 +272,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmCsrCreatedWithInactiveG HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmAllocationWhenGetBufferObjectToModifyIsCalledForAGivenHandleIdThenTheCorrespondingBufferObjectGetsModified) { auto size = 1024u; - auto allocation = new DrmAllocation(0, AllocationType::unknown, nullptr, nullptr, size, static_cast(0u), MemoryPool::memoryNull); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, size, static_cast(0u), MemoryPool::memoryNull); auto &bos = allocation->getBOs(); for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) { @@ -292,7 +292,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmAllocationWhenGetBuffer HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, WhenMakingResidentThenSucceeds) { auto buffer = this->createBO(1024); - auto allocation = new DrmAllocation(0, AllocationType::unknown, buffer, nullptr, buffer->peekSize(), static_cast(0u), MemoryPool::memoryNull); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, buffer, nullptr, buffer->peekSize(), static_cast(0u), MemoryPool::memoryNull); EXPECT_EQ(nullptr, allocation->getUnderlyingBuffer()); csr->makeResident(*allocation); @@ -310,8 +310,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, WhenMakingResidentThenSucceeds) HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenMultipleAllocationsWhenMakingResidentThenEachSucceeds) { BufferObject *buffer1 = this->createBO(4096); BufferObject *buffer2 = this->createBO(4096); - auto allocation1 = new DrmAllocation(0, AllocationType::unknown, buffer1, nullptr, buffer1->peekSize(), static_cast(0u), MemoryPool::memoryNull); - auto allocation2 = new DrmAllocation(0, AllocationType::unknown, buffer2, nullptr, buffer2->peekSize(), static_cast(0u), MemoryPool::memoryNull); + auto allocation1 = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, buffer1, nullptr, buffer1->peekSize(), static_cast(0u), MemoryPool::memoryNull); + auto allocation2 = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, buffer2, nullptr, buffer2->peekSize(), static_cast(0u), MemoryPool::memoryNull); EXPECT_EQ(nullptr, allocation1->getUnderlyingBuffer()); EXPECT_EQ(nullptr, allocation2->getUnderlyingBuffer()); @@ -334,7 +334,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenMultipleAllocationsWhenMak HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, WhenMakingResidentTwiceThenRefCountIsOne) { auto buffer = this->createBO(1024); - auto allocation = new DrmAllocation(0, AllocationType::unknown, buffer, nullptr, buffer->peekSize(), static_cast(0u), MemoryPool::memoryNull); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, buffer, nullptr, buffer->peekSize(), static_cast(0u), MemoryPool::memoryNull); csr->makeResident(*allocation); csr->processResidency(csr->getResidencyAllocations(), 0u); @@ -831,7 +831,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmCommandStreamReceiverWh struct MockDrmAllocationBindBO : public DrmAllocation { MockDrmAllocationBindBO(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { + : DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } ADDMETHOD_NOBASE(bindBO, int, 0, @@ -840,7 +840,7 @@ struct MockDrmAllocationBindBO : public DrmAllocation { struct MockDrmAllocationBindBOs : public DrmAllocation { MockDrmAllocationBindBOs(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { + : DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } ADDMETHOD_NOBASE(bindBOs, int, 0, @@ -950,7 +950,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocationWithSingleBuffer auto size = 1024u; auto bo = this->createBO(size); BufferObjects bos{bo}; - auto allocation = new DrmAllocation(0, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); EXPECT_EQ(bo, allocation->getBO()); makeResidentBufferObjects(&csr->getOsContext(), allocation); diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp index 64f8bc5bf4..1fb6b0d9b5 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp @@ -125,7 +125,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenDebugFlagSetWhenSubmittingThenCall } HWTEST_TEMPLATED_F(DrmCommandStreamTest, WhenMakingResidentThenSucceeds) { - DrmAllocation graphicsAllocation(0, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); csr->makeResident(graphicsAllocation); EXPECT_EQ(0, mock->ioctlCount.gemUserptr); @@ -137,7 +137,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, WhenMakingResidentThenSucceeds) { } HWTEST_TEMPLATED_F(DrmCommandStreamTest, WhenMakingResidentTwiceThenSucceeds) { - DrmAllocation graphicsAllocation(0, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); csr->makeResident(graphicsAllocation); csr->makeResident(graphicsAllocation); @@ -151,7 +151,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, WhenMakingResidentTwiceThenSucceeds) { } HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenSizeZeroWhenMakingResidentTwiceThenSucceeds) { - DrmAllocation graphicsAllocation(0, AllocationType::unknown, nullptr, nullptr, 0, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0, static_cast(1u), MemoryPool::memoryNull); csr->makeResident(graphicsAllocation); @@ -164,8 +164,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenSizeZeroWhenMakingResidentTwiceThe } HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenResizedWhenMakingResidentTwiceThenSucceeds) { - DrmAllocation graphicsAllocation(0, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); - DrmAllocation graphicsAllocation2(0, AllocationType::unknown, nullptr, nullptr, 8192, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation graphicsAllocation2(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 8192, static_cast(1u), MemoryPool::memoryNull); csr->makeResident(graphicsAllocation); csr->makeResident(graphicsAllocation2); @@ -302,7 +302,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenInvalidAddressWhenFlushingThenSucc ASSERT_NE(nullptr, commandBuffer); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(commandBuffer)); - DrmAllocation commandBufferAllocation(0, AllocationType::commandBuffer, nullptr, commandBuffer, 1024, static_cast(1u), MemoryPool::memoryNull, canonizedGpuAddress); + DrmAllocation commandBufferAllocation(0, 1u /*num gmms*/, AllocationType::commandBuffer, nullptr, commandBuffer, 1024, static_cast(1u), MemoryPool::memoryNull, canonizedGpuAddress); LinearStream cs(&commandBufferAllocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -395,8 +395,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenNotAlignedWhenFlushingThenSucceeds HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenCheckFlagsWhenFlushingThenSucceeds) { auto &cs = csr->getCS(); - DrmAllocation allocation(0, AllocationType::unknown, nullptr, (void *)0x7FFFFFFF, 1024, static_cast(0u), MemoryPool::memoryNull); - DrmAllocation allocation2(0, AllocationType::unknown, nullptr, (void *)0x307FFFFFFF, 1024, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, (void *)0x7FFFFFFF, 1024, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation allocation2(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, (void *)0x307FFFFFFF, 1024, static_cast(0u), MemoryPool::memoryNull); csr->makeResident(allocation); csr->makeResident(allocation2); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -420,7 +420,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenCheckDrmFreeWhenFlushingThenSuccee auto expectedBatchStartOffset = (reinterpret_cast(commandBuffer->getUnderlyingBuffer()) + 4) & (this->alignment - 1); auto expectedSize = alignUp(8u, MemoryConstants::cacheLineSize); // bbEnd - DrmAllocation allocation(0, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(0u), MemoryPool::memoryNull); csr->makeResident(allocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -463,7 +463,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenCheckDrmFreeCloseFailedWhenFlushin mock->storedRetValForGemClose = -1; - DrmAllocation allocation(0, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 1024, static_cast(0u), MemoryPool::memoryNull); csr->makeResident(allocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp index 8157c7608c..4e3639e038 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -32,7 +32,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocationWithMultipleBuff auto bo2 = this->createBO(size); auto bo3 = this->createBO(size); BufferObjects bos{bo0, bo1, bo2, bo3}; - auto allocation = new DrmAllocation(0, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); allocation->storageInfo.memoryBanks = maxNBitValue(MemoryBanks::getBankForLocalMemory(3)); csr->CommandStreamReceiver::makeResident(*allocation); @@ -258,7 +258,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocationWithMultipleBuff auto bo2 = this->createBO(size); auto bo3 = this->createBO(size); BufferObjects bos{bo0, bo1, bo2, bo3}; - auto allocation = new DrmAllocation(0, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bos, nullptr, 0u, size, MemoryPool::localMemory); allocation->storageInfo.memoryBanks = maxNBitValue(MemoryBanks::getBankForLocalMemory(3)); allocation->storageInfo.tileInstanced = true; @@ -466,14 +466,14 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenTwoTilesW auto multiStorageBo0 = new BufferObject(0u, drm, 3, 30, 0, 1); auto multiStorageBo1 = new BufferObject(0u, drm, 3, 31, 0, 1); BufferObjects multiStorageBos{multiStorageBo0, multiStorageBo1}; - auto multiStorageAllocation = new DrmAllocation(0, AllocationType::unknown, multiStorageBos, nullptr, 0u, size, MemoryPool::localMemory); + auto multiStorageAllocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, multiStorageBos, nullptr, 0u, size, MemoryPool::localMemory); multiStorageAllocation->storageInfo.memoryBanks = 0b11; csr->CommandStreamReceiver::makeResident(*multiStorageAllocation); auto tileInstancedBo0 = new BufferObject(0u, drm, 3, 40, 0, 1); auto tileInstancedBo1 = new BufferObject(0u, drm, 3, 41, 0, 1); BufferObjects tileInstancedBos{tileInstancedBo0, tileInstancedBo1}; - auto tileInstancedAllocation = new DrmAllocation(0, AllocationType::unknown, tileInstancedBos, nullptr, 0u, size, MemoryPool::localMemory); + auto tileInstancedAllocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, tileInstancedBos, nullptr, 0u, size, MemoryPool::localMemory); tileInstancedAllocation->storageInfo.memoryBanks = 0b11; tileInstancedAllocation->storageInfo.tileInstanced = true; csr->CommandStreamReceiver::makeResident(*tileInstancedAllocation); @@ -540,7 +540,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, whenForceExecu auto tileInstancedBo2 = new BufferObject(0u, drm, 3, 42, 0, 1); auto tileInstancedBo3 = new BufferObject(0u, drm, 3, 43, 0, 1); BufferObjects tileInstancedBos{tileInstancedBo0, tileInstancedBo1, tileInstancedBo2, tileInstancedBo3}; - auto tileInstancedAllocation = new DrmAllocation(0, AllocationType::unknown, tileInstancedBos, nullptr, 0u, 1024u, MemoryPool::localMemory); + auto tileInstancedAllocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, tileInstancedBos, nullptr, 0u, 1024u, MemoryPool::localMemory); tileInstancedAllocation->storageInfo.memoryBanks = 0b11; tileInstancedAllocation->storageInfo.tileInstanced = true; csr->CommandStreamReceiver::makeResident(*tileInstancedAllocation); @@ -583,7 +583,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, whenForceExecu auto tileInstancedBo2 = new BufferObject(0u, drm, 3, 42, 0, 1); auto tileInstancedBo3 = new BufferObject(0u, drm, 3, 43, 0, 1); BufferObjects tileInstancedBos{tileInstancedBo0, tileInstancedBo1, tileInstancedBo2, tileInstancedBo3}; - auto tileInstancedAllocation = new DrmAllocation(0, AllocationType::unknown, tileInstancedBos, nullptr, 0u, 1024u, MemoryPool::localMemory); + auto tileInstancedAllocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, tileInstancedBos, nullptr, 0u, 1024u, MemoryPool::localMemory); tileInstancedAllocation->storageInfo.memoryBanks = 0b11; tileInstancedAllocation->storageInfo.tileInstanced = true; csr->CommandStreamReceiver::makeResident(*tileInstancedAllocation); @@ -629,7 +629,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenDisabledI const auto size = 1024u; BufferObject *bufferObject = new BufferObject(0u, drm, 3, 30, 0, 1); BufferObjects bufferObjects{bufferObject}; - auto allocation = new DrmAllocation(0, AllocationType::unknown, bufferObjects, nullptr, 0u, size, MemoryPool::localMemory); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bufferObjects, nullptr, 0u, size, MemoryPool::localMemory); csr->CommandStreamReceiver::makeResident(*allocation); auto &cs = csr->getCS(); @@ -663,7 +663,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DrmImplicitScalingCommandStreamTest, givenMultiTile const auto size = 1024u; BufferObject *bufferObject = new BufferObject(0u, drm, 3, 30, 0, 1); BufferObjects bufferObjects{bufferObject}; - auto allocation = new DrmAllocation(0, AllocationType::unknown, bufferObjects, nullptr, 0u, size, MemoryPool::localMemory); + auto allocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bufferObjects, nullptr, 0u, size, MemoryPool::localMemory); csr->CommandStreamReceiver::makeResident(*allocation); auto &cs = csr->getCS(); diff --git a/shared/test/unit_test/os_interface/linux/drm_gem_close_worker_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_gem_close_worker_tests.cpp index 236d2c4a52..f6d82f847e 100644 --- a/shared/test/unit_test/os_interface/linux/drm_gem_close_worker_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_gem_close_worker_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -90,7 +90,7 @@ class DrmGemCloseWorkerFixture { class DrmAllocationWrapper : public DrmAllocation { public: DrmAllocationWrapper(BufferObject *bo) - : DrmAllocation(0, AllocationType::unknown, bo, nullptr, 0, static_cast(0u), MemoryPool::memoryNull) { + : DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bo, nullptr, 0, static_cast(0u), MemoryPool::memoryNull) { } }; MockExecutionEnvironment executionEnvironment; diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp index c52117090a..94866b0ed2 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp @@ -31,7 +31,7 @@ TEST_F(DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnBufferObjectThenReturnPtr) { BufferObject bo(0, mock, 3, 1, 1024, 1); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_EQ(&bo, drmAllocation.getBO()); auto ptr = memoryManager->lockBufferObject(&bo); @@ -2599,7 +2599,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerWhenLockUnlockIsCalledOn mock->ioctlResExt = &ioctlResExt; BufferObject bo(0, mock, 3, 1, 0, 1); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2614,7 +2614,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerWhenLockUnlockIsCalledOn mock->failOnMmapOffset = true; BufferObject bo(0, mock, 3, 1, 0, 1); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2838,7 +2838,7 @@ TEST_F(DrmMemoryManagerTestPrelim, MmapFailWhenUSMHostAllocationFromSharedHandle } TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButBufferObjectIsNullThenReturnNullPtr) { - DrmAllocation drmAllocation(0, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); auto ptr = memoryManager->lockResource(&drmAllocation); EXPECT_EQ(nullptr, ptr); @@ -2995,7 +2995,7 @@ TEST(AllocationInfoLogging, givenDrmGraphicsAllocationWithMultipleBOsWhenGetting BufferObject bo0(0, &drm, 3, 0, 0, 1), bo1(0, &drm, 3, 1, 0, 1), bo2(0, &drm, 3, 2, 0, 1), bo3(0, &drm, 3, 3, 0, 1); BufferObjects bos{&bo0, &bo1, &bo2, &bo3}; - DrmAllocation drmAllocation(0, AllocationType::unknown, bos, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, bos, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_STREQ(drmAllocation.getAllocationInfoString().c_str(), " Handle: 0 Handle: 1 Handle: 2 Handle: 3"); } diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_upstream_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_upstream_tests.cpp index d176bee536..54274cfe12 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_upstream_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_upstream_tests.cpp @@ -645,7 +645,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWithLocalMemoryWhen TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnBufferObjectThenReturnPtr) { BufferObject bo(0, mock, 3, 1, 1024, 0); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_EQ(&bo, drmAllocation.getBO()); auto ptr = memoryManager->lockBufferObject(&bo); @@ -848,7 +848,7 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAl mockExp->ioctlResExt = &ioctlResExt; BufferObject bo(0, mockExp, 3, 1, 0, 0); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -864,7 +864,7 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAl mockExp->failOnMmapOffset = true; BufferObject bo(0, mockExp, 3, 1, 0, 0); - DrmAllocation drmAllocation(0, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -875,7 +875,7 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAl } TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButBufferObjectIsNullThenReturnNullPtr) { - DrmAllocation drmAllocation(0, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); auto ptr = memoryManager->lockResource(&drmAllocation); EXPECT_EQ(nullptr, ptr); diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 006a0a7abf..6d77024cb3 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -278,7 +278,7 @@ TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationTo size_t size = 0x1000; const uint32_t rootDeviceIndex = 0u; - DrmAllocation gfxAllocation(rootDeviceIndex, AllocationType::unknown, nullptr, cpuPtr, size, static_cast(1u), MemoryPool::memoryNull); + DrmAllocation gfxAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, nullptr, cpuPtr, size, static_cast(1u), MemoryPool::memoryNull); memoryManager->addAllocationToHostPtrManager(&gfxAllocation); auto fragment = memoryManager->getHostPtrManager()->getFragment({gfxAllocation.getUnderlyingBuffer(), rootDeviceIndex}); EXPECT_NE(fragment, nullptr); @@ -2475,7 +2475,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnNullAl } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationWithoutBufferObjectThenReturnNullPtr) { - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, nullptr, nullptr, 0, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0, static_cast(0u), MemoryPool::memoryNull); EXPECT_EQ(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2490,7 +2490,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledButFails mock->ioctlResExt = &ioctlResExt; BufferObject bo(rootDeviceIndex, mock, 3, 1, 0, 1); - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2520,7 +2520,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenUnlockResourceIsCalledOnAl DrmMockCustom drmMock(*executionEnvironment->rootDeviceEnvironments[1]); auto bo = new BufferObject(rootDeviceIndex, &drmMock, 3, 1, 0, 1); - auto drmAllocation = new DrmAllocation(rootDeviceIndex, AllocationType::unknown, bo, nullptr, 0u, static_cast(0u), MemoryPool::localMemory); + auto drmAllocation = new DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, bo, nullptr, 0u, static_cast(0u), MemoryPool::localMemory); drmMemoryManager.unlockResourceImpl(*drmAllocation); EXPECT_TRUE(drmMemoryManager.unlockResourceInLocalMemoryImplParam.called); @@ -2530,7 +2530,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenUnlockResourceIsCalledOnAl } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllocationWithoutBufferObjectThenReturnFalse) { - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, nullptr, nullptr, 0, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0, static_cast(0u), MemoryPool::memoryNull); EXPECT_EQ(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, false); @@ -2544,7 +2544,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledButFai DrmMockCustom drmMock(*executionEnvironment->rootDeviceEnvironments[0]); BufferObject bo(0u, &drmMock, 3, 1, 0, 1); - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, false); @@ -2557,7 +2557,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllo DrmMockCustom drmMock(*executionEnvironment->rootDeviceEnvironments[0]); BufferObject bo(rootDeviceIndex, &drmMock, 3, 1, 0, 1); - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, &bo, nullptr, 0u, static_cast(0u), MemoryPool::memoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, true); @@ -3719,18 +3719,18 @@ struct DrmAllocationTests : public ::testing::Test { }; TEST_F(DrmAllocationTests, givenAllocationTypeWhenPassedToDrmAllocationConstructorThenAllocationTypeIsStored) { - DrmAllocation allocation{0, AllocationType::commandBuffer, nullptr, nullptr, static_cast(0), 0u, MemoryPool::memoryNull}; + DrmAllocation allocation{0, 1u /*num gmms*/, AllocationType::commandBuffer, nullptr, nullptr, static_cast(0), 0u, MemoryPool::memoryNull}; EXPECT_EQ(AllocationType::commandBuffer, allocation.getAllocationType()); - DrmAllocation allocation2{0, AllocationType::unknown, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::memoryNull}; + DrmAllocation allocation2{0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::memoryNull}; EXPECT_EQ(AllocationType::unknown, allocation2.getAllocationType()); } TEST_F(DrmAllocationTests, givenMemoryPoolWhenPassedToDrmAllocationConstructorThenMemoryPoolIsStored) { - DrmAllocation allocation{0, AllocationType::commandBuffer, nullptr, nullptr, static_cast(0), 0u, MemoryPool::system64KBPages}; + DrmAllocation allocation{0, 1u /*num gmms*/, AllocationType::commandBuffer, nullptr, nullptr, static_cast(0), 0u, MemoryPool::system64KBPages}; EXPECT_EQ(MemoryPool::system64KBPages, allocation.getMemoryPool()); - DrmAllocation allocation2{0, AllocationType::unknown, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::systemCpuInaccessible}; + DrmAllocation allocation2{0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::systemCpuInaccessible}; EXPECT_EQ(MemoryPool::systemCpuInaccessible, allocation2.getMemoryPool()); } @@ -4902,7 +4902,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmAllocationWithHostPtrWhenItIsCreatedWithCac memoryManager->populateOsHandles(storage, rootDeviceIndex); - auto allocation = std::make_unique(rootDeviceIndex, AllocationType::bufferHostMemory, + auto allocation = std::make_unique(rootDeviceIndex, 1u /*num gmms*/, AllocationType::bufferHostMemory, nullptr, ptr, castToUint64(ptr), size, MemoryPool::system4KBPages); allocation->fragmentsStorage = storage; @@ -5033,7 +5033,7 @@ TEST_F(DrmMemoryManagerTest, whenDebugFlagToNotFreeResourcesIsSpecifiedThenFreeI TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment); size_t sizeIn = 1024llu; uint64_t gpuAddress = 0x1337llu; - DrmAllocation stackDrmAllocation(0u, AllocationType::buffer, nullptr, nullptr, gpuAddress, sizeIn, MemoryPool::system64KBPages); + DrmAllocation stackDrmAllocation(0u, 1u /*num gmms*/, AllocationType::buffer, nullptr, nullptr, gpuAddress, sizeIn, MemoryPool::system64KBPages); memoryManager.freeGraphicsMemoryImpl(&stackDrmAllocation); } @@ -5103,7 +5103,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmManagerWithLocalMemoryWhenLockResourceIsCal DrmMemoryManagerToTestLockInLocalMemory memoryManager(*executionEnvironment); BufferObject bo(rootDeviceIndex, mock, 3, 1, 1024, 0); - DrmAllocation drmAllocation(0, AllocationType::writeCombined, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::writeCombined, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_EQ(&bo, drmAllocation.getBO()); auto ptr = memoryManager.lockResourceImpl(drmAllocation); @@ -5235,7 +5235,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOn executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(drm)); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false); TestedDrmMemoryManager memoryManager(executionEnvironment); - DrmAllocation drmAllocation(0, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); auto ptr = memoryManager.lockBufferObject(drmAllocation.getBO()); EXPECT_EQ(nullptr, ptr); @@ -5251,7 +5251,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCa executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false); TestedDrmMemoryManager memoryManager(executionEnvironment); - auto drmAllocation = new DrmAllocation(0, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); + auto drmAllocation = new DrmAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_NE(nullptr, drmAllocation); memoryManager.freeGraphicsMemoryImpl(drmAllocation); @@ -5268,7 +5268,7 @@ TEST(DrmMemoryManagerSimpleTest, WhenDrmIsCreatedThenQueryPageFaultSupportIsCall using DrmMemoryManagerWithLocalMemoryTest = Test; TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnAllocationInLocalMemoryThenReturnNullPtr) { - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unknown, nullptr, nullptr, 0u, 0u, MemoryPool::localMemory); auto ptr = memoryManager->lockResource(&drmAllocation); EXPECT_EQ(nullptr, ptr); @@ -5334,7 +5334,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetMemAdviseIsCalledThenUp TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment); BufferObject bo(rootDeviceIndex, mock, 3, 1, 1024, 0); - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unifiedSharedMemory, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unifiedSharedMemory, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_EQ(&bo, drmAllocation.getBO()); for (auto isCached : {false, true}) { @@ -5350,7 +5350,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetAtomicAccessIsCalledThe TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment); BufferObject bo(rootDeviceIndex, mock, 3, 1, 1024, 0); - DrmAllocation drmAllocation(rootDeviceIndex, AllocationType::unifiedSharedMemory, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); + DrmAllocation drmAllocation(rootDeviceIndex, 1u /*num gmms*/, AllocationType::unifiedSharedMemory, &bo, nullptr, 0u, 0u, MemoryPool::localMemory); EXPECT_EQ(&bo, drmAllocation.getBO()); size_t size = 16; diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp index 85c932b6c8..6c573f7a41 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp @@ -536,7 +536,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenEvictImplFailsThenEvictWithinOsC TEST_F(DrmMemoryOperationsHandlerBindTest, givenMakeBOsResidentFailsThenMakeResidentWithinOsContextReturnsError) { struct MockDrmAllocationBOsResident : public DrmAllocation { MockDrmAllocationBOsResident(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { + : DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } int makeBOsResident(OsContext *osContext, uint32_t vmHandleId, std::vector *bufferObjects, bool bind) override { @@ -560,7 +560,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenDrmAllocationWithChunkingAndmakeResidentWithinOsContextCalledThenprefetchBOWithChunkingCalled) { struct MockDrmAllocationBOsResident : public DrmAllocation { MockDrmAllocationBOsResident(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { + : DrmAllocation(rootDeviceIndex, 1u /*num gmms*/, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } }; DebugManagerStateRestore restore; @@ -1242,7 +1242,7 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenDebugFlagSetWhenVmBindCalledTh EXPECT_EQ(2u, patIndex); MockBufferObject bo(0, mock, patIndex, 0, 0, 1); - DrmAllocation allocation(0, AllocationType::buffer, &bo, nullptr, 0x1234000, 1, MemoryPool::localMemory); + DrmAllocation allocation(0, 1u /*num gmms*/, AllocationType::buffer, &bo, nullptr, 0x1234000, 1, MemoryPool::localMemory); GraphicsAllocation *allocPtr = &allocation; @@ -1273,7 +1273,7 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenDebugFlagSetWhenVmBindCalledTh EXPECT_EQ(3u, patIndex); MockBufferObject bo(0, mock, patIndex, 0, 0, 1); - DrmAllocation allocation(0, AllocationType::buffer, &bo, nullptr, 0x1234000, 1, MemoryPool::system4KBPages); + DrmAllocation allocation(0, 1u /*num gmms*/, AllocationType::buffer, &bo, nullptr, 0x1234000, 1, MemoryPool::system4KBPages); GraphicsAllocation *allocPtr = &allocation;