diff --git a/opencl/source/os_interface/linux/device_command_stream.inl b/opencl/source/os_interface/linux/device_command_stream.inl index 815083d9a4..52ed82573f 100644 --- a/opencl/source/os_interface/linux/device_command_stream.inl +++ b/opencl/source/os_interface/linux/device_command_stream.inl @@ -24,20 +24,9 @@ CommandStreamReceiver *createDrmCommandStreamReceiver(bool withAubDump, rootDeviceIndex, deviceBitfield); } else { - auto gemMode = gemCloseWorkerMode::gemCloseWorkerActive; - - if (DebugManager.flags.EnableDirectSubmission.get() == 1) { - gemMode = gemCloseWorkerMode::gemCloseWorkerInactive; - } - - if (DebugManager.flags.EnableGemCloseWorker.get() != -1) { - gemMode = DebugManager.flags.EnableGemCloseWorker.get() ? gemCloseWorkerMode::gemCloseWorkerActive : gemCloseWorkerMode::gemCloseWorkerInactive; - } - return new DrmCommandStreamReceiver(executionEnvironment, rootDeviceIndex, - deviceBitfield, - gemMode); + deviceBitfield); } } } // namespace NEO diff --git a/opencl/source/os_interface/linux/drm_command_stream.inl b/opencl/source/os_interface/linux/drm_command_stream.inl index 93c6ffaa68..8647694063 100644 --- a/opencl/source/os_interface/linux/drm_command_stream.inl +++ b/opencl/source/os_interface/linux/drm_command_stream.inl @@ -44,6 +44,14 @@ DrmCommandStreamReceiver::DrmCommandStreamReceiver(ExecutionEnvironme residency.reserve(512); execObjectsStorage.reserve(512); + if (this->drm->isVmBindAvailable()) { + gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive; + } + + if (DebugManager.flags.EnableGemCloseWorker.get() != -1) { + gemCloseWorkerOperationMode = DebugManager.flags.EnableGemCloseWorker.get() ? gemCloseWorkerMode::gemCloseWorkerActive : gemCloseWorkerMode::gemCloseWorkerInactive; + } + auto hwInfo = rootDeviceEnvironment->getHardwareInfo(); auto localMemoryEnabled = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*hwInfo); diff --git a/opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp b/opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp index ae5a23a874..72296e50d2 100644 --- a/opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp @@ -103,13 +103,3 @@ HWTEST_F(DeviceCommandStreamSetInternalUsageTests, givenValidDrmCsrThenGemCloseW drmCsr->initializeDefaultsForInternalEngine(); EXPECT_EQ(drmCsr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive); } - -HWTEST_F(DeviceCommandStreamSetInternalUsageTests, givenEnableDirectSubmissionWhenCreateDrmCommandStreamReceiverThenGemCloseWorkerInactive) { - DebugManagerStateRestore restorer; - DebugManager.flags.EnableDirectSubmission.set(1); - - std::unique_ptr ptr(DeviceCommandStreamReceiver::create(false, *executionEnvironment, 0, 1)); - - auto drmCsr = (DrmCommandStreamReceiver *)ptr.get(); - EXPECT_EQ(drmCsr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive); -} diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index d5327a56cb..eeea7c1157 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -90,24 +90,6 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableWhenCreatingDrmMemoryManagerThenS } } -TEST_F(DrmMemoryManagerTest, whenNewResidencyModelAvailableThenGemCloseWorkerInactive) { - auto drm = static_cast(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as()); - drm->bindAvailable = true; - - memoryManager->disableGemCloseWorkerForNewResidencyModel(); - - for (const auto &engine : memoryManager->getRegisteredEngines()) { - auto engineRootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex(); - auto rootDeviceDrm = static_cast(executionEnvironment->rootDeviceEnvironments[engineRootDeviceIndex]->osInterface->getDriverModel()->as()); - - auto csr = static_cast *>(engine.commandStreamReceiver); - EXPECT_TRUE(rootDeviceDrm->isVmBindAvailable()); - EXPECT_EQ(csr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive); - } - - this->dontTestIoctlInTearDown = true; -} - TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCheckForKmdMigrationThenCorrectValueIsReturned) { DebugManagerStateRestore restorer; auto drm = static_cast(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as()); @@ -775,14 +757,15 @@ TEST(DrmMemoryManagerTest2, givenDrmMemoryManagerWhengetSystemSharedMemoryIsCall auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(4u); for (auto i = 0u; i < 4u; i++) { + auto mock = new DrmMockCustom(); + executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique(); + executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr(mock)); executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); } auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (auto i = 0u; i < 4u; i++) { - auto mock = new DrmMockCustom(); - executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique(); - executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr(mock)); + auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as(); mock->getContextParamRetValue = 16 * MemoryConstants::gigaByte; uint64_t mem = memoryManager->getSystemSharedMemory(i); @@ -808,20 +791,24 @@ TEST(DrmMemoryManagerTest2, WhenGetMinimumSystemSharedMemoryThenCorrectValueIsRe executionEnvironment->prepareRootDeviceEnvironments(4u); for (auto i = 0u; i < 4u; i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); - } - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); - for (auto i = 0u; i < 4u; i++) { auto mock = new DrmMockCustom(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr(mock)); + } + + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); + + for (auto i = 0u; i < 4u; i++) { + auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as(); auto hostMemorySize = MemoryConstants::pageSize * (uint64_t)(sysconf(_SC_PHYS_PAGES)); // gpuMemSize < hostMemSize auto gpuMemorySize = hostMemorySize - 1u; + + mock->ioctl_expected.contextGetParam = 1; mock->getContextParamRetValue = gpuMemorySize; uint64_t systemSharedMemorySize = memoryManager->getSystemSharedMemory(i); - mock->ioctl_expected.contextGetParam = 1; EXPECT_EQ(gpuMemorySize, systemSharedMemorySize); mock->ioctl_expected.contextDestroy = 0; @@ -3852,12 +3839,13 @@ TEST(DrmMemoryManagerWithExplicitExpectationsTest2, whenObtainFdFromHandleIsCall executionEnvironment->prepareRootDeviceEnvironments(4u); for (auto i = 0u; i < 4u; i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); - } - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); - for (auto i = 0u; i < 4u; i++) { auto mock = new DrmMockCustom(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr(mock)); + } + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); + for (auto i = 0u; i < 4u; i++) { + auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as(); int boHandle = 3; mock->outputFd = 1337; @@ -4128,10 +4116,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhe auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(1u); executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(mockDrm)); + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); EXPECT_FALSE(mockDrm->resourceRegistrationEnabled()); @@ -4149,10 +4137,10 @@ TEST(DrmMemoryManager, givenResourceRegistrationEnabledAndAllocTypeToCaptureWhen auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(1u); executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(mockDrm)); + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); // mock resource registration enabling by storing class handles mockDrm->classHandles.push_back(1); @@ -4175,10 +4163,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenAllocatingThenAllocationIsR auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(1u); executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(mockDrm)); + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (uint32_t i = 3; i < 3 + static_cast(Drm::ResourceClass::MaxSize); i++) { mockDrm->classHandles.push_back(i); @@ -4205,10 +4193,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenFreeingThenRegisteredHandle auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(1u); executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); - auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(mockDrm)); + auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (uint32_t i = 3; i < 3 + static_cast(Drm::ResourceClass::MaxSize); i++) { mockDrm->classHandles.push_back(i); diff --git a/shared/source/memory_manager/memory_manager.h b/shared/source/memory_manager/memory_manager.h index 8ca99ea7fd..1660bd156f 100644 --- a/shared/source/memory_manager/memory_manager.h +++ b/shared/source/memory_manager/memory_manager.h @@ -210,7 +210,6 @@ class MemoryManager { virtual void registerSysMemAlloc(GraphicsAllocation *allocation){}; virtual void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex){}; - virtual void disableGemCloseWorkerForNewResidencyModel(){}; bool isLocalMemoryUsedForIsa(uint32_t rootDeviceIndex); protected: diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index ec61e2edb1..a9ffb02899 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -155,8 +155,6 @@ std::vector> DeviceFactory::createDevices(ExecutionEnvir } } - executionEnvironment.memoryManager->disableGemCloseWorkerForNewResidencyModel(); - return devices; } diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index f75b60b46e..9c474ef627 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -53,6 +53,8 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode, } void DrmMemoryManager::initialize(gemCloseWorkerMode mode) { + bool disableGemCloseWorker = true; + for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < gfxPartitions.size(); ++rootDeviceIndex) { auto gpuAddressSpace = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->capabilityTable.gpuAddressSpace; if (!getGfxPartition(rootDeviceIndex)->init(gpuAddressSpace, getSizeToReserve(), rootDeviceIndex, gfxPartitions.size(), heapAssigner.apiAllowExternalHeapForSshAndDsh)) { @@ -60,10 +62,11 @@ void DrmMemoryManager::initialize(gemCloseWorkerMode mode) { return; } localMemAllocs.emplace_back(); + disableGemCloseWorker &= getDrm(rootDeviceIndex).isVmBindAvailable(); } MemoryManager::virtualPaddingAvailable = true; - if (DebugManager.flags.EnableDirectSubmission.get() == 1) { + if (disableGemCloseWorker) { mode = gemCloseWorkerMode::gemCloseWorkerInactive; } @@ -1008,17 +1011,6 @@ void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) { localMemAllocs[allocation->getRootDeviceIndex()].end()); } -void DrmMemoryManager::disableGemCloseWorkerForNewResidencyModel() { - for (auto &engine : this->registeredEngines) { - auto rootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex(); - auto &drm = this->getDrm(rootDeviceIndex); - - if (drm.isVmBindAvailable()) { - engine.commandStreamReceiver->initializeDefaultsForInternalEngine(); - } - } -} - void DrmMemoryManager::registerAllocationInOs(GraphicsAllocation *allocation) { if (allocation && getDrm(allocation->getRootDeviceIndex()).resourceRegistrationEnabled()) { auto drmAllocation = static_cast(allocation); diff --git a/shared/source/os_interface/linux/drm_memory_manager.h b/shared/source/os_interface/linux/drm_memory_manager.h index 87e810e1f9..43c81ab65e 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.h +++ b/shared/source/os_interface/linux/drm_memory_manager.h @@ -71,8 +71,6 @@ class DrmMemoryManager : public MemoryManager { void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) override; void unregisterAllocation(GraphicsAllocation *allocation); - void disableGemCloseWorkerForNewResidencyModel() override; - static std::unique_ptr create(ExecutionEnvironment &executionEnvironment); DrmAllocation *createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool hasMappedPtr);