sysman:close diagnostics handles before reset

Relates-to:LOCI-2650

Signed-off-by: T J Vivek Vilvaraj <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
T J Vivek Vilvaraj 2021-11-09 14:12:15 +00:00 committed by Compute-Runtime-Automation
parent 9aad34bb1c
commit e1a1e96110
8 changed files with 47 additions and 17 deletions

View File

@ -12,12 +12,15 @@
namespace L0 { namespace L0 {
class OsDiagnostics; class OsDiagnostics;
DiagnosticsHandleContext::~DiagnosticsHandleContext() { DiagnosticsHandleContext::~DiagnosticsHandleContext() {
releaseDiagnosticsHandles();
}
void DiagnosticsHandleContext::releaseDiagnosticsHandles() {
for (Diagnostics *pDiagnostics : handleList) { for (Diagnostics *pDiagnostics : handleList) {
delete pDiagnostics; delete pDiagnostics;
} }
handleList.clear(); handleList.clear();
} }
void DiagnosticsHandleContext::createHandle(ze_device_handle_t deviceHandle, const std::string &diagTests) { void DiagnosticsHandleContext::createHandle(ze_device_handle_t deviceHandle, const std::string &diagTests) {
Diagnostics *pDiagnostics = new DiagnosticsImp(pOsSysman, diagTests, deviceHandle); Diagnostics *pDiagnostics = new DiagnosticsImp(pOsSysman, diagTests, deviceHandle);
handleList.push_back(pDiagnostics); handleList.push_back(pDiagnostics);

View File

@ -35,6 +35,7 @@ class Diagnostics : _zes_diag_handle_t {
struct DiagnosticsHandleContext { struct DiagnosticsHandleContext {
DiagnosticsHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){}; DiagnosticsHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
void releaseDiagnosticsHandles();
~DiagnosticsHandleContext(); ~DiagnosticsHandleContext();
void init(std::vector<ze_device_handle_t> &deviceHandles); void init(std::vector<ze_device_handle_t> &deviceHandles);

View File

@ -12,12 +12,15 @@
namespace L0 { namespace L0 {
class OsFirmware; class OsFirmware;
FirmwareHandleContext::~FirmwareHandleContext() { FirmwareHandleContext::~FirmwareHandleContext() {
releaseFwHandles();
}
void FirmwareHandleContext::releaseFwHandles() {
for (Firmware *pFirmware : handleList) { for (Firmware *pFirmware : handleList) {
delete pFirmware; delete pFirmware;
} }
handleList.clear(); handleList.clear();
} }
void FirmwareHandleContext::createHandle(const std::string &fwType) { void FirmwareHandleContext::createHandle(const std::string &fwType) {
Firmware *pFirmware = new FirmwareImp(pOsSysman, fwType); Firmware *pFirmware = new FirmwareImp(pOsSysman, fwType);
if (pFirmware->isFirmwareEnabled == true) { if (pFirmware->isFirmwareEnabled == true) {

View File

@ -36,6 +36,7 @@ class Firmware : _zes_firmware_handle_t {
struct FirmwareHandleContext { struct FirmwareHandleContext {
FirmwareHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){}; FirmwareHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
~FirmwareHandleContext(); ~FirmwareHandleContext();
void releaseFwHandles();
void init(); void init();

View File

@ -124,7 +124,10 @@ static void getPidFdsForOpenDevice(ProcfsAccess *pProcfsAccess, SysfsAccess *pSy
void LinuxGlobalOperationsImp::releaseSysmanDeviceResources() { void LinuxGlobalOperationsImp::releaseSysmanDeviceResources() {
pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->releaseEngines(); pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->releaseEngines();
pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->releaseRasHandles(); pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->releaseRasHandles();
pLinuxSysmanImp->getSysmanDeviceImp()->pDiagnosticsHandleContext->releaseDiagnosticsHandles();
pLinuxSysmanImp->getSysmanDeviceImp()->pFirmwareHandleContext->releaseFwHandles();
pLinuxSysmanImp->releasePmtObject(); pLinuxSysmanImp->releasePmtObject();
pLinuxSysmanImp->releaseFwUtilInterface();
pLinuxSysmanImp->releaseLocalDrmHandle(); pLinuxSysmanImp->releaseLocalDrmHandle();
} }
@ -140,8 +143,11 @@ void LinuxGlobalOperationsImp::releaseDeviceResources() {
void LinuxGlobalOperationsImp::reInitSysmanDeviceResources() { void LinuxGlobalOperationsImp::reInitSysmanDeviceResources() {
pLinuxSysmanImp->getSysmanDeviceImp()->updateSubDeviceHandlesLocally(); pLinuxSysmanImp->getSysmanDeviceImp()->updateSubDeviceHandlesLocally();
pLinuxSysmanImp->createPmtHandles(); pLinuxSysmanImp->createPmtHandles();
pLinuxSysmanImp->createFwUtilInterface();
pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->init(pLinuxSysmanImp->getSysmanDeviceImp()->deviceHandles); pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->init(pLinuxSysmanImp->getSysmanDeviceImp()->deviceHandles);
pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->init(); pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->init();
pLinuxSysmanImp->getSysmanDeviceImp()->pDiagnosticsHandleContext->init(pLinuxSysmanImp->getSysmanDeviceImp()->deviceHandles);
pLinuxSysmanImp->getSysmanDeviceImp()->pFirmwareHandleContext->init();
} }
ze_result_t LinuxGlobalOperationsImp::initDevice() { ze_result_t LinuxGlobalOperationsImp::initDevice() {
@ -322,9 +328,9 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
if (ZE_RESULT_SUCCESS != result) { if (ZE_RESULT_SUCCESS != result) {
if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) { if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) {
//update the result as Success as ZE_RESULT_ERROR_NOT_AVAILABLE is expected if the "realClientPidPath" folder is empty // update the result as Success as ZE_RESULT_ERROR_NOT_AVAILABLE is expected if the "realClientPidPath" folder is empty
//this condition(when encountered) must not prevent the information accumulated for other clientIds // this condition(when encountered) must not prevent the information accumulated for other clientIds
//this situation occurs when there is no call modifying result, // this situation occurs when there is no call modifying result,
result = ZE_RESULT_SUCCESS; result = ZE_RESULT_SUCCESS;
continue; continue;
} else { } else {
@ -338,10 +344,10 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
result = pSysfsAccess->scanDirEntries(busyDirForEngines, engineNums); result = pSysfsAccess->scanDirEntries(busyDirForEngines, engineNums);
if (ZE_RESULT_SUCCESS != result) { if (ZE_RESULT_SUCCESS != result) {
if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) { if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) {
//update the result as Success as ZE_RESULT_ERROR_NOT_AVAILABLE is expected if the "realClientPidPath" folder is empty // update the result as Success as ZE_RESULT_ERROR_NOT_AVAILABLE is expected if the "realClientPidPath" folder is empty
//this condition(when encountered) must not prevent the information accumulated for other clientIds // this condition(when encountered) must not prevent the information accumulated for other clientIds
//this situation occurs when there is no call modifying result, // this situation occurs when there is no call modifying result,
//Here its seen when the last element of clientIds returns ZE_RESULT_ERROR_NOT_AVAILABLE for some reason. // Here its seen when the last element of clientIds returns ZE_RESULT_ERROR_NOT_AVAILABLE for some reason.
engineType = ZES_ENGINE_TYPE_FLAG_OTHER; // When busy node is absent assign engine type with ZES_ENGINE_TYPE_FLAG_OTHER engineType = ZES_ENGINE_TYPE_FLAG_OTHER; // When busy node is absent assign engine type with ZES_ENGINE_TYPE_FLAG_OTHER
} else { } else {
return result; return result;
@ -444,7 +450,6 @@ LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess(); pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
pFsAccess = &pLinuxSysmanImp->getFsAccess(); pFsAccess = &pLinuxSysmanImp->getFsAccess();
pDevice = pLinuxSysmanImp->getDeviceHandle(); pDevice = pLinuxSysmanImp->getDeviceHandle();
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
auto device = static_cast<DeviceImp *>(pDevice); auto device = static_cast<DeviceImp *>(pDevice);
devicePciBdf = device->getNEODevice()->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>()->getPciPath(); devicePciBdf = device->getNEODevice()->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>()->getPciPath();
executionEnvironment = device->getNEODevice()->getExecutionEnvironment(); executionEnvironment = device->getNEODevice()->getExecutionEnvironment();

View File

@ -37,8 +37,6 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
SysfsAccess *pSysfsAccess = nullptr; SysfsAccess *pSysfsAccess = nullptr;
LinuxSysmanImp *pLinuxSysmanImp = nullptr; LinuxSysmanImp *pLinuxSysmanImp = nullptr;
Device *pDevice = nullptr; Device *pDevice = nullptr;
FirmwareUtil *pFwInterface = nullptr;
int resetTimeout = 10000; // in milliseconds int resetTimeout = 10000; // in milliseconds
void releaseSysmanDeviceResources(); void releaseSysmanDeviceResources();
void releaseDeviceResources(); void releaseDeviceResources();

View File

@ -9,6 +9,8 @@
#include "level_zero/tools/source/sysman/linux/fs_access.h" #include "level_zero/tools/source/sysman/linux/fs_access.h"
#include "sysman/linux/firmware_util/firmware_util.h"
namespace L0 { namespace L0 {
ze_result_t LinuxSysmanImp::init() { ze_result_t LinuxSysmanImp::init() {
@ -39,10 +41,22 @@ ze_result_t LinuxSysmanImp::init() {
pPmuInterface = PmuInterface::create(this); pPmuInterface = PmuInterface::create(this);
DEBUG_BREAK_IF(nullptr == pPmuInterface); DEBUG_BREAK_IF(nullptr == pPmuInterface);
pFwUtilInterface = FirmwareUtil::create(pDrm->getPciPath());
createFwUtilInterface();
return createPmtHandles(); return createPmtHandles();
} }
void LinuxSysmanImp::createFwUtilInterface() {
std::string realRootPath;
auto result = pSysfsAccess->getRealPath("device", realRootPath);
if (ZE_RESULT_SUCCESS != result) {
return;
}
auto rootPciPathOfGpuDevice = getPciRootPortDirectoryPath(realRootPath);
auto loc = realRootPath.find_last_of('/');
pFwUtilInterface = FirmwareUtil::create(realRootPath.substr(loc + 1, std::string::npos));
}
ze_result_t LinuxSysmanImp::createPmtHandles() { ze_result_t LinuxSysmanImp::createPmtHandles() {
std::string realRootPath; std::string realRootPath;
auto result = pSysfsAccess->getRealPath("device", realRootPath); auto result = pSysfsAccess->getRealPath("device", realRootPath);
@ -146,6 +160,12 @@ void LinuxSysmanImp::releasePmtObject() {
} }
mapOfSubDeviceIdToPmtObject.clear(); mapOfSubDeviceIdToPmtObject.clear();
} }
void LinuxSysmanImp::releaseFwUtilInterface() {
if (nullptr != pFwUtilInterface) {
delete pFwUtilInterface;
pFwUtilInterface = nullptr;
}
}
LinuxSysmanImp::~LinuxSysmanImp() { LinuxSysmanImp::~LinuxSysmanImp() {
if (nullptr != pSysfsAccess) { if (nullptr != pSysfsAccess) {
@ -160,14 +180,11 @@ LinuxSysmanImp::~LinuxSysmanImp() {
delete pFsAccess; delete pFsAccess;
pFsAccess = nullptr; pFsAccess = nullptr;
} }
if (nullptr != pFwUtilInterface) {
delete pFwUtilInterface;
pFwUtilInterface = nullptr;
}
if (nullptr != pPmuInterface) { if (nullptr != pPmuInterface) {
delete pPmuInterface; delete pPmuInterface;
pPmuInterface = nullptr; pPmuInterface = nullptr;
} }
releaseFwUtilInterface();
releasePmtObject(); releasePmtObject();
} }

View File

@ -41,6 +41,8 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
std::string getPciRootPortDirectoryPath(std::string realPciPath); std::string getPciRootPortDirectoryPath(std::string realPciPath);
void releasePmtObject(); void releasePmtObject();
ze_result_t createPmtHandles(); ze_result_t createPmtHandles();
void createFwUtilInterface();
void releaseFwUtilInterface();
void releaseLocalDrmHandle(); void releaseLocalDrmHandle();
protected: protected: