2020-04-06 15:26:25 +05:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "level_zero/tools/source/sysman/ras/ras_imp.h"
|
|
|
|
|
|
2020-06-15 16:33:11 +05:30
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
|
#include "shared/source/helpers/string.h"
|
|
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
2020-04-06 15:26:25 +05:30
|
|
|
namespace L0 {
|
|
|
|
|
|
2020-06-15 16:33:11 +05:30
|
|
|
uint64_t getTotalErrors(zet_ras_details_t pDetails) {
|
|
|
|
|
return (pDetails.numResets +
|
|
|
|
|
pDetails.numProgrammingErrors +
|
|
|
|
|
pDetails.numNonComputeErrors +
|
|
|
|
|
pDetails.numComputeErrors +
|
|
|
|
|
pDetails.numDriverErrors +
|
|
|
|
|
pDetails.numDisplayErrors +
|
|
|
|
|
pDetails.numCacheErrors);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 15:26:25 +05:30
|
|
|
ze_result_t RasImp::rasGetProperties(zet_ras_properties_t *pProperties) {
|
2020-06-15 16:33:11 +05:30
|
|
|
rasProperties.type = this->rasErrorType;
|
|
|
|
|
rasProperties.onSubdevice = false;
|
|
|
|
|
rasProperties.subdeviceId = 0;
|
|
|
|
|
*pProperties = rasProperties;
|
|
|
|
|
return ZE_RESULT_SUCCESS;
|
2020-04-06 15:26:25 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
2020-06-15 16:33:11 +05:30
|
|
|
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();
|
2020-04-06 15:26:25 +05:30
|
|
|
}
|
|
|
|
|
|
2020-06-15 16:33:11 +05:30
|
|
|
RasImp::RasImp(OsSysman *pOsSysman, zet_ras_error_type_t type) {
|
2020-04-06 15:26:25 +05:30
|
|
|
pOsRas = OsRas::create(pOsSysman);
|
2020-06-15 16:33:11 +05:30
|
|
|
this->rasErrorType = type;
|
|
|
|
|
init();
|
2020-04-06 15:26:25 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RasImp::~RasImp() {
|
|
|
|
|
if (nullptr != pOsRas) {
|
|
|
|
|
delete pOsRas;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace L0
|