diff --git a/level_zero/tools/source/debug/windows/debug_session.cpp b/level_zero/tools/source/debug/windows/debug_session.cpp index df348fbf2b..48eb300372 100644 --- a/level_zero/tools/source/debug/windows/debug_session.cpp +++ b/level_zero/tools/source/debug/windows/debug_session.cpp @@ -35,6 +35,13 @@ DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *dev auto debugSession = createDebugSessionHelper(config, device, 0, nullptr); debugSession->setAttachMode(isRootAttach); + if (debugSession->getTopologyMap().count(0) == 0) { + result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + PRINT_DEBUGGER_ERROR_LOG("Topology map not valid, debug session cannot be created\n"); + delete debugSession; + debugSession = nullptr; + return debugSession; + } result = debugSession->initialize(); if (result != ZE_RESULT_SUCCESS) { debugSession->closeConnection(); diff --git a/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp b/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp index 905b6d9685..beb2be0523 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp @@ -17,6 +17,7 @@ #include "level_zero/tools/source/debug/debug_handlers.h" #include "level_zero/tools/source/debug/windows/debug_session.h" #include "level_zero/tools/test/unit_tests/sources/debug/debug_session_common.h" +#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h" #include "common/StateSaveAreaHeader.h" @@ -164,6 +165,7 @@ struct DebugApiWindowsFixture : public DeviceFixture { WddmEuDebugInterfaceMock *mockWddm = nullptr; }; +extern CreateDebugSessionHelperFunc createDebugSessionFunc; using DebugApiWindowsAttentionTest = Test; TEST_F(DebugApiWindowsAttentionTest, GivenEuAttentionEventForThreadsWhenHandlingEventThenNewlyStoppedThreadsSaved) { @@ -477,6 +479,28 @@ TEST_F(DebugApiWindowsTest, givenDebugAttachIsNotAvailableWhenGetDebugProperties EXPECT_EQ(0u, debugProperties.flags); } +TEST_F(DebugApiWindowsTest, givenInvalidTopologyDebugAttachCalledThenUnsupportedErrorIsReturned) { + zet_debug_config_t config = {}; + config.pid = 0x1234; + + NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get(), 0)); + auto mockWddm = new WddmEuDebugInterfaceMock(*neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(mockWddm)); + Mock deviceImp(neoDevice, neoDevice->getExecutionEnvironment()); + ze_result_t result = ZE_RESULT_SUCCESS; + + VariableBackup mockCreateDebugSessionBackup(&L0::ult::createDebugSessionFunc, [](const zet_debug_config_t &config, L0::Device *device, int debugFd, void *params) -> DebugSession * { + auto session = new DebugSessionMock(config, device); + session->topologyMap.erase(0); + return session; + }); + + auto session = DebugSession::create(config, &deviceImp, result, true); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); + EXPECT_EQ(nullptr, session); +} + TEST_F(DebugApiWindowsTest, givenSubDeviceWhenDebugAttachCalledThenUnsupportedErrorIsReturned) { zet_debug_config_t config = {}; config.pid = 0x1234; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index a10df59bd5..f482ed0323 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -140,11 +140,7 @@ bool Wddm::init() { gmmMemory.reset(GmmMemory::create(rootDeviceEnvironment.getGmmClientContext())); } - if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) { - if (!buildTopologyMapping()) { - return false; - } - } + buildTopologyMapping(); return configureDeviceAddressSpace(); } @@ -160,9 +156,7 @@ void Wddm::setPlatformSupportEvictIfNecessaryFlag(const ProductHelper &productHe } bool Wddm::buildTopologyMapping() { - auto hwInfo = rootDeviceEnvironment.getHardwareInfo(); - UNRECOVERABLE_IF(hwInfo->gtSystemInfo.MultiTileArchInfo.TileCount > 1); TopologyMapping mapping; if (!translateTopologyInfo(mapping)) { PRINT_DEBUGGER_ERROR_LOG("translateTopologyInfo Failed\n", ""); 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 41de633934..8fdd94b06f 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -181,13 +181,12 @@ TEST_F(WddmTests, GivengtSystemInfoSliceInfoHasEnabledSlicesAtHigherIndicesThenE &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace)); - wddm->rootDeviceEnvironment.executionEnvironment.setDebuggingMode(NEO::DebuggingMode::Online); EXPECT_TRUE(wddm->init()); const auto &topologyMap = wddm->getTopologyMap(); EXPECT_EQ(topologyMap.size(), 1u); } -TEST_F(WddmTests, GivenProperTopologyDataAndDebugFlagsEnabledWhenInitializingWddmThenExpectTopologyMapCreateAndReturnTrue) { +TEST_F(WddmTests, GivenProperTopologyDataWhenInitializingWddmThenExpectTopologyMapCreateAndReturnTrue) { VariableBackup backupHwInfo(defaultHwInfo.get()); defaultHwInfo.get()->gtSystemInfo.MaxSlicesSupported = GT_MAX_SLICE; defaultHwInfo.get()->gtSystemInfo.IsDynamicallyPopulated = true; @@ -206,13 +205,12 @@ TEST_F(WddmTests, GivenProperTopologyDataAndDebugFlagsEnabledWhenInitializingWdd &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace)); - wddm->rootDeviceEnvironment.executionEnvironment.setDebuggingMode(NEO::DebuggingMode::Online); EXPECT_TRUE(wddm->init()); const auto &topologyMap = wddm->getTopologyMap(); EXPECT_EQ(topologyMap.size(), 1u); } -TEST_F(WddmTests, GivenNoSubsliceEnabledAndDebugFlagsEnabledWhenInitializingWddmThenExpectTopologyMapNotCreateAndReturnFalse) { +TEST_F(WddmTests, GivenNoSubsliceEnabledAndDebugFlagsEnabledWhenInitializingWddmThenExpectTopologyMapNotCreated) { VariableBackup backupHwInfo(defaultHwInfo.get()); defaultHwInfo.get()->gtSystemInfo.MaxSlicesSupported = GT_MAX_SLICE; defaultHwInfo.get()->gtSystemInfo.SliceCount = 1; // Only one slice enabled @@ -227,8 +225,7 @@ TEST_F(WddmTests, GivenNoSubsliceEnabledAndDebugFlagsEnabledWhenInitializingWddm &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace)); - wddm->rootDeviceEnvironment.executionEnvironment.setDebuggingMode(NEO::DebuggingMode::Online); - EXPECT_FALSE(wddm->init()); + EXPECT_TRUE(wddm->init()); const auto &topologyMap = wddm->getTopologyMap(); EXPECT_TRUE(topologyMap.empty()); }