Skip to content

Commit 9a39cad

Browse files
sysman:add reinitialization code to diagnostics
Signed-off-by: T J Vivek Vilvaraj <[email protected]>
1 parent 70a7840 commit 9a39cad

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

level_zero/tools/source/sysman/diagnostics/linux/os_diagnostics_imp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include "shared/source/helpers/string.h"
1111

12+
#include "level_zero/core/source/device/device_imp.h"
13+
1214
namespace L0 {
1315
const std::string LinuxDiagnosticsImp::deviceDir("device");
1416

@@ -34,6 +36,10 @@ LinuxDiagnosticsImp::LinuxDiagnosticsImp(OsSysman *pOsSysman, const std::string
3436
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
3537
pFsAccess = &pLinuxSysmanImp->getFsAccess();
3638
pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
39+
pDevice = pLinuxSysmanImp->getDeviceHandle();
40+
auto device = static_cast<DeviceImp *>(pDevice);
41+
executionEnvironment = device->getNEODevice()->getExecutionEnvironment();
42+
rootDeviceIndex = device->getNEODevice()->getRootDeviceIndex();
3743
}
3844

3945
std::unique_ptr<OsDiagnostics> OsDiagnostics::create(OsSysman *pOsSysman, const std::string &diagTests, ze_bool_t onSubdevice, uint32_t subdeviceId) {

level_zero/tools/source/sysman/diagnostics/linux/os_diagnostics_imp.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass
3333
SysfsAccess *pSysfsAccess = nullptr;
3434
FsAccess *pFsAccess = nullptr;
3535
ProcfsAccess *pProcfsAccess = nullptr;
36+
Device *pDevice = nullptr;
37+
std::string devicePciBdf = "";
38+
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
39+
uint32_t rootDeviceIndex = 0u;
3640
decltype(&NEO::SysCalls::open) openFunction = NEO::SysCalls::open;
3741
decltype(&NEO::SysCalls::close) closeFunction = NEO::SysCalls::close;
3842
decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread;
3943
decltype(&NEO::SysCalls::pwrite) pwriteFunction = NEO::SysCalls::pwrite;
44+
void releaseSysmanDeviceResources();
45+
void releaseDeviceResources();
46+
ze_result_t initDevice();
47+
void reInitSysmanDeviceResources();
4048

4149
private:
4250
static const std::string quiescentGpuFile;
@@ -46,4 +54,17 @@ class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass
4654
static const std::string deviceDir;
4755
};
4856

57+
class ExecutionEnvironmentRefCountRestore {
58+
public:
59+
ExecutionEnvironmentRefCountRestore() = delete;
60+
ExecutionEnvironmentRefCountRestore(NEO::ExecutionEnvironment *executionEnvironmentRecevied) {
61+
executionEnvironment = executionEnvironmentRecevied;
62+
executionEnvironment->incRefInternal();
63+
}
64+
~ExecutionEnvironmentRefCountRestore() {
65+
executionEnvironment->decRefInternal();
66+
}
67+
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
68+
};
69+
4970
} // namespace L0

level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/mock_zes_sysman_diagnostics.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ struct Mock<DiagnosticsFwInterface> : public FirmwareUtil {
6868
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
6969
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));
7070
};
71+
struct GlobalOperationsEngineHandleContext : public EngineHandleContext {
72+
GlobalOperationsEngineHandleContext(OsSysman *pOsSysman) : EngineHandleContext(pOsSysman) {}
73+
};
74+
template <>
75+
struct Mock<GlobalOperationsEngineHandleContext> : public GlobalOperationsEngineHandleContext {
76+
void initMock() {}
77+
Mock<GlobalOperationsEngineHandleContext>(OsSysman *pOsSysman) : GlobalOperationsEngineHandleContext(pOsSysman) {}
78+
MOCK_METHOD(void, init, (), (override));
79+
};
7180

7281
class DiagSysfsAccess : public SysfsAccess {};
7382
template <>
@@ -264,6 +273,7 @@ class PublicLinuxDiagnosticsImp : public L0::LinuxDiagnosticsImp {
264273
public:
265274
using LinuxDiagnosticsImp::closeFunction;
266275
using LinuxDiagnosticsImp::openFunction;
276+
using LinuxDiagnosticsImp::pDevice;
267277
using LinuxDiagnosticsImp::pFsAccess;
268278
using LinuxDiagnosticsImp::pFwInterface;
269279
using LinuxDiagnosticsImp::pLinuxSysmanImp;

0 commit comments

Comments
 (0)