sysman: add basic steps for IFR status.

In field repair status information is needed as part of Device
reset status

Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
Vilvaraj, T J Vivek 2021-02-24 16:35:03 +05:30 committed by Compute-Runtime-Automation
parent fabd834941
commit b56b204f3e
16 changed files with 120 additions and 55 deletions

View File

@ -18,9 +18,7 @@ const std::string LinuxEventsImp::attachEvent("add");
bool LinuxEventsImp::isResetRequired(zes_event_type_flags_t &pEvent) {
zes_device_state_t pState = {};
if (pLinuxSysmanImp->getSysmanDeviceImp()->deviceGetState(&pState) != ZE_RESULT_SUCCESS) {
return false;
}
pLinuxSysmanImp->getSysmanDeviceImp()->deviceGetState(&pState);
if (pState.reset) {
pEvent |= ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED;
return true;

View File

@ -1,11 +1,12 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_global_operations_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_imp.h
)

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
#include "level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h"
#include "level_zero/tools/source/sysman/linux/fs_access.h"
#include "level_zero/tools/source/sysman/sysman_const.h"
namespace L0 {
void LinuxGlobalOperationsImp::getRepairStatus(zes_device_state_t *pState) {
}
} // namespace L0

View File

@ -390,20 +390,23 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
}
return result;
}
ze_result_t LinuxGlobalOperationsImp::deviceGetState(zes_device_state_t *pState) {
void LinuxGlobalOperationsImp::getWedgedStatus(zes_device_state_t *pState) {
uint32_t valWedged = 0;
ze_result_t result = pFsAccess->read(ueventWedgedFile, valWedged);
if (result != ZE_RESULT_SUCCESS) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE)
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return result;
if (ZE_RESULT_SUCCESS == pFsAccess->read(ueventWedgedFile, valWedged)) {
if (valWedged != 0) {
pState->reset |= ZES_RESET_REASON_FLAG_WEDGED;
}
}
pState->reset = 0;
if (valWedged != 0) {
pState->reset |= ZES_RESET_REASON_FLAG_WEDGED;
}
return result;
}
ze_result_t LinuxGlobalOperationsImp::deviceGetState(zes_device_state_t *pState) {
memset(pState, 0, sizeof(zes_device_state_t));
pState->repaired = ZES_REPAIR_STATUS_UNSUPPORTED;
getWedgedStatus(pState);
getRepairStatus(pState);
return ZE_RESULT_SUCCESS;
}
LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
@ -411,6 +414,7 @@ LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
pFsAccess = &pLinuxSysmanImp->getFsAccess();
pDevice = pLinuxSysmanImp->getDeviceHandle();
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
}
OsGlobalOperations *OsGlobalOperations::create(OsSysman *pOsSysman) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -21,6 +21,8 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
void getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) override;
void getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) override;
void getDriverVersion(char (&driverVersion)[ZES_STRING_PROPERTY_SIZE]) override;
void getWedgedStatus(zes_device_state_t *pState) override;
void getRepairStatus(zes_device_state_t *pState) override;
Device *getDevice() override;
ze_result_t reset(ze_bool_t force) override;
ze_result_t scanProcessesState(std::vector<zes_process_state_t> &pProcessList) override;
@ -35,6 +37,7 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
SysfsAccess *pSysfsAccess = nullptr;
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
Device *pDevice = nullptr;
FirmwareUtil *pFwInterface = nullptr;
int resetTimeout = 10000; // in milliseconds

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -24,6 +24,8 @@ class OsGlobalOperations {
virtual void getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) = 0;
virtual void getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) = 0;
virtual void getDriverVersion(char (&driverVersion)[ZES_STRING_PROPERTY_SIZE]) = 0;
virtual void getWedgedStatus(zes_device_state_t *pState) = 0;
virtual void getRepairStatus(zes_device_state_t *pState) = 0;
virtual Device *getDevice() = 0;
virtual ze_result_t reset(ze_bool_t force) = 0;
virtual ze_result_t scanProcessesState(std::vector<zes_process_state_t> &pProcessList) = 0;

View File

@ -31,6 +31,10 @@ void WddmGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPER
void WddmGlobalOperationsImp::getDriverVersion(char (&driverVersion)[ZES_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getWedgedStatus(zes_device_state_t *pState) {
}
void WddmGlobalOperationsImp::getRepairStatus(zes_device_state_t *pState) {
}
ze_result_t WddmGlobalOperationsImp::reset(ze_bool_t force) {
uint32_t value = 0;
KmdSysman::RequestProperty request;

View File

@ -22,6 +22,8 @@ class WddmGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMov
void getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) override;
void getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) override;
void getDriverVersion(char (&driverVersion)[ZES_STRING_PROPERTY_SIZE]) override;
void getWedgedStatus(zes_device_state_t *pState) override;
void getRepairStatus(zes_device_state_t *pState) override;
Device *getDevice() override;
ze_result_t reset(ze_bool_t force) override;
ze_result_t scanProcessesState(std::vector<zes_process_state_t> &pProcessList) override;

View File

@ -1,22 +1,27 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(libigsc_FOUND)
set(L0_SRCS_TOOLS_SYSMAN_LINUX_FIRMWARE_UTIL
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/firmware_util_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/firmware_util_imp.h
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_base.h
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_extended.h
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util.h
)
else()
set(L0_SRCS_TOOLS_SYSMAN_LINUX_FIRMWARE_UTIL
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_base.h
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_extended.h
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util.h
)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/firmware_util_extended.h ${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_extended.h)
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}

View File

@ -10,26 +10,16 @@
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/sysman/linux/firmware_util/firmware_util_base.h"
#include "level_zero/tools/source/sysman/linux/firmware_util/firmware_util_extended.h"
#ifdef IGSC_PRESENT
#include "igsc_lib.h"
#else
typedef struct igsc_device_info {
} igsc_device_info_t;
#endif
#include <string>
#include <vector>
namespace L0 {
class FirmwareUtil {
class FirmwareUtil : public virtual FirmwareUtilBase, public virtual FirmwareUtilExtended {
public:
static FirmwareUtil *create();
virtual ze_result_t fwDeviceInit() = 0;
virtual ze_result_t getFirstDevice(igsc_device_info *) = 0;
virtual ze_result_t fwGetVersion(std::string &fwVersion) = 0;
virtual ze_result_t opromGetVersion(std::string &fwVersion) = 0;
virtual ze_result_t fwFlashGSC(void *pImage, uint32_t size) = 0;
virtual ze_result_t fwFlashOprom(void *pImage, uint32_t size) = 0;
virtual ~FirmwareUtil() = default;
};
} // namespace L0

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "level_zero/core/source/device/device.h"
#ifdef IGSC_PRESENT
#include "igsc_lib.h"
#else
typedef struct igsc_device_info {
} igsc_device_info_t;
#endif
namespace L0 {
class FirmwareUtilBase {
public:
virtual ze_result_t fwDeviceInit() = 0;
virtual ze_result_t getFirstDevice(igsc_device_info *) = 0;
virtual ze_result_t fwGetVersion(std::string &fwVersion) = 0;
virtual ze_result_t opromGetVersion(std::string &fwVersion) = 0;
virtual ze_result_t fwFlashGSC(void *pImage, uint32_t size) = 0;
virtual ze_result_t fwFlashOprom(void *pImage, uint32_t size) = 0;
};
} // namespace L0

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "level_zero/core/source/device/device.h"
#ifdef IGSC_PRESENT
#include "igsc_lib.h"
#endif
namespace L0 {
class FirmwareUtilExtended {
public:
};
} // namespace L0

View File

@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_zes_sysman_diagnostics.h
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_sysman_diagnostics.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_zes_sysman_diagnostics.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_sysman_diagnostics.cpp
)
endif()

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_zes_sysman_firmware.h
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_sysman_firmware.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_zes_sysman_firmware.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_sysman_firmware.cpp
)
endif()

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_global_operations.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_global_operations.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_global_operations.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_global_operations.h
)
endif()

View File

@ -268,20 +268,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsNotWedgedWhenCallingGetDevice
EXPECT_EQ(0u, deviceState.reset);
}
TEST_F(SysmanGlobalOperationsFixture, GivenWedgedFileNotFoundWhenCallingGetDeviceStateThenZeResultErrorUnsupportedFeatureIsReturned) {
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValWedgedFileNotFound));
zes_device_state_t deviceState;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceGetState(device, &deviceState));
}
TEST_F(SysmanGlobalOperationsFixture, GivenWedgedFileInsufficientPermissionsWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValWedgedFileInsufficientPermissions));
zes_device_state_t deviceState;
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, zesDeviceGetState(device, &deviceState));
}
TEST_F(SysmanGlobalOperationsFixture, GivenPermissionDeniedWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
ON_CALL(*pSysfsAccess.get(), getRealPath(_, Matcher<std::string &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getRealPathVal));