Lazy init implementation for RAS module

Related-To: LOCI-3127

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2022-07-02 10:23:53 +00:00
committed by Compute-Runtime-Automation
parent 4bdd8860a1
commit 49aaf62bbd
9 changed files with 30 additions and 7 deletions

View File

@@ -396,4 +396,8 @@ OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp(pParentSysmanDeviceImp);
return static_cast<OsSysman *>(pLinuxSysmanImp);
}
std::vector<ze_device_handle_t> &LinuxSysmanImp::getDeviceHandles() {
return pParentSysmanDeviceImp->deviceHandles;
}
} // namespace L0

View File

@@ -52,6 +52,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
NEO::Drm &getDrm();
PlatformMonitoringTech *getPlatformMonitoringTechAccess(uint32_t subDeviceId);
Device *getDeviceHandle();
std::vector<ze_device_handle_t> &getDeviceHandles() override;
SysmanDeviceImp *getSysmanDeviceImp();
std::string getPciCardBusDirectoryPath(std::string realPciPath);
void releasePmtObject();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,9 @@
#pragma once
#include <level_zero/zes_api.h>
#include <vector>
namespace L0 {
struct SysmanDeviceImp;
@@ -16,6 +19,7 @@ struct OsSysman {
virtual ze_result_t init() = 0;
static OsSysman *create(SysmanDeviceImp *pSysmanImp);
virtual std::vector<ze_device_handle_t> &getDeviceHandles() = 0;
};
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#include "shared/source/helpers/basic_math.h"
#include "level_zero/tools/source/sysman/os_sysman.h"
#include "level_zero/tools/source/sysman/ras/ras_imp.h"
namespace L0 {
@@ -38,6 +39,9 @@ void RasHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles) {
}
ze_result_t RasHandleContext::rasGet(uint32_t *pCount,
zes_ras_handle_t *phRas) {
std::call_once(initRasOnce, [this]() {
this->init(pOsSysman->getDeviceHandles());
});
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {

View File

@@ -9,6 +9,7 @@
#include "level_zero/core/source/device/device.h"
#include <level_zero/zes_api.h>
#include <mutex>
#include <vector>
struct _zes_ras_handle_t {
@@ -48,6 +49,7 @@ struct RasHandleContext {
private:
void createHandle(zes_ras_error_type_t type, ze_device_handle_t deviceHandle);
std::once_flag initRasOnce;
};
} // namespace L0

View File

@@ -121,9 +121,6 @@ ze_result_t SysmanDeviceImp::init() {
if (pSchedulerHandleContext) {
pSchedulerHandleContext->init(deviceHandles);
}
if (pRasHandleContext) {
pRasHandleContext->init(deviceHandles);
}
if (pMemoryHandleContext) {
pMemoryHandleContext->init(deviceHandles);
}

View File

@@ -52,7 +52,9 @@ FirmwareUtil *WddmSysmanImp::getFwUtilInterface() {
Device *WddmSysmanImp::getDeviceHandle() {
return pDevice;
}
std::vector<ze_device_handle_t> &WddmSysmanImp::getDeviceHandles() {
return pParentSysmanDeviceImp->deviceHandles;
}
NEO::Wddm &WddmSysmanImp::getWddm() {
UNRECOVERABLE_IF(nullptr == pWddm);
return *pWddm;

View File

@@ -30,6 +30,7 @@ class WddmSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
NEO::Wddm &getWddm();
Device *getDeviceHandle();
void releaseFwUtilInterface();
std::vector<ze_device_handle_t> &getDeviceHandles() override;
protected:
FirmwareUtil *pFwUtilInterface = nullptr;

View File

@@ -43,7 +43,6 @@ struct SysmanRasFixture : public SysmanDeviceFixture {
deviceHandles.resize(subDeviceCount, nullptr);
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
}
pSysmanDeviceImp->pRasHandleContext->init(deviceHandles);
}
void TearDown() override {
if (!sysmanUltsEnable) {
@@ -60,6 +59,15 @@ struct SysmanRasFixture : public SysmanDeviceFixture {
}
};
TEST_F(SysmanRasFixture, GivenValidRasContextWhenRetrievingRasHandlesThenSuccessIsReturned) {
uint32_t count = 0;
RasHandleContext *pRasHandleContext = new RasHandleContext(pSysmanDeviceImp->pOsSysman);
ze_result_t result = pRasHandleContext->rasGet(&count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, mockHandleCount);
delete pRasHandleContext;
}
TEST_F(SysmanRasFixture, GivenValidSysmanHandleWhenRasErrorSetsThenCorrectCountIsReported) {
uint32_t count = 0;
ze_result_t result = zesDeviceEnumRasErrorSets(device->toHandle(), &count, NULL);