Files
compute-runtime/level_zero/tools/source/sysman/ras/ras_imp.cpp
Vilvaraj, T J Vivek 0c9c55cd17 add counter support for RAS.
- added dual handle support for RAS Correctable and Uncorrectable Errors.
- added reset counter for RAS.
- added Os Specific ULT for RAS

Change-Id: Ia10115bf6720ab211f549571e810ec0d6c0801ec
2020-06-25 08:48:11 +02:00

75 lines
2.0 KiB
C++

/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/ras/ras_imp.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/string.h"
#include <cstring>
namespace L0 {
uint64_t getTotalErrors(zet_ras_details_t pDetails) {
return (pDetails.numResets +
pDetails.numProgrammingErrors +
pDetails.numNonComputeErrors +
pDetails.numComputeErrors +
pDetails.numDriverErrors +
pDetails.numDisplayErrors +
pDetails.numCacheErrors);
}
ze_result_t RasImp::rasGetProperties(zet_ras_properties_t *pProperties) {
rasProperties.type = this->rasErrorType;
rasProperties.onSubdevice = false;
rasProperties.subdeviceId = 0;
*pProperties = rasProperties;
return ZE_RESULT_SUCCESS;
}
ze_result_t RasImp::rasGetConfig(zet_ras_config_t *pConfig) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t RasImp::rasSetConfig(const zet_ras_config_t *pConfig) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t RasImp::rasGetState(ze_bool_t clear, uint64_t *pTotalErrors, zet_ras_details_t *pDetails) {
zet_ras_details_t pDetailsInternal;
memset(&pDetailsInternal, 0, sizeof(zet_ras_details_t));
ze_result_t result = pOsRas->getCounterValues(&pDetailsInternal);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*pTotalErrors = getTotalErrors(pDetailsInternal);
if (pDetails != nullptr) {
memcpy_s(pDetails, sizeof(zet_ras_details_t), &pDetailsInternal, sizeof(zet_ras_details_t));
}
return result;
}
void RasImp::init() {
pOsRas->setRasErrorType(this->rasErrorType);
isRasErrorSupported = pOsRas->isRasSupported();
}
RasImp::RasImp(OsSysman *pOsSysman, zet_ras_error_type_t type) {
pOsRas = OsRas::create(pOsSysman);
this->rasErrorType = type;
init();
}
RasImp::~RasImp() {
if (nullptr != pOsRas) {
delete pOsRas;
}
}
} // namespace L0