diff --git a/level_zero/api/tools/zet_sysman.cpp b/level_zero/api/tools/zet_sysman.cpp index b06f20d109..a40e8ef72c 100644 --- a/level_zero/api/tools/zet_sysman.cpp +++ b/level_zero/api/tools/zet_sysman.cpp @@ -581,21 +581,21 @@ __zedllexport ze_result_t __zecall zetSysmanRasGetProperties( zet_sysman_ras_handle_t hRas, zet_ras_properties_t *pProperties) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + return L0::Ras::fromHandle(hRas)->rasGetProperties(pProperties); } __zedllexport ze_result_t __zecall zetSysmanRasGetConfig( zet_sysman_ras_handle_t hRas, zet_ras_config_t *pConfig) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + return L0::Ras::fromHandle(hRas)->rasGetConfig(pConfig); } __zedllexport ze_result_t __zecall zetSysmanRasSetConfig( zet_sysman_ras_handle_t hRas, const zet_ras_config_t *pConfig) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + return L0::Ras::fromHandle(hRas)->rasSetConfig(pConfig); } __zedllexport ze_result_t __zecall @@ -604,7 +604,7 @@ zetSysmanRasGetState( ze_bool_t clear, uint64_t *pTotalErrors, zet_ras_details_t *pDetails) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + return L0::Ras::fromHandle(hRas)->rasGetState(clear, pTotalErrors, pDetails); } __zedllexport ze_result_t __zecall diff --git a/level_zero/tools/source/sysman/ras/CMakeLists.txt b/level_zero/tools/source/sysman/ras/CMakeLists.txt new file mode 100644 index 0000000000..41b2c8bece --- /dev/null +++ b/level_zero/tools/source/sysman/ras/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(L0_SRCS_TOOLS_SYSMAN_RAS + ${CMAKE_CURRENT_SOURCE_DIR}/ras.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ras.h + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ras_imp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ras_imp.h + ${CMAKE_CURRENT_SOURCE_DIR}/os_ras.h +) + + +target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${L0_SRCS_TOOLS_SYSMAN_RAS} + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt +) + +add_subdirectories() + +# Make our source files visible to parent +set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_RAS ${L0_SRCS_TOOLS_SYSMAN_RAS}) diff --git a/level_zero/tools/source/sysman/ras/linux/CMakeLists.txt b/level_zero/tools/source/sysman/ras/linux/CMakeLists.txt new file mode 100755 index 0000000000..65839b2c35 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/linux/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(L0_SRCS_TOOLS_SYSMAN_RAS_LINUX + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_ras_imp.cpp +) + +if(UNIX) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${L0_SRCS_TOOLS_SYSMAN_RAS_LINUX}) +endif() + +# Make our source files visible to parent +set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_RAS_LINUX ${L0_SRCS_TOOLS_SYSMAN_RAS_LINUX}) diff --git a/level_zero/tools/source/sysman/ras/linux/os_ras_imp.cpp b/level_zero/tools/source/sysman/ras/linux/os_ras_imp.cpp new file mode 100644 index 0000000000..338a4d5735 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/linux/os_ras_imp.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/non_copyable_or_moveable.h" + +#include "level_zero/tools/source/sysman/ras/os_ras.h" + +#include "sysman/linux/os_sysman_imp.h" + +namespace L0 { + +class LinuxRasImp : public OsRas, public NEO::NonCopyableClass { + public: + LinuxRasImp(OsSysman *pOsSysman); + ~LinuxRasImp() override = default; + + private: + SysfsAccess *pSysfsAccess = nullptr; +}; + +LinuxRasImp::LinuxRasImp(OsSysman *pOsSysman) { + LinuxSysmanImp *pLinuxSysmanImp = static_cast(pOsSysman); + pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess(); +} + +OsRas *OsRas::create(OsSysman *pOsSysman) { + LinuxRasImp *pLinuxRasImp = new LinuxRasImp(pOsSysman); + return static_cast(pLinuxRasImp); +} + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/os_ras.h b/level_zero/tools/source/sysman/ras/os_ras.h new file mode 100644 index 0000000000..ac5caf6861 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/os_ras.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +namespace L0 { + +struct OsSysman; +class OsRas { + public: + static OsRas *create(OsSysman *pOsSysman); + virtual ~OsRas() = default; +}; + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/ras.cpp b/level_zero/tools/source/sysman/ras/ras.cpp new file mode 100644 index 0000000000..a72b144d15 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/ras.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/tools/source/sysman/ras/ras_imp.h" + +namespace L0 { + +RasHandleContext::~RasHandleContext() { + for (Ras *pRas : handleList) { + delete pRas; + } +} + +void RasHandleContext::init() { + Ras *pRas = new RasImp(pOsSysman); + handleList.push_back(pRas); +} + +ze_result_t RasHandleContext::rasGet(uint32_t *pCount, zet_sysman_ras_handle_t *phRas) { + *pCount = 0; + return ZE_RESULT_SUCCESS; +} + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/ras.h b/level_zero/tools/source/sysman/ras/ras.h new file mode 100644 index 0000000000..9b9ae93753 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/ras.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include + +#include + +struct _zet_sysman_ras_handle_t { + virtual ~_zet_sysman_ras_handle_t() = default; +}; + +namespace L0 { + +struct OsSysman; + +class Ras : _zet_sysman_ras_handle_t { + public: + virtual ze_result_t rasGetProperties(zet_ras_properties_t *pProperties) = 0; + virtual ze_result_t rasGetConfig(zet_ras_config_t *pConfig) = 0; + virtual ze_result_t rasSetConfig(const zet_ras_config_t *pConfig) = 0; + virtual ze_result_t rasGetState(ze_bool_t clear, uint64_t *pTotalErrors, zet_ras_details_t *pDetails) = 0; + + static Ras *fromHandle(zet_sysman_ras_handle_t handle) { + return static_cast(handle); + } + inline zet_sysman_ras_handle_t toHandle() { return this; } +}; + +struct RasHandleContext { + RasHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){}; + ~RasHandleContext(); + + void init(); + + ze_result_t rasGet(uint32_t *pCount, zet_sysman_ras_handle_t *phRas); + + OsSysman *pOsSysman = nullptr; + std::vector handleList; +}; + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/ras_imp.cpp b/level_zero/tools/source/sysman/ras/ras_imp.cpp new file mode 100644 index 0000000000..65b7e3f21f --- /dev/null +++ b/level_zero/tools/source/sysman/ras/ras_imp.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/tools/source/sysman/ras/ras_imp.h" + +namespace L0 { + +ze_result_t RasImp::rasGetProperties(zet_ras_properties_t *pProperties) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +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) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +RasImp::RasImp(OsSysman *pOsSysman) { + pOsRas = OsRas::create(pOsSysman); +} + +RasImp::~RasImp() { + if (nullptr != pOsRas) { + delete pOsRas; + } +} + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/ras_imp.h b/level_zero/tools/source/sysman/ras/ras_imp.h new file mode 100644 index 0000000000..23059cf462 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/ras_imp.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/helpers/non_copyable_or_moveable.h" + +#include "level_zero/tools/source/sysman/ras/os_ras.h" +#include "level_zero/tools/source/sysman/ras/ras.h" + +namespace L0 { + +class RasImp : public NEO::NonCopyableClass, public Ras { + public: + ze_result_t rasGetProperties(zet_ras_properties_t *pProperties) override; + ze_result_t rasGetConfig(zet_ras_config_t *pConfig) override; + ze_result_t rasSetConfig(const zet_ras_config_t *pConfig) override; + ze_result_t rasGetState(ze_bool_t clear, uint64_t *pTotalErrors, zet_ras_details_t *pDetails) override; + + RasImp(OsSysman *pOsSysman); + ~RasImp() override; + + private: + OsRas *pOsRas = nullptr; + void init(); +}; + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/ras/windows/CMakeLists.txt b/level_zero/tools/source/sysman/ras/windows/CMakeLists.txt new file mode 100755 index 0000000000..582fc0c648 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/windows/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(L0_SRCS_TOOLS_SYSMAN_RAS_WINDOWS + ${CMAKE_CURRENT_SOURCE_DIR}/os_ras_imp.cpp +) + +if(WIN32) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${L0_SRCS_TOOLS_SYSMAN_RAS_WINDOWS}) +endif() + +# Make our source files visible to parent +set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_RAS_WINDOWS ${L0_SRCS_TOOLS_SYSMAN_RAS_WINDOWS}) diff --git a/level_zero/tools/source/sysman/ras/windows/os_ras_imp.cpp b/level_zero/tools/source/sysman/ras/windows/os_ras_imp.cpp new file mode 100644 index 0000000000..2198094ce3 --- /dev/null +++ b/level_zero/tools/source/sysman/ras/windows/os_ras_imp.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "sysman/ras/os_ras.h" + +namespace L0 { + +class WddmRasImp : public OsRas {}; + +OsRas *OsRas::create(OsSysman *pOsSysman) { + WddmRasImp *pWddmRasImp = new WddmRasImp(); + return static_cast(pWddmRasImp); +} + +} // namespace L0 diff --git a/level_zero/tools/source/sysman/sysman.h b/level_zero/tools/source/sysman/sysman.h index e7beb8dacd..0b5eebdd4c 100644 --- a/level_zero/tools/source/sysman/sysman.h +++ b/level_zero/tools/source/sysman/sysman.h @@ -10,6 +10,7 @@ #include "level_zero/tools/source/sysman/frequency/frequency.h" #include "level_zero/tools/source/sysman/memory/memory.h" #include "level_zero/tools/source/sysman/pci/pci.h" +#include "level_zero/tools/source/sysman/ras/ras.h" #include "level_zero/tools/source/sysman/scheduler/scheduler.h" #include "level_zero/tools/source/sysman/standby/standby.h" #include "level_zero/tools/source/sysman/sysman_device/sysman_device.h" diff --git a/level_zero/tools/source/sysman/sysman_imp.cpp b/level_zero/tools/source/sysman/sysman_imp.cpp index 06c1bae97d..f350160be9 100644 --- a/level_zero/tools/source/sysman/sysman_imp.cpp +++ b/level_zero/tools/source/sysman/sysman_imp.cpp @@ -29,9 +29,13 @@ SysmanImp::SysmanImp(ze_device_handle_t hDevice) { pStandbyHandleContext = new StandbyHandleContext(pOsSysman); pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice); pEngineHandleContext = new EngineHandleContext(pOsSysman); + pRasHandleContext = new RasHandleContext(pOsSysman); } SysmanImp::~SysmanImp() { + if (pRasHandleContext) { + delete pRasHandleContext; + } if (pEngineHandleContext) { delete pEngineHandleContext; } @@ -70,6 +74,9 @@ void SysmanImp::init() { if (pEngineHandleContext) { pEngineHandleContext->init(); } + if (pRasHandleContext) { + pRasHandleContext->init(); + } if (pPci) { pPci->init(); } @@ -186,7 +193,7 @@ ze_result_t SysmanImp::ledGet(uint32_t *pCount, zet_sysman_led_handle_t *phLed) } ze_result_t SysmanImp::rasGet(uint32_t *pCount, zet_sysman_ras_handle_t *phRas) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + return pRasHandleContext->rasGet(pCount, phRas); } ze_result_t SysmanImp::eventGet(zet_sysman_event_handle_t *phEvent) { diff --git a/level_zero/tools/source/sysman/sysman_imp.h b/level_zero/tools/source/sysman/sysman_imp.h index 9915955fea..3a4a11c10a 100644 --- a/level_zero/tools/source/sysman/sysman_imp.h +++ b/level_zero/tools/source/sysman/sysman_imp.h @@ -36,6 +36,7 @@ struct SysmanImp : Sysman { StandbyHandleContext *pStandbyHandleContext = nullptr; MemoryHandleContext *pMemoryHandleContext = nullptr; EngineHandleContext *pEngineHandleContext = nullptr; + RasHandleContext *pRasHandleContext = nullptr; ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) override; ze_result_t schedulerGetCurrentMode(zet_sched_mode_t *pMode) override;