mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Add Ecc support for sysman windows
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
afb57636b0
commit
db20000450
@@ -8,7 +8,6 @@ set(L0_SRCS_TOOLS_SYSMAN_ECC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecc_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecc_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc.h
|
||||
)
|
||||
|
||||
target_include_directories(${L0_STATIC_LIB_NAME}
|
||||
|
||||
@@ -7,34 +7,116 @@
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/firmware_util/firmware_util.h"
|
||||
|
||||
namespace L0 {
|
||||
zes_device_ecc_state_t EccImp::getEccState(uint8_t state) {
|
||||
switch (state) {
|
||||
case eccStateEnable:
|
||||
return ZES_DEVICE_ECC_STATE_ENABLED;
|
||||
case eccStateDisable:
|
||||
return ZES_DEVICE_ECC_STATE_DISABLED;
|
||||
default:
|
||||
return ZES_DEVICE_ECC_STATE_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t EccImp::getEccFwUtilInterface(FirmwareUtil *&pFwUtil) {
|
||||
pFwUtil = getFirmwareUtilInterface(pOsSysman);
|
||||
if (pFwUtil == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
ze_result_t result = pFwUtil->fwDeviceInit();
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
pFwUtil = nullptr;
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t EccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
|
||||
return pOsEcc->deviceEccAvailable(pAvailable);
|
||||
if (pFwInterface == nullptr) {
|
||||
ze_result_t result = getEccFwUtilInterface(pFwInterface);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
}
|
||||
|
||||
*pAvailable = false;
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
ze_result_t result = pFwInterface->fwGetEccConfig(¤tState, &pendingState);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
|
||||
*pAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t EccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
|
||||
return pOsEcc->deviceEccConfigurable(pConfigurable);
|
||||
return deviceEccAvailable(pConfigurable);
|
||||
}
|
||||
|
||||
ze_result_t EccImp::getEccState(zes_device_ecc_properties_t *pState) {
|
||||
return pOsEcc->getEccState(pState);
|
||||
if (pFwInterface == nullptr) {
|
||||
ze_result_t result = getEccFwUtilInterface(pFwInterface);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
ze_result_t result = pFwInterface->fwGetEccConfig(¤tState, &pendingState);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
pState->currentState = getEccState(currentState);
|
||||
pState->pendingState = getEccState(pendingState);
|
||||
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
|
||||
if (pState->currentState == pState->pendingState) {
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t EccImp::setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) {
|
||||
return pOsEcc->setEccState(newState, pState);
|
||||
}
|
||||
|
||||
void EccImp::init() {
|
||||
if (pOsEcc == nullptr) {
|
||||
pOsEcc = OsEcc::create(pOsSysman);
|
||||
if (pFwInterface == nullptr) {
|
||||
ze_result_t result = getEccFwUtilInterface(pFwInterface);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EccImp::~EccImp() {
|
||||
if (nullptr != pOsEcc) {
|
||||
delete pOsEcc;
|
||||
uint8_t state = 0;
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
if (newState->state == ZES_DEVICE_ECC_STATE_ENABLED) {
|
||||
state = eccStateEnable;
|
||||
} else if (newState->state == ZES_DEVICE_ECC_STATE_DISABLED) {
|
||||
state = eccStateDisable;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_INVALID_ENUMERATION;
|
||||
}
|
||||
|
||||
ze_result_t result = pFwInterface->fwSetEccConfig(state, ¤tState, &pendingState);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
pState->currentState = getEccState(currentState);
|
||||
pState->pendingState = getEccState(pendingState);
|
||||
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
|
||||
if (pState->currentState == pState->pendingState) {
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -9,24 +9,31 @@
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/ecc.h"
|
||||
#include "level_zero/tools/source/sysman/ecc/os_ecc.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class FirmwareUtil;
|
||||
struct OsSysman;
|
||||
class EccImp : public Ecc, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
void init() override;
|
||||
void init() override {}
|
||||
ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) override;
|
||||
ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) override;
|
||||
ze_result_t getEccState(zes_device_ecc_properties_t *pState) override;
|
||||
ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) override;
|
||||
OsEcc *pOsEcc = nullptr;
|
||||
|
||||
EccImp(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
|
||||
~EccImp() override;
|
||||
~EccImp() override {}
|
||||
|
||||
private:
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
FirmwareUtil *pFwInterface = nullptr;
|
||||
static constexpr uint8_t eccStateDisable = 0;
|
||||
static constexpr uint8_t eccStateEnable = 1;
|
||||
static constexpr uint8_t eccStateNone = 0xFF;
|
||||
|
||||
zes_device_ecc_state_t getEccState(uint8_t state);
|
||||
static FirmwareUtil *getFirmwareUtilInterface(OsSysman *pOsSysman);
|
||||
ze_result_t getEccFwUtilInterface(FirmwareUtil *&pFwUtil);
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_ECC_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc.cpp
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
|
||||
19
level_zero/tools/source/sysman/ecc/linux/os_ecc.cpp
Normal file
19
level_zero/tools/source/sysman/ecc/linux/os_ecc.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
|
||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class LinuxSysmanImp;
|
||||
class FirmwareUtil;
|
||||
|
||||
FirmwareUtil *EccImp::getFirmwareUtilInterface(OsSysman *pOsSysman) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
return pLinuxSysmanImp->getFwUtilInterface();
|
||||
}
|
||||
} // namespace L0
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/linux/os_ecc_imp.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
|
||||
#include "level_zero/tools/source/sysman/firmware_util/firmware_util.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
zes_device_ecc_state_t LinuxEccImp::getEccState(uint8_t state) {
|
||||
switch (state) {
|
||||
case eccStateEnable:
|
||||
return ZES_DEVICE_ECC_STATE_ENABLED;
|
||||
case eccStateDisable:
|
||||
return ZES_DEVICE_ECC_STATE_DISABLED;
|
||||
default:
|
||||
return ZES_DEVICE_ECC_STATE_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t LinuxEccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
|
||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
if (pFwInterface == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
*pAvailable = false;
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
ze_result_t result = pFwInterface->fwGetEccConfig(¤tState, &pendingState);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
|
||||
*pAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxEccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
|
||||
return deviceEccAvailable(pConfigurable);
|
||||
}
|
||||
|
||||
ze_result_t LinuxEccImp::getEccState(zes_device_ecc_properties_t *pState) {
|
||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
if (pFwInterface == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
ze_result_t result = pFwInterface->fwGetEccConfig(¤tState, &pendingState);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
pState->currentState = getEccState(currentState);
|
||||
pState->pendingState = getEccState(pendingState);
|
||||
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
|
||||
if (pState->currentState == pState->pendingState) {
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxEccImp::setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) {
|
||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
if (pFwInterface == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
uint8_t state = 0;
|
||||
uint8_t currentState = 0;
|
||||
uint8_t pendingState = 0;
|
||||
if (newState->state == ZES_DEVICE_ECC_STATE_ENABLED) {
|
||||
state = eccStateEnable;
|
||||
} else if (newState->state == ZES_DEVICE_ECC_STATE_DISABLED) {
|
||||
state = eccStateDisable;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_INVALID_ENUMERATION;
|
||||
}
|
||||
|
||||
ze_result_t result = pFwInterface->fwSetEccConfig(state, ¤tState, &pendingState);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
pState->currentState = getEccState(currentState);
|
||||
pState->pendingState = getEccState(pendingState);
|
||||
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_WARM_CARD_RESET;
|
||||
if (pState->currentState == pState->pendingState) {
|
||||
pState->pendingAction = ZES_DEVICE_ACTION_NONE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LinuxEccImp::LinuxEccImp(OsSysman *pOsSysman) {
|
||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
}
|
||||
|
||||
OsEcc *OsEcc::create(OsSysman *pOsSysman) {
|
||||
LinuxEccImp *pLinuxEccImp = new LinuxEccImp(pOsSysman);
|
||||
return static_cast<OsEcc *>(pLinuxEccImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/tools/source/sysman/ecc/os_ecc.h"
|
||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class LinuxSysmanImp;
|
||||
class FirmwareUtil;
|
||||
|
||||
class LinuxEccImp : public OsEcc, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) override;
|
||||
ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) override;
|
||||
ze_result_t getEccState(zes_device_ecc_properties_t *pState) override;
|
||||
ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) override;
|
||||
LinuxEccImp() = default;
|
||||
LinuxEccImp(OsSysman *pOsSysman);
|
||||
~LinuxEccImp() override = default;
|
||||
|
||||
protected:
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
|
||||
private:
|
||||
static constexpr uint8_t eccStateDisable = 0;
|
||||
static constexpr uint8_t eccStateEnable = 1;
|
||||
static constexpr uint8_t eccStateNone = 0xFF;
|
||||
|
||||
zes_device_ecc_state_t getEccState(uint8_t state);
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/sysman/os_sysman.h"
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class OsEcc {
|
||||
public:
|
||||
virtual ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) = 0;
|
||||
virtual ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) = 0;
|
||||
virtual ze_result_t getEccState(zes_device_ecc_properties_t *pState) = 0;
|
||||
virtual ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) = 0;
|
||||
static OsEcc *create(OsSysman *pOsSysman);
|
||||
virtual ~OsEcc() = default;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_ECC_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_ecc.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
19
level_zero/tools/source/sysman/ecc/windows/os_ecc.cpp
Normal file
19
level_zero/tools/source/sysman/ecc/windows/os_ecc.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
|
||||
#include "level_zero/tools/source/sysman/windows/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class WddmSysmanImp;
|
||||
class FirmwareUtil;
|
||||
|
||||
FirmwareUtil *EccImp::getFirmwareUtilInterface(OsSysman *pOsSysman) {
|
||||
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
|
||||
return pWddmSysmanImp->getFwUtilInterface();
|
||||
}
|
||||
} // namespace L0
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/ecc/windows/os_ecc_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t WddmEccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmEccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmEccImp::getEccState(zes_device_ecc_properties_t *pState) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
ze_result_t WddmEccImp::setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
WddmEccImp::WddmEccImp(OsSysman *pOsSysman) {
|
||||
}
|
||||
|
||||
OsEcc *OsEcc::create(OsSysman *pOsSysman) {
|
||||
WddmEccImp *pWddmEccImp = new WddmEccImp(pOsSysman);
|
||||
return static_cast<OsEcc *>(pWddmEccImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "sysman/ecc/os_ecc.h"
|
||||
#include "sysman/windows/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class WddmEccImp : public OsEcc {
|
||||
public:
|
||||
ze_result_t deviceEccAvailable(ze_bool_t *pAvailable) override;
|
||||
ze_result_t deviceEccConfigurable(ze_bool_t *pConfigurable) override;
|
||||
ze_result_t getEccState(zes_device_ecc_properties_t *pState) override;
|
||||
ze_result_t setEccState(const zes_device_ecc_desc_t *newState, zes_device_ecc_properties_t *pState) override;
|
||||
|
||||
WddmEccImp(OsSysman *pOsSysman);
|
||||
WddmEccImp() = default;
|
||||
~WddmEccImp() override = default;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user