RAS APIs boilerplate for Level Zero Sysman.

-Implement zetSysmanRasGet API

Change-Id: Ib06e4a5d087a1e684c918413c3d98da2082e4f91
Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
Vilvaraj, T J Vivek
2020-04-06 15:26:25 +05:30
committed by sys_ocldev
parent 9db47c7421
commit 324b1f5c60
14 changed files with 292 additions and 5 deletions

View File

@@ -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})

View File

@@ -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})

View File

@@ -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<LinuxSysmanImp *>(pOsSysman);
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
}
OsRas *OsRas::create(OsSysman *pOsSysman) {
LinuxRasImp *pLinuxRasImp = new LinuxRasImp(pOsSysman);
return static_cast<OsRas *>(pLinuxRasImp);
}
} // namespace L0

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <level_zero/zet_api.h>
#include <vector>
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<Ras *>(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<Ras *> handleList;
};
} // namespace L0

View File

@@ -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

View File

@@ -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

View File

@@ -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})

View File

@@ -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<OsRas *>(pWddmRasImp);
}
} // namespace L0

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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;