Skip to content

Commit 3efdfba

Browse files
Add support for error correction codes
Implement ECC API. Add ULTs to validate error correction codes. Integrate sysman ecc with igsc. Related-To: LOCI-2782 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
1 parent b48d4a8 commit 3efdfba

31 files changed

+871
-4
lines changed

level_zero/api/sysman/ze_sysman_loader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ zesGetDeviceProcAddrTable(
6363
pDdiTable->pfnEnumSchedulers = zesDeviceEnumSchedulers;
6464
pDdiTable->pfnEnumStandbyDomains = zesDeviceEnumStandbyDomains;
6565
pDdiTable->pfnEnumTemperatureSensors = zesDeviceEnumTemperatureSensors;
66+
pDdiTable->pfnEccAvailable = zesDeviceEccAvailable;
67+
pDdiTable->pfnEccConfigurable = zesDeviceEccConfigurable;
68+
pDdiTable->pfnGetEccState = zesDeviceGetEccState;
69+
pDdiTable->pfnSetEccState = zesDeviceSetEccState;
6670
return result;
6771
}
6872

level_zero/api/sysman/zes_sysman.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,3 +747,32 @@ zesPerformanceFactorSetConfig(
747747
double factor) {
748748
return L0::Performance::fromHandle(hPerf)->performanceSetConfig(factor);
749749
}
750+
751+
ZE_APIEXPORT ze_result_t ZE_APICALL
752+
zesDeviceEccAvailable(
753+
zes_device_handle_t hDevice,
754+
ze_bool_t *pAvailable) {
755+
return L0::SysmanDevice::deviceEccAvailable(hDevice, pAvailable);
756+
}
757+
758+
ZE_APIEXPORT ze_result_t ZE_APICALL
759+
zesDeviceEccConfigurable(
760+
zes_device_handle_t hDevice,
761+
ze_bool_t *pConfigurable) {
762+
return L0::SysmanDevice::deviceEccConfigurable(hDevice, pConfigurable);
763+
}
764+
765+
ZE_APIEXPORT ze_result_t ZE_APICALL
766+
zesDeviceGetEccState(
767+
zes_device_handle_t hDevice,
768+
zes_device_ecc_properties_t *pState) {
769+
return L0::SysmanDevice::deviceGetEccState(hDevice, pState);
770+
}
771+
772+
ZE_APIEXPORT ze_result_t ZE_APICALL
773+
zesDeviceSetEccState(
774+
zes_device_handle_t hDevice,
775+
const zes_device_ecc_desc_t *newState,
776+
zes_device_ecc_properties_t *pState) {
777+
return L0::SysmanDevice::deviceSetEccState(hDevice, newState, pState);
778+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(L0_SRCS_TOOLS_SYSMAN_ECC
8+
${CMAKE_CURRENT_SOURCE_DIR}/ecc.h
9+
${CMAKE_CURRENT_SOURCE_DIR}/ecc_imp.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/ecc_imp.h
11+
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc.h
12+
)
13+
14+
target_include_directories(${L0_STATIC_LIB_NAME}
15+
PUBLIC
16+
${CMAKE_CURRENT_SOURCE_DIR}/
17+
)
18+
19+
target_sources(${L0_STATIC_LIB_NAME}
20+
PRIVATE
21+
${L0_SRCS_TOOLS_SYSMAN_ECC}
22+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
23+
)
24+
25+
add_subdirectories()
26+
27+
# Make our source files visible to parent
28+
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_ECC ${L0_SRCS_TOOLS_ECC})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include <level_zero/zes_api.h>
10+
11+
namespace L0 {
12+
13+
class Ecc {
14+
public:
15+
virtual ~Ecc() = default;
16+
virtual ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) = 0;
17+
virtual ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) = 0;
18+
virtual ze_result_t getEccState(zes_device_ecc_properties_t *pState) = 0;
19+
virtual ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) = 0;
20+
21+
virtual void init() = 0;
22+
};
23+
24+
} // namespace L0
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
9+
10+
namespace L0 {
11+
12+
ze_result_t EccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
13+
return pOsEcc->deviceEccAvailable(pAvailable);
14+
}
15+
16+
ze_result_t EccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
17+
return pOsEcc->deviceEccConfigurable(pConfigurable);
18+
}
19+
20+
ze_result_t EccImp::getEccState(zes_device_ecc_properties_t *pState) {
21+
return pOsEcc->getEccState(pState);
22+
}
23+
24+
ze_result_t EccImp::setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) {
25+
return pOsEcc->setEccState(newState, pState);
26+
}
27+
28+
void EccImp::init() {
29+
if (pOsEcc == nullptr) {
30+
pOsEcc = OsEcc::create(pOsSysman);
31+
}
32+
}
33+
34+
EccImp::~EccImp() {
35+
if (nullptr != pOsEcc) {
36+
delete pOsEcc;
37+
}
38+
}
39+
40+
} // namespace L0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "shared/source/helpers/non_copyable_or_moveable.h"
10+
11+
#include "level_zero/tools/source/sysman/ecc/ecc.h"
12+
#include "level_zero/tools/source/sysman/ecc/os_ecc.h"
13+
14+
namespace L0 {
15+
16+
class EccImp : public Ecc, NEO::NonCopyableOrMovableClass {
17+
public:
18+
void init() override;
19+
ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) override;
20+
ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) override;
21+
ze_result_t getEccState(zes_device_ecc_properties_t *pState) override;
22+
ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) override;
23+
OsEcc *pOsEcc = nullptr;
24+
25+
EccImp(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
26+
~EccImp() override;
27+
28+
private:
29+
OsSysman *pOsSysman = nullptr;
30+
};
31+
32+
} // namespace L0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(L0_SRCS_TOOLS_SYSMAN_ECC_LINUX
8+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9+
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.h
11+
)
12+
13+
if(UNIX)
14+
target_sources(${L0_STATIC_LIB_NAME}
15+
PRIVATE
16+
${L0_SRCS_TOOLS_SYSMAN_ECC_LINUX}
17+
)
18+
endif()
19+
20+
# Make our source files visible to parent
21+
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_ECC_LINUX ${L0_SRCS_TOOLS_SYSMAN_ECC_LINUX})
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "level_zero/tools/source/sysman/ecc/linux/os_ecc_imp.h"
9+
10+
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
11+
12+
namespace L0 {
13+
14+
zes_device_ecc_state_t LinuxEccImp::getEccState(uint8_t state) {
15+
switch (state) {
16+
case eccStateEnable:
17+
return ZES_DEVICE_ECC_STATE_ENABLED;
18+
case eccStateDisable:
19+
return ZES_DEVICE_ECC_STATE_DISABLED;
20+
default:
21+
return ZES_DEVICE_ECC_STATE_UNAVAILABLE;
22+
}
23+
}
24+
25+
ze_result_t LinuxEccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
26+
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
27+
if (pFwInterface == nullptr) {
28+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
29+
}
30+
31+
*pAvailable = false;
32+
uint8_t currentState = 0;
33+
uint8_t pendingState = 0;
34+
ze_result_t result = pFwInterface->fwGetEccConfig(&currentState, &pendingState);
35+
if (ZE_RESULT_SUCCESS == result) {
36+
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
37+
*pAvailable = true;
38+
}
39+
}
40+
41+
return result;
42+
}
43+
44+
ze_result_t LinuxEccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
45+
return deviceEccAvailable(pConfigurable);
46+
}
47+
48+
ze_result_t LinuxEccImp::getEccState(zes_device_ecc_properties_t *pState) {
49+
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
50+
if (pFwInterface == nullptr) {
51+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
52+
}
53+
54+
uint8_t currentState = 0;
55+
uint8_t pendingState = 0;
56+
ze_result_t result = pFwInterface->fwGetEccConfig(&currentState, &pendingState);
57+
if (result != ZE_RESULT_SUCCESS) {
58+
return result;
59+
}
60+
pState->currentState = getEccState(currentState);
61+
pState->pendingState = getEccState(pendingState);
62+
63+
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
64+
if (pState->currentState == pState->pendingState) {
65+
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
66+
}
67+
68+
return result;
69+
}
70+
71+
ze_result_t LinuxEccImp::setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) {
72+
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
73+
if (pFwInterface == nullptr) {
74+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
75+
}
76+
77+
uint8_t state = 0;
78+
uint8_t currentState = 0;
79+
uint8_t pendingState = 0;
80+
if (newState->state == ZES_DEVICE_ECC_STATE_ENABLED) {
81+
state = eccStateEnable;
82+
} else if (newState->state == ZES_DEVICE_ECC_STATE_DISABLED) {
83+
state = eccStateDisable;
84+
} else {
85+
return ZE_RESULT_ERROR_INVALID_ENUMERATION;
86+
}
87+
88+
ze_result_t result = pFwInterface->fwSetEccConfig(state, &currentState, &pendingState);
89+
if (result != ZE_RESULT_SUCCESS) {
90+
return result;
91+
}
92+
93+
pState->currentState = getEccState(currentState);
94+
pState->pendingState = getEccState(pendingState);
95+
96+
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
97+
if (pState->currentState == pState->pendingState) {
98+
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
99+
}
100+
101+
return result;
102+
}
103+
104+
LinuxEccImp::LinuxEccImp(OsSysman *pOsSysman) {
105+
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
106+
}
107+
108+
OsEcc *OsEcc::create(OsSysman *pOsSysman) {
109+
LinuxEccImp *pLinuxEccImp = new LinuxEccImp(pOsSysman);
110+
return static_cast<OsEcc *>(pLinuxEccImp);
111+
}
112+
113+
} // namespace L0
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "level_zero/tools/source/sysman/ecc/os_ecc.h"
10+
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
11+
12+
namespace L0 {
13+
class LinuxSysmanImp;
14+
class FirmwareUtil;
15+
16+
class LinuxEccImp : public OsEcc, NEO::NonCopyableOrMovableClass {
17+
public:
18+
ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) override;
19+
ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) override;
20+
ze_result_t getEccState(zes_device_ecc_properties_t *pState) override;
21+
ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) override;
22+
LinuxEccImp() = default;
23+
LinuxEccImp(OsSysman *pOsSysman);
24+
~LinuxEccImp() override = default;
25+
26+
protected:
27+
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
28+
29+
private:
30+
static constexpr uint8_t eccStateDisable = 0;
31+
static constexpr uint8_t eccStateEnable = 1;
32+
static constexpr uint8_t eccStateNone = 0xFF;
33+
34+
zes_device_ecc_state_t getEccState(uint8_t state);
35+
};
36+
37+
} // namespace L0
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "level_zero/tools/source/sysman/os_sysman.h"
11+
#include <level_zero/zes_api.h>
12+
13+
namespace L0 {
14+
15+
class OsEcc {
16+
public:
17+
virtual ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) = 0;
18+
virtual ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) = 0;
19+
virtual ze_result_t getEccState(zes_device_ecc_properties_t *pState) = 0;
20+
virtual ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) = 0;
21+
static OsEcc *create(OsSysman *pOsSysman);
22+
virtual ~OsEcc() = default;
23+
};
24+
25+
} // namespace L0

0 commit comments

Comments
 (0)