diff --git a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp index 7b5e586fcb..36a8fc1195 100644 --- a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp +++ b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp @@ -105,6 +105,12 @@ ze_result_t SysmanKmdInterface::getNumEngineTypeAndInstancesForSubDevices(std::m std::string sysfsEngineDirNode = sysfEngineString + std::to_string(engine.engineInstance); auto level0EngineType = sysfsEngineMapToLevel0EngineType.find(sysfEngineString); + if (level0EngineType == sysfsEngineMapToLevel0EngineType.end()) { + NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, + "Error@ %s(): unknown engine type: %s and returning error:0x%x \n", __FUNCTION__, sysfEngineString.c_str(), + ZE_RESULT_ERROR_UNKNOWN); + return ZE_RESULT_ERROR_UNKNOWN; + } auto ret = mapOfEngines.find(level0EngineType->second); if (ret != mapOfEngines.end()) { ret->second.push_back(sysfsEngineDirNode); diff --git a/level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp b/level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp index 600f1bd390..e9d5a75d16 100644 --- a/level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp +++ b/level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp @@ -66,6 +66,10 @@ void LinuxEngineImp::checkErrorNumberAndUpdateStatus() { void LinuxEngineImp::init() { auto i915EngineClass = engineToI915Map.find(engineGroup); + if (i915EngineClass == engineToI915Map.end()) { + checkErrorNumberAndUpdateStatus(); + return; + } vfConfigs.clear(); // I915_PMU_ENGINE_BUSY macro provides the perf type config which we want to listen to get the engine busyness. auto fd = pPmuInterface->pmuInterfaceOpen(I915_PMU_ENGINE_BUSY(i915EngineClass->second, engineInstance), -1, PERF_FORMAT_TOTAL_TIME_ENABLED); diff --git a/level_zero/tools/source/sysman/linux/pmt/pmt.cpp b/level_zero/tools/source/sysman/linux/pmt/pmt.cpp index 0664dceb7d..68257b2372 100644 --- a/level_zero/tools/source/sysman/linux/pmt/pmt.cpp +++ b/level_zero/tools/source/sysman/linux/pmt/pmt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -97,9 +97,11 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, // listOfTelemNodes vector could contain non "telem" entries which are not interested to us. // Lets refactor listOfTelemNodes vector as below - for (auto iterator = listOfTelemNodes.begin(); iterator != listOfTelemNodes.end(); iterator++) { + for (auto iterator = listOfTelemNodes.begin(); iterator != listOfTelemNodes.end();) { if (iterator->compare(0, telem.size(), telem) != 0) { - listOfTelemNodes.erase(iterator--); // Remove entry if its suffix is not "telem" + iterator = listOfTelemNodes.erase(iterator); // Remove entry if its suffix is not "telem" + } else { + iterator++; } } diff --git a/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp_prelim.cpp b/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp_prelim.cpp index c52a451aeb..e0b89e3681 100644 --- a/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp_prelim.cpp +++ b/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -496,6 +496,7 @@ static ze_result_t getNumEngineTypeAndInstancesForSubDevices(std::mapsecond + std::to_string(engine.engineInstance); auto level0EngineType = sysfsEngineMapToLevel0EngineType.find(sysfEngineString->second); + UNRECOVERABLE_IF(level0EngineType == sysfsEngineMapToLevel0EngineType.end()); auto ret = mapOfEngines.find(level0EngineType->second); if (ret != mapOfEngines.end()) { ret->second.push_back(sysfsEngineDirNode); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/engine/linux/test_zes_engine.cpp b/level_zero/tools/test/unit_tests/sources/sysman/engine/linux/test_zes_engine.cpp index dd8da2cce6..bd4c468d30 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/engine/linux/test_zes_engine.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/engine/linux/test_zes_engine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -206,6 +206,12 @@ TEST_F(ZesEngineFixture, GivenPerfEventOpenFailsWhenEnumeratingHandlesThenFailur EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, engineImp->isEngineModuleSupported()); } +TEST_F(ZesEngineFixture, GivenPerfEventOpenFailsWhenEnumeratingHandlesUnsupportedEngineClassIsPassedThenFailureIsObserved) { + pPmuInterface->mockPerfEventFailureReturnValue = -1; + std::unique_ptr engineImp = std::make_unique(pOsSysman, ZES_ENGINE_GROUP_RENDER_ALL, 1, 0, false); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, engineImp->isEngineModuleSupported()); +} + TEST_F(ZesEngineFixture, GivenPerfEventOpenFailsBecauseOfHandlesUnavailableThenFailureIsObserved) { pPmuInterface->mockPerfEventFailureReturnValue = -1; {