sysman: Avoid creating the IGSC libary handle in ULTs

- Contains the changes to avoid invoking IGSC library
during ULT execution.


Related-To: LOCI-2719
Signed-off-by: Pichika Uday Kiran <pichika.uday.kiran@intel.com>
This commit is contained in:
Pichika Uday Kiran
2021-11-24 09:25:05 +00:00
committed by Compute-Runtime-Automation
parent 3e1023fa1a
commit 7764924387
9 changed files with 52 additions and 37 deletions

View File

@@ -77,9 +77,17 @@ if(BUILD_WITH_L0)
if(UNIX)
# Firmware Update Library
find_package(igsc)
get_filename_component(IGSC_DIR_tmp "${NEO_SOURCE_DIR}/../igsc" ABSOLUTE)
if(EXISTS "${IGSC_DIR_tmp}/lib/cmake")
find_package(igsc HINTS "${IGSC_DIR_tmp}/lib/cmake")
else()
find_package(igsc)
endif()
if(igsc_FOUND)
add_definitions(-DIGSC_PRESENT=1)
if(EXISTS "${IGSC_DIR_tmp}/lib/cmake")
get_filename_component(igsc_INCLUDE_DIR "${NEO_SOURCE_DIR}/../igsc/include" ABSOLUTE)
endif()
message(STATUS "igsc Library headers directory: ${igsc_INCLUDE_DIR}")
message(STATUS "igsc version: ${igsc_VERSION}")
include_directories(SYSTEM ${igsc_INCLUDE_DIR})

View File

@@ -36,9 +36,9 @@ class Diagnostics : _zes_diag_handle_t {
struct DiagnosticsHandleContext {
DiagnosticsHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
void releaseDiagnosticsHandles();
~DiagnosticsHandleContext();
MOCKABLE_VIRTUAL ~DiagnosticsHandleContext();
void init(std::vector<ze_device_handle_t> &deviceHandles);
MOCKABLE_VIRTUAL void init(std::vector<ze_device_handle_t> &deviceHandles);
ze_result_t diagnosticsGet(uint32_t *pCount, zes_diag_handle_t *phDiagnostics);
std::vector<std::string> supportedDiagTests = {};

View File

@@ -35,10 +35,10 @@ class Firmware : _zes_firmware_handle_t {
struct FirmwareHandleContext {
FirmwareHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
~FirmwareHandleContext();
MOCKABLE_VIRTUAL ~FirmwareHandleContext();
void releaseFwHandles();
void init();
MOCKABLE_VIRTUAL void init();
ze_result_t firmwareGet(uint32_t *pCount, zes_firmware_handle_t *phFirmware);

View File

@@ -143,7 +143,6 @@ void LinuxGlobalOperationsImp::releaseDeviceResources() {
void LinuxGlobalOperationsImp::reInitSysmanDeviceResources() {
pLinuxSysmanImp->getSysmanDeviceImp()->updateSubDeviceHandlesLocally();
pLinuxSysmanImp->createPmtHandles();
pLinuxSysmanImp->createFwUtilInterface();
pLinuxSysmanImp->getSysmanDeviceImp()->pRasHandleContext->init(pLinuxSysmanImp->getSysmanDeviceImp()->deviceHandles);
pLinuxSysmanImp->getSysmanDeviceImp()->pEngineHandleContext->init();
pLinuxSysmanImp->getSysmanDeviceImp()->pDiagnosticsHandleContext->init(pLinuxSysmanImp->getSysmanDeviceImp()->deviceHandles);

View File

@@ -42,9 +42,6 @@ ze_result_t LinuxSysmanImp::init() {
DEBUG_BREAK_IF(nullptr == pPmuInterface);
if (pFwUtilInterface == nullptr) {
createFwUtilInterface();
}
return createPmtHandles();
}
@@ -75,6 +72,9 @@ PmuInterface *LinuxSysmanImp::getPmuInterface() {
}
FirmwareUtil *LinuxSysmanImp::getFwUtilInterface() {
if (pFwUtilInterface == nullptr) {
createFwUtilInterface();
}
return pFwUtilInterface;
}

View File

@@ -237,14 +237,6 @@ TEST_F(ZesFirmwareFixture, GivenValidFirmwareHandleFirmwareLibraryCallFailureWhe
EXPECT_STREQ("unknown", properties.version);
}
TEST_F(ZesFirmwareFixture, GivenFwUtilInterfaceNullWhenCreatingFirmwareImpThenIsFirmwareSupportedShouldFail) {
pLinuxSysmanImp->pFwUtilInterface = nullptr;
FirmwareImp *ptestFirmwareImp = new FirmwareImp(pSysmanDeviceImp->pFirmwareHandleContext->pOsSysman, mockSupportedFwTypes[0]);
EXPECT_EQ(nullptr, pLinuxSysmanImp->pFwUtilInterface);
delete ptestFirmwareImp;
pLinuxSysmanImp->pFwUtilInterface = pMockFwInterface.get();
}
class ZesFirmwareUninitializedFixture : public SysmanDeviceFixture {
protected:
@@ -278,14 +270,5 @@ class ZesFirmwareUninitializedFixture : public SysmanDeviceFixture {
}
};
TEST_F(ZesFirmwareUninitializedFixture, GivenFirmwareLibraryMissingThenCreateHandleMustFail) {
for (const auto &handle : pSysmanDeviceImp->pFirmwareHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pFirmwareHandleContext->handleList.clear();
pSysmanDeviceImp->pFirmwareHandleContext->init();
EXPECT_EQ(0u, pSysmanDeviceImp->pFirmwareHandleContext->handleList.size());
}
} // namespace ult
} // namespace L0

View File

@@ -62,6 +62,26 @@ struct Mock<GlobalOperationsEngineHandleContext> : public GlobalOperationsEngine
MOCK_METHOD(void, init, (), (override));
};
struct GlobalOperationsDiagnosticsHandleContext : public DiagnosticsHandleContext {
GlobalOperationsDiagnosticsHandleContext(OsSysman *pOsSysman) : DiagnosticsHandleContext(pOsSysman) {}
};
template <>
struct Mock<GlobalOperationsDiagnosticsHandleContext> : public GlobalOperationsDiagnosticsHandleContext {
void initMock(std::vector<ze_device_handle_t> &deviceHandles) {}
Mock<GlobalOperationsDiagnosticsHandleContext>(OsSysman *pOsSysman) : GlobalOperationsDiagnosticsHandleContext(pOsSysman) {}
MOCK_METHOD(void, init, (std::vector<ze_device_handle_t> & deviceHandles), (override));
};
struct GlobalOperationsFirmwareHandleContext : public FirmwareHandleContext {
GlobalOperationsFirmwareHandleContext(OsSysman *pOsSysman) : FirmwareHandleContext(pOsSysman) {}
};
template <>
struct Mock<GlobalOperationsFirmwareHandleContext> : public GlobalOperationsFirmwareHandleContext {
void initMock() {}
Mock<GlobalOperationsFirmwareHandleContext>(OsSysman *pOsSysman) : GlobalOperationsFirmwareHandleContext(pOsSysman) {}
MOCK_METHOD(void, init, (), (override));
};
class GlobalOperationsSysfsAccess : public SysfsAccess {};
template <>

View File

@@ -45,10 +45,14 @@ constexpr uint32_t totalProcessStatesForFaultyClients = 3u;
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
protected:
std::unique_ptr<Mock<GlobalOperationsEngineHandleContext>> pEngineHandleContext;
std::unique_ptr<Mock<GlobalOperationsDiagnosticsHandleContext>> pDiagnosticsHandleContext;
std::unique_ptr<Mock<GlobalOperationsFirmwareHandleContext>> pFirmwareHandleContext;
std::unique_ptr<Mock<GlobalOperationsSysfsAccess>> pSysfsAccess;
std::unique_ptr<Mock<GlobalOperationsProcfsAccess>> pProcfsAccess;
std::unique_ptr<Mock<GlobalOperationsFsAccess>> pFsAccess;
EngineHandleContext *pEngineHandleContextOld = nullptr;
DiagnosticsHandleContext *pDiagnosticsHandleContextOld = nullptr;
FirmwareHandleContext *pFirmwareHandleContextOld = nullptr;
SysfsAccess *pSysfsAccessOld = nullptr;
ProcfsAccess *pProcfsAccessOld = nullptr;
FsAccess *pFsAccessOld = nullptr;
@@ -63,6 +67,8 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
}
SysmanDeviceFixture::SetUp();
pEngineHandleContextOld = pSysmanDeviceImp->pEngineHandleContext;
pDiagnosticsHandleContextOld = pSysmanDeviceImp->pDiagnosticsHandleContext;
pFirmwareHandleContextOld = pSysmanDeviceImp->pFirmwareHandleContext;
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
pProcfsAccessOld = pLinuxSysmanImp->pProcfsAccess;
pFsAccessOld = pLinuxSysmanImp->pFsAccess;
@@ -71,14 +77,22 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
pSysfsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsSysfsAccess>>>();
pProcfsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsProcfsAccess>>>();
pFsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsFsAccess>>>();
pDiagnosticsHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsDiagnosticsHandleContext>>>(pOsSysman);
pFirmwareHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsFirmwareHandleContext>>>(pOsSysman);
pSysmanDeviceImp->pEngineHandleContext = pEngineHandleContext.get();
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
pLinuxSysmanImp->pProcfsAccess = pProcfsAccess.get();
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
pSysmanDeviceImp->pDiagnosticsHandleContext = pDiagnosticsHandleContext.get();
pSysmanDeviceImp->pFirmwareHandleContext = pFirmwareHandleContext.get();
ON_CALL(*pEngineHandleContext.get(), init())
.WillByDefault(::testing::Invoke(pEngineHandleContext.get(), &Mock<GlobalOperationsEngineHandleContext>::initMock));
ON_CALL(*pDiagnosticsHandleContext.get(), init(_))
.WillByDefault(::testing::Invoke(pDiagnosticsHandleContext.get(), &Mock<GlobalOperationsDiagnosticsHandleContext>::initMock));
ON_CALL(*pFirmwareHandleContext.get(), init())
.WillByDefault(::testing::Invoke(pFirmwareHandleContext.get(), &Mock<GlobalOperationsFirmwareHandleContext>::initMock));
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValString));
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
@@ -124,6 +138,8 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
pGlobalOperationsImp->pOsGlobalOperations = pOsGlobalOperationsPrev;
pGlobalOperationsImp = nullptr;
pSysmanDeviceImp->pEngineHandleContext = pEngineHandleContextOld;
pSysmanDeviceImp->pDiagnosticsHandleContext = pDiagnosticsHandleContextOld;
pSysmanDeviceImp->pFirmwareHandleContext = pFirmwareHandleContextOld;
SysmanDeviceFixture::TearDown();
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld;
pLinuxSysmanImp->pProcfsAccess = pProcfsAccessOld;

View File

@@ -288,17 +288,6 @@ TEST_F(SysmanDeviceFixture, GivenPmuInterfaceHandleWhenCallinggetPmuInterfaceThe
EXPECT_EQ(pLinuxSysmanImp->getPmuInterface(), pLinuxSysmanImp->pPmuInterface);
}
TEST_F(SysmanDeviceFixture, GivenFwUtilInterfaceHandleWhenCallinggetFwUtilInterfaceThenCreatedFwUtilInterfaceHandleWillBeRetrieved) {
if (pLinuxSysmanImp->pFwUtilInterface != nullptr) {
//delete previously allocated FwUtilInterface
delete pLinuxSysmanImp->pFwUtilInterface;
pLinuxSysmanImp->pFwUtilInterface = nullptr;
}
const std::string mockBdf = "0000:00:02.0";
pLinuxSysmanImp->pFwUtilInterface = FirmwareUtil::create(mockBdf);
EXPECT_EQ(pLinuxSysmanImp->getFwUtilInterface(), pLinuxSysmanImp->pFwUtilInterface);
}
TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturnedPathIs2LevelUpThenTheCurrentPath) {
const std::string mockBdf = "0000:00:02.0";
const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf;