diff --git a/shared/source/os_interface/linux/drm_allocation.cpp b/shared/source/os_interface/linux/drm_allocation.cpp index 8782570f15..b60fae500e 100644 --- a/shared/source/os_interface/linux/drm_allocation.cpp +++ b/shared/source/os_interface/linux/drm_allocation.cpp @@ -38,19 +38,11 @@ std::string DrmAllocation::getAllocationInfoString() const { } uint64_t DrmAllocation::peekInternalHandle(MemoryManager *memoryManager) { - if (handles[0] != std::numeric_limits::max()) { - return handles[0]; - } - handles[0] = static_cast((static_cast(memoryManager))->obtainFdFromHandle(getBO()->peekHandle(), this->rootDeviceIndex)); - return handles[0]; + return static_cast((static_cast(memoryManager))->obtainFdFromHandle(getBO()->peekHandle(), this->rootDeviceIndex)); } uint64_t DrmAllocation::peekInternalHandle(MemoryManager *memoryManager, uint32_t handleId) { - if (handles[handleId] != std::numeric_limits::max()) { - return handles[handleId]; - } - handles[handleId] = static_cast((static_cast(memoryManager))->obtainFdFromHandle(getBufferObjectToModify(handleId)->peekHandle(), this->rootDeviceIndex)); - return handles[handleId]; + return static_cast((static_cast(memoryManager))->obtainFdFromHandle(getBufferObjectToModify(handleId)->peekHandle(), this->rootDeviceIndex)); } void DrmAllocation::setCachePolicy(CachePolicy memType) { diff --git a/shared/source/os_interface/linux/drm_allocation.h b/shared/source/os_interface/linux/drm_allocation.h index 8734a5fce3..3341191183 100644 --- a/shared/source/os_interface/linux/drm_allocation.h +++ b/shared/source/os_interface/linux/drm_allocation.h @@ -40,7 +40,6 @@ class DrmAllocation : public GraphicsAllocation { 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) @@ -49,7 +48,6 @@ class DrmAllocation : public GraphicsAllocation { 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) @@ -58,7 +56,6 @@ class DrmAllocation : public GraphicsAllocation { 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) { - handles.resize(EngineLimits::maxHandleCount, std::numeric_limits::max()); } ~DrmAllocation() override; @@ -122,7 +119,6 @@ class DrmAllocation : public GraphicsAllocation { MemAdviseFlags enabledMemAdviseFlags{}; StackVec memoryToUnmap; uint32_t numHandles = 0u; - std::vector handles; void *mmapPtr = nullptr; size_t mmapSize = 0u; diff --git a/shared/test/common/libult/linux/drm_mock.h b/shared/test/common/libult/linux/drm_mock.h index 011126c39c..3e67de81c2 100644 --- a/shared/test/common/libult/linux/drm_mock.h +++ b/shared/test/common/libult/linux/drm_mock.h @@ -225,7 +225,6 @@ class DrmMock : public Drm { int fdToHandleRetVal = 0; //DRM_IOCTL_HANDLE_TO_FD int32_t outputFd = 0; - bool incrementOutputFdAfterCall = false; //DRM_IOCTL_I915_GEM_USERPTR uint32_t returnHandle = 0; uint64_t gpuMemSize = 3u * MemoryConstants::gigaByte; diff --git a/shared/test/common/os_interface/linux/device_command_stream_fixture.cpp b/shared/test/common/os_interface/linux/device_command_stream_fixture.cpp index 5f209e913d..0d76265e74 100644 --- a/shared/test/common/os_interface/linux/device_command_stream_fixture.cpp +++ b/shared/test/common/os_interface/linux/device_command_stream_fixture.cpp @@ -124,9 +124,6 @@ int DrmMockCustom::ioctl(DrmIoctl request, void *arg) { inputHandle = handleToPrimeParams->handle; inputFlags = handleToPrimeParams->flags; handleToPrimeParams->fileDescriptor = outputFd; - if (incrementOutputFdAfterCall) { - outputFd++; - } ioctl_cnt.handleToPrimeFd++; } break; case DrmIoctl::GemSetDomain: { diff --git a/shared/test/common/os_interface/linux/device_command_stream_fixture.h b/shared/test/common/os_interface/linux/device_command_stream_fixture.h index 43821c6e6e..55cc4c1452 100644 --- a/shared/test/common/os_interface/linux/device_command_stream_fixture.h +++ b/shared/test/common/os_interface/linux/device_command_stream_fixture.h @@ -191,7 +191,6 @@ class DrmMockCustom : public Drm { //DRM_IOCTL_PRIME_HANDLE_TO_FD uint32_t inputHandle = 0; int32_t outputFd = 0; - bool incrementOutputFdAfterCall = false; int32_t inputFlags = 0; //DRM_IOCTL_I915_GEM_USERPTR uint32_t returnHandle = 0; 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 7362669e8c..4b35108594 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 @@ -441,7 +441,7 @@ TEST_F(DrmMemoryManagerTest, WhenAskedAndAllowedAndBigAllocationThenPinAfterAllo memoryManager->freeGraphicsMemory(alloc); } -TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleIsCalledThenBoIsReturned) { +TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleIsCalledThenBoIsReturend) { mock->ioctl_expected.gemUserptr = 1; mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; @@ -454,32 +454,7 @@ TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleIsCalledThenBoIsReturned) { memoryManager->freeGraphicsMemory(allocation); } -TEST_F(DrmMemoryManagerTest, whenCallingPeekInternalHandleSeveralTimesThenSameHandleIsReturned) { - mock->ioctl_expected.gemUserptr = 1; - mock->ioctl_expected.gemWait = 1; - mock->ioctl_expected.gemClose = 1; - mock->ioctl_expected.handleToPrimeFd = 1; - uint64_t expectedFd = 1337; - mock->outputFd = static_cast(expectedFd); - mock->incrementOutputFdAfterCall = true; - auto allocation = static_cast(this->memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, 10 * MemoryConstants::pageSize, true))); - ASSERT_NE(allocation->getBO(), nullptr); - - EXPECT_EQ(mock->outputFd, static_cast(expectedFd)); - uint64_t handle0 = allocation->peekInternalHandle(this->memoryManager); - EXPECT_NE(mock->outputFd, static_cast(expectedFd)); - - uint64_t handle1 = allocation->peekInternalHandle(this->memoryManager); - uint64_t handle2 = allocation->peekInternalHandle(this->memoryManager); - - ASSERT_EQ(handle0, expectedFd); - ASSERT_EQ(handle1, expectedFd); - ASSERT_EQ(handle2, expectedFd); - - memoryManager->freeGraphicsMemory(allocation); -} - -TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleWithHandleIdIsCalledThenBoIsReturned) { +TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleWithHandleIdIsCalledThenBoIsReturend) { mock->ioctl_expected.gemUserptr = 1; mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; @@ -494,32 +469,6 @@ TEST_F(DrmMemoryManagerTest, whenPeekInternalHandleWithHandleIdIsCalledThenBoIsR memoryManager->freeGraphicsMemory(allocation); } -TEST_F(DrmMemoryManagerTest, whenCallingPeekInternalHandleWithIdSeveralTimesThenSameHandleIsReturned) { - mock->ioctl_expected.gemUserptr = 1; - mock->ioctl_expected.gemWait = 1; - mock->ioctl_expected.gemClose = 1; - mock->ioctl_expected.handleToPrimeFd = 1; - uint64_t expectedFd = 1337; - mock->outputFd = static_cast(expectedFd); - mock->incrementOutputFdAfterCall = true; - auto allocation = static_cast(this->memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, 10 * MemoryConstants::pageSize, true))); - ASSERT_NE(allocation->getBO(), nullptr); - - EXPECT_EQ(mock->outputFd, static_cast(expectedFd)); - uint32_t handleId = 0; - uint64_t handle0 = allocation->peekInternalHandle(this->memoryManager, handleId); - EXPECT_NE(mock->outputFd, static_cast(expectedFd)); - - uint64_t handle1 = allocation->peekInternalHandle(this->memoryManager, handleId); - uint64_t handle2 = allocation->peekInternalHandle(this->memoryManager, handleId); - - ASSERT_EQ(handle0, expectedFd); - ASSERT_EQ(handle1, expectedFd); - ASSERT_EQ(handle2, expectedFd); - - memoryManager->freeGraphicsMemory(allocation); -} - TEST_F(DrmMemoryManagerTest, givenDrmContextIdWhenAllocationIsCreatedThenPinWithPassedDrmContextId) { mock->ioctl_expected.gemUserptr = 2; mock->ioctl_expected.execbuffer2 = 1;