mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Implement zesRasGetConfig and zesRasSetConfig
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0c035cfcc9
commit
0f973f146e
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -273,6 +273,10 @@ std::string FsAccess::getDirName(const std::string path) {
|
||||
return path.substr(0, pos);
|
||||
}
|
||||
|
||||
bool FsAccess::isRootUser() {
|
||||
return (geteuid() == 0);
|
||||
}
|
||||
|
||||
// Procfs Access
|
||||
const std::string ProcfsAccess::procDir = "/proc/";
|
||||
const std::string ProcfsAccess::fdDir = "/fd/";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -44,6 +44,7 @@ class FsAccess {
|
||||
virtual ze_result_t readSymLink(const std::string path, std::string &buf);
|
||||
virtual ze_result_t getRealPath(const std::string path, std::string &buf);
|
||||
virtual ze_result_t listDirectory(const std::string path, std::vector<std::string> &list);
|
||||
virtual bool isRootUser();
|
||||
std::string getBaseName(const std::string path);
|
||||
std::string getDirName(const std::string path);
|
||||
virtual bool fileExists(const std::string file);
|
||||
|
||||
@@ -19,6 +19,21 @@ ze_result_t LinuxRasImp::osRasGetState(zes_ras_state_t &state, ze_bool_t clear)
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t LinuxRasImp::osRasGetConfig(zes_ras_config_t *config) {
|
||||
config->totalThreshold = totalThreshold;
|
||||
memcpy(config->detailedThresholds.category, categoryThreshold, sizeof(config->detailedThresholds.category));
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t LinuxRasImp::osRasSetConfig(const zes_ras_config_t *config) {
|
||||
if (pFsAccess->isRootUser() == true) {
|
||||
totalThreshold = config->totalThreshold;
|
||||
memcpy(categoryThreshold, config->detailedThresholds.category, sizeof(config->detailedThresholds.category));
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
ze_result_t LinuxRasImp::osRasGetProperties(zes_ras_properties_t &properties) {
|
||||
properties.pNext = nullptr;
|
||||
properties.type = osRasErrorType;
|
||||
@@ -27,6 +42,8 @@ ze_result_t LinuxRasImp::osRasGetProperties(zes_ras_properties_t &properties) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
LinuxRasImp::LinuxRasImp(OsSysman *pOsSysman, zes_ras_error_type_t type, ze_bool_t onSubdevice, uint32_t subdeviceId) : osRasErrorType(type), isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
}
|
||||
|
||||
OsRas *OsRas::create(OsSysman *pOsSysman, zes_ras_error_type_t type, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
|
||||
@@ -11,21 +11,28 @@
|
||||
#include "level_zero/tools/source/sysman/ras/os_ras.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class FsAccess;
|
||||
class LinuxSysmanImp;
|
||||
class LinuxRasImp : public OsRas, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t osRasGetProperties(zes_ras_properties_t &properties) override;
|
||||
ze_result_t osRasGetState(zes_ras_state_t &state, ze_bool_t clear) override;
|
||||
ze_result_t osRasGetConfig(zes_ras_config_t *config) override;
|
||||
ze_result_t osRasSetConfig(const zes_ras_config_t *config) override;
|
||||
LinuxRasImp(OsSysman *pOsSysman, zes_ras_error_type_t type, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
LinuxRasImp() = default;
|
||||
~LinuxRasImp() override = default;
|
||||
|
||||
protected:
|
||||
zes_ras_error_type_t osRasErrorType = {};
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
|
||||
private:
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
uint64_t totalThreshold = 0;
|
||||
uint64_t categoryThreshold[ZES_MAX_RAS_ERROR_CATEGORY_COUNT] = {0};
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -18,6 +18,8 @@ class OsRas {
|
||||
public:
|
||||
virtual ze_result_t osRasGetProperties(zes_ras_properties_t &properties) = 0;
|
||||
virtual ze_result_t osRasGetState(zes_ras_state_t &state, ze_bool_t clear) = 0;
|
||||
virtual ze_result_t osRasGetConfig(zes_ras_config_t *config) = 0;
|
||||
virtual ze_result_t osRasSetConfig(const zes_ras_config_t *config) = 0;
|
||||
static OsRas *create(OsSysman *pOsSysman, zes_ras_error_type_t type, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
static ze_result_t getSupportedRasErrorTypes(std::vector<zes_ras_error_type_t> &errorType, OsSysman *pOsSysman, ze_device_handle_t deviceHandle);
|
||||
virtual ~OsRas() = default;
|
||||
|
||||
@@ -20,11 +20,11 @@ ze_result_t RasImp::rasGetProperties(zes_ras_properties_t *pProperties) {
|
||||
}
|
||||
|
||||
ze_result_t RasImp::rasGetConfig(zes_ras_config_t *pConfig) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
return pOsRas->osRasGetConfig(pConfig);
|
||||
}
|
||||
|
||||
ze_result_t RasImp::rasSetConfig(const zes_ras_config_t *pConfig) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
return pOsRas->osRasSetConfig(pConfig);
|
||||
}
|
||||
|
||||
ze_result_t RasImp::rasGetState(zes_ras_state_t *pState, ze_bool_t clear) {
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace L0 {
|
||||
class WddmRasImp : public OsRas {
|
||||
ze_result_t osRasGetProperties(zes_ras_properties_t &properties) override;
|
||||
ze_result_t osRasGetState(zes_ras_state_t &state, ze_bool_t clear) override;
|
||||
ze_result_t osRasGetConfig(zes_ras_config_t *config) override;
|
||||
ze_result_t osRasSetConfig(const zes_ras_config_t *config) override;
|
||||
};
|
||||
|
||||
ze_result_t OsRas::getSupportedRasErrorTypes(std::vector<zes_ras_error_type_t> &errorType, OsSysman *pOsSysman, ze_device_handle_t deviceHandle) {
|
||||
@@ -22,6 +24,14 @@ ze_result_t WddmRasImp::osRasGetProperties(zes_ras_properties_t &properties) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmRasImp::osRasGetConfig(zes_ras_config_t *config) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmRasImp::osRasSetConfig(const zes_ras_config_t *config) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmRasImp::osRasGetState(zes_ras_state_t &state, ze_bool_t clear) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user