From ae566a42d84eae09e3cf821ef8ea0c2731abab4d Mon Sep 17 00:00:00 2001 From: "Kulkarni, Ashwin Kumar" Date: Tue, 7 Mar 2023 06:56:39 +0000 Subject: [PATCH] Disable context creation when NEO_L0_SYSMAN_NO_CONTEXT_MODE is set Related-To: LOCI-4031 Signed-off-by: Kulkarni, Ashwin Kumar --- .../source/os_interface/windows/wddm/wddm.cpp | 26 +++++++++++-------- .../os_interface/windows/wddm_tests.cpp | 9 +++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 57b37303a7..a10df59bd5 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -25,6 +25,7 @@ #include "shared/source/helpers/string.h" #include "shared/source/helpers/windows/gmm_callbacks.h" #include "shared/source/memory_manager/gfx_partition.h" +#include "shared/source/os_interface/debug_env_reader.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/os_interface/windows/driver_info_windows.h" @@ -958,19 +959,22 @@ bool Wddm::createContext(OsContextWin &osContext) { } createContext.hDevice = device; - status = getGdi()->createContext(&createContext); - osContext.setWddmContextHandle(createContext.hContext); + NEO::EnvironmentVariableReader envReader; + bool sysmanDisableContextCreationFlag = envReader.getSetting("NEO_L0_SYSMAN_NO_CONTEXT_MODE", false); + if (!sysmanDisableContextCreationFlag) { + status = getGdi()->createContext(&createContext); + osContext.setWddmContextHandle(createContext.hContext); - PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, - "\nCreated Wddm context. Status: :%lu, engine: %u, contextId: %u, deviceBitfield: %lu \n", - status, osContext.getEngineType(), osContext.getContextId(), osContext.getDeviceBitfield().to_ulong()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, + "\nCreated Wddm context. Status: :%lu, engine: %u, contextId: %u, deviceBitfield: %lu \n", + status, osContext.getEngineType(), osContext.getContextId(), osContext.getDeviceBitfield().to_ulong()); - if (status != STATUS_SUCCESS) { - return false; - } - - if (osContext.isLowPriority()) { - return setLowPriorityContextParam(osContext.getWddmContextHandle()); + if (status != STATUS_SUCCESS) { + return false; + } + if (osContext.isLowPriority()) { + return setLowPriorityContextParam(osContext.getWddmContextHandle()); + } } return true; diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index 63fc16c329..84505adfdb 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -11,6 +11,7 @@ #include "shared/source/os_interface/windows/wddm/um_km_data_translator.h" #include "shared/source/os_interface/windows/wddm_allocation.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/os_interface/windows/wddm_fixture.h" #include "shared/test/common/test_macros/hw_test.h" @@ -93,6 +94,14 @@ TEST_F(WddmTests, whenProgramDebugIsEnabledAndCreatingContextWithInternalEngineT osContext.ensureContextInitialized(); EXPECT_FALSE(osContext.isDebuggableContext()); } +TEST_F(WddmTests, WhenCreatingContextWithContextCreateDisabledFlagEnabledThenContextHandleIsNull) { + std::unordered_map mockableEnvs = {{"NEO_L0_SYSMAN_NO_CONTEXT_MODE", "1"}}; + VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); + init(); + auto newContext = osContext.get(); + EXPECT_TRUE(wddm->createContext(*newContext)); + EXPECT_EQ(0u, newContext->getWddmContextHandle()); +} TEST(WddmPciSpeedInfoTest, WhenGetPciSpeedInfoIsCalledThenUnknownIsReturned) { MockExecutionEnvironment executionEnvironment;