diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp index 91701d9da4..81ecc08051 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp @@ -170,6 +170,8 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { } pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->releaseEngines(); + pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->releaseRasHandles(); + pLinuxSysmanImp->releasePmtObject(); static_cast(getDevice())->releaseResources(); for (auto &&fd : myPidFds) { // Close open filedescriptors to the device diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp index 59bddd1851..7047ad3883 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp @@ -117,6 +117,12 @@ LinuxSysmanImp::LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) { this->pParentSysmanDeviceImp = pParentSysmanDeviceImp; } +void LinuxSysmanImp::releasePmtObject() { + for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject) { + delete subDeviceIdToPmtEntry.second; + } +} + LinuxSysmanImp::~LinuxSysmanImp() { if (nullptr != pSysfsAccess) { delete pSysfsAccess; @@ -142,9 +148,7 @@ LinuxSysmanImp::~LinuxSysmanImp() { delete pPmuInterface; pPmuInterface = nullptr; } - for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject) { - delete subDeviceIdToPmtEntry.second; - } + releasePmtObject(); } OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) { diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.h b/level_zero/tools/source/sysman/linux/os_sysman_imp.h index ea93da5cdc..4edf877034 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.h +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.h @@ -41,6 +41,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass { Device *getDeviceHandle(); SysmanDeviceImp *getSysmanDeviceImp(); std::string getPciRootPortDirectoryPath(std::string realPciPath); + void releasePmtObject(); protected: XmlParser *pXmlParser = nullptr; diff --git a/level_zero/tools/source/sysman/ras/ras.cpp b/level_zero/tools/source/sysman/ras/ras.cpp index 3995b37281..f7204eb7f0 100644 --- a/level_zero/tools/source/sysman/ras/ras.cpp +++ b/level_zero/tools/source/sysman/ras/ras.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,11 +11,17 @@ namespace L0 { -RasHandleContext::~RasHandleContext() { +void RasHandleContext::releaseRasHandles() { for (Ras *pRas : handleList) { delete pRas; } + handleList.clear(); } + +RasHandleContext::~RasHandleContext() { + releaseRasHandles(); +} + void RasHandleContext::createHandle(zes_ras_error_type_t type, ze_device_handle_t deviceHandle) { Ras *pRas = new RasImp(pOsSysman, type, deviceHandle); handleList.push_back(pRas); diff --git a/level_zero/tools/source/sysman/ras/ras.h b/level_zero/tools/source/sysman/ras/ras.h index 4f4c30a662..3fedbe7063 100644 --- a/level_zero/tools/source/sysman/ras/ras.h +++ b/level_zero/tools/source/sysman/ras/ras.h @@ -39,6 +39,7 @@ struct RasHandleContext { ~RasHandleContext(); void init(std::vector &deviceHandles); + void releaseRasHandles(); ze_result_t rasGet(uint32_t *pCount, zes_ras_handle_t *phRas); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/test_zes_ras.cpp b/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/test_zes_ras.cpp index 8c72f29689..a6478fc3ec 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/test_zes_ras.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/ras/linux/test_zes_ras.cpp @@ -151,8 +151,7 @@ TEST_F(SysmanRasFixture, GivenValidRasHandleWhenCallingzesRasSetConfigWithoutPer memset(setConfig.detailedThresholds.category, 1, sizeof(setConfig.detailedThresholds.category)); EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, zesRasSetConfig(handle, &setConfig)); } - pSysmanDeviceImp->pRasHandleContext->handleList.pop_back(); - delete pTestRasImp; + pSysmanDeviceImp->pRasHandleContext->releaseRasHandles(); } } // namespace ult