2020-04-06 15:26:25 +05:30
|
|
|
/*
|
2022-07-02 10:23:53 +00:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-04-06 15:26:25 +05:30
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-07-29 13:03:15 -04:00
|
|
|
#include "shared/source/helpers/basic_math.h"
|
|
|
|
|
|
2022-07-02 10:23:53 +00:00
|
|
|
#include "level_zero/tools/source/sysman/os_sysman.h"
|
2020-04-06 15:26:25 +05:30
|
|
|
#include "level_zero/tools/source/sysman/ras/ras_imp.h"
|
|
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
|
2021-04-14 12:30:33 +00:00
|
|
|
void RasHandleContext::releaseRasHandles() {
|
2020-04-06 15:26:25 +05:30
|
|
|
for (Ras *pRas : handleList) {
|
|
|
|
|
delete pRas;
|
|
|
|
|
}
|
2021-04-14 12:30:33 +00:00
|
|
|
handleList.clear();
|
2020-04-06 15:26:25 +05:30
|
|
|
}
|
2021-04-14 12:30:33 +00:00
|
|
|
|
|
|
|
|
RasHandleContext::~RasHandleContext() {
|
|
|
|
|
releaseRasHandles();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-23 08:59:36 +05:30
|
|
|
void RasHandleContext::createHandle(zes_ras_error_type_t type, ze_device_handle_t deviceHandle) {
|
|
|
|
|
Ras *pRas = new RasImp(pOsSysman, type, deviceHandle);
|
2020-09-22 18:12:08 +05:30
|
|
|
handleList.push_back(pRas);
|
2020-06-15 16:33:11 +05:30
|
|
|
}
|
2020-09-22 18:12:08 +05:30
|
|
|
|
2020-10-23 08:59:36 +05:30
|
|
|
void RasHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles) {
|
|
|
|
|
for (const auto &deviceHandle : deviceHandles) {
|
2021-11-28 09:32:17 +00:00
|
|
|
std::set<zes_ras_error_type_t> errorType = {};
|
2020-10-23 08:59:36 +05:30
|
|
|
OsRas::getSupportedRasErrorTypes(errorType, pOsSysman, deviceHandle);
|
|
|
|
|
for (const auto &type : errorType) {
|
|
|
|
|
createHandle(type, deviceHandle);
|
|
|
|
|
}
|
2020-09-22 18:12:08 +05:30
|
|
|
}
|
2020-04-06 15:26:25 +05:30
|
|
|
}
|
2020-06-15 16:33:11 +05:30
|
|
|
ze_result_t RasHandleContext::rasGet(uint32_t *pCount,
|
2020-07-29 02:45:54 -07:00
|
|
|
zes_ras_handle_t *phRas) {
|
2022-07-02 10:23:53 +00:00
|
|
|
std::call_once(initRasOnce, [this]() {
|
|
|
|
|
this->init(pOsSysman->getDeviceHandles());
|
2022-08-11 13:42:59 +00:00
|
|
|
this->rasInitDone = true;
|
2022-07-02 10:23:53 +00:00
|
|
|
});
|
2020-07-29 13:03:15 -04:00
|
|
|
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
|
|
|
|
|
uint32_t numToCopy = std::min(*pCount, handleListSize);
|
|
|
|
|
if (0 == *pCount || *pCount > handleListSize) {
|
|
|
|
|
*pCount = handleListSize;
|
2020-04-22 10:00:08 +05:30
|
|
|
}
|
2020-07-29 13:03:15 -04:00
|
|
|
if (nullptr != phRas) {
|
|
|
|
|
for (uint32_t i = 0; i < numToCopy; i++) {
|
|
|
|
|
phRas[i] = handleList[i]->toHandle();
|
2020-04-22 10:00:08 +05:30
|
|
|
}
|
|
|
|
|
}
|
2020-04-06 15:26:25 +05:30
|
|
|
return ZE_RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace L0
|