Skip to content

Commit 061af9c

Browse files
Sysman : Add check on engine handle creation
Add check whether init succeeded on handle creation. Related-To: LOCI-3005 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
1 parent 878466a commit 061af9c

File tree

9 files changed

+38
-9
lines changed

9 files changed

+38
-9
lines changed

level_zero/tools/source/sysman/engine/engine.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -24,7 +24,11 @@ EngineHandleContext::~EngineHandleContext() {
2424

2525
void EngineHandleContext::createHandle(zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {
2626
Engine *pEngine = new EngineImp(pOsSysman, engineType, engineInstance, subDeviceId);
27-
handleList.push_back(pEngine);
27+
if (pEngine->initSuccess == true) {
28+
handleList.push_back(pEngine);
29+
} else {
30+
delete pEngine;
31+
}
2832
}
2933

3034
void EngineHandleContext::init() {

level_zero/tools/source/sysman/engine/engine.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -28,6 +28,7 @@ class Engine : _zes_engine_handle_t {
2828
return static_cast<Engine *>(handle);
2929
}
3030
inline zes_engine_handle_t toHandle() { return this; }
31+
bool initSuccess = false;
3132
};
3233

3334
struct EngineHandleContext {

level_zero/tools/source/sysman/engine/engine_imp.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -20,7 +20,10 @@ ze_result_t EngineImp::engineGetProperties(zes_engine_properties_t *pProperties)
2020
}
2121

2222
void EngineImp::init() {
23-
pOsEngine->getProperties(engineProperties);
23+
if (pOsEngine->isEngineModuleSupported()) {
24+
pOsEngine->getProperties(engineProperties);
25+
this->initSuccess = true;
26+
}
2427
}
2528

2629
EngineImp::EngineImp(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {

level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ void LinuxEngineImp::init() {
7272
fd = pPmuInterface->pmuInterfaceOpen(I915_PMU_ENGINE_BUSY(i915EngineClass->second, engineInstance), -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
7373
}
7474

75+
bool LinuxEngineImp::isEngineModuleSupported() {
76+
if (fd < 0) {
77+
return false;
78+
}
79+
return true;
80+
}
81+
7582
LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId) : engineGroup(type), engineInstance(engineInstance), subDeviceId(subDeviceId) {
7683
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
7784
pDrm = &pLinuxSysmanImp->getDrm();

level_zero/tools/source/sysman/engine/linux/os_engine_imp.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -19,6 +19,7 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableOrMovableClass {
1919
public:
2020
ze_result_t getActivity(zes_engine_stats_t *pStats) override;
2121
ze_result_t getProperties(zes_engine_properties_t &properties) override;
22+
bool isEngineModuleSupported() override;
2223
static zes_engine_group_t getGroupFromEngineType(zes_engine_group_t type);
2324
LinuxEngineImp() = default;
2425
LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId);

level_zero/tools/source/sysman/engine/linux/os_engine_imp_prelim.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ void LinuxEngineImp::init() {
115115
fd = pPmuInterface->pmuInterfaceOpen(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
116116
}
117117

118+
bool LinuxEngineImp::isEngineModuleSupported() {
119+
if (fd < 0) {
120+
return false;
121+
}
122+
return true;
123+
}
124+
118125
LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId) : engineGroup(type), engineInstance(engineInstance), subDeviceId(subDeviceId) {
119126
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
120127
pDrm = &pLinuxSysmanImp->getDrm();

level_zero/tools/source/sysman/engine/os_engine.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -21,6 +21,7 @@ class OsEngine {
2121
public:
2222
virtual ze_result_t getActivity(zes_engine_stats_t *pStats) = 0;
2323
virtual ze_result_t getProperties(zes_engine_properties_t &properties) = 0;
24+
virtual bool isEngineModuleSupported() = 0;
2425
static OsEngine *create(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId);
2526
static ze_result_t getNumEngineTypeAndInstances(std::set<std::pair<zes_engine_group_t, EngineInstanceSubDeviceId>> &engineGroupInstance, OsSysman *pOsSysman);
2627
virtual ~OsEngine() = default;

level_zero/tools/source/sysman/engine/windows/os_engine_imp.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -57,6 +57,10 @@ ze_result_t WddmEngineImp::getProperties(zes_engine_properties_t &properties) {
5757
return ZE_RESULT_SUCCESS;
5858
}
5959

60+
bool WddmEngineImp::isEngineModuleSupported() {
61+
return true;
62+
}
63+
6064
WddmEngineImp::WddmEngineImp(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {
6165
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
6266
this->engineGroup = engineType;

level_zero/tools/source/sysman/engine/windows/os_engine_imp.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -17,6 +17,7 @@ class WddmEngineImp : public OsEngine, NEO::NonCopyableOrMovableClass {
1717
public:
1818
ze_result_t getActivity(zes_engine_stats_t *pStats) override;
1919
ze_result_t getProperties(zes_engine_properties_t &properties) override;
20+
bool isEngineModuleSupported() override;
2021

2122
WddmEngineImp() = default;
2223
WddmEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId);

0 commit comments

Comments
 (0)