diff --git a/level_zero/tools/source/sysman/events/linux/os_events_imp.cpp b/level_zero/tools/source/sysman/events/linux/os_events_imp.cpp index 295afdbea9..af810ad46d 100644 --- a/level_zero/tools/source/sysman/events/linux/os_events_imp.cpp +++ b/level_zero/tools/source/sysman/events/linux/os_events_imp.cpp @@ -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; diff --git a/level_zero/tools/source/sysman/global_operations/linux/CMakeLists.txt b/level_zero/tools/source/sysman/global_operations/linux/CMakeLists.txt index 6a94633168..4b5aef15e2 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/CMakeLists.txt +++ b/level_zero/tools/source/sysman/global_operations/linux/CMakeLists.txt @@ -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 ) diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_helper.cpp b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_helper.cpp new file mode 100644 index 0000000000..52ed4f6979 --- /dev/null +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_helper.cpp @@ -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 \ No newline at end of file diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp index 91701d9da4..3025359ba8 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp @@ -390,20 +390,23 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vectorread(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(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) { diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h index ad4426817b..7062a1b5a4 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h @@ -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 &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 diff --git a/level_zero/tools/source/sysman/global_operations/os_global_operations.h b/level_zero/tools/source/sysman/global_operations/os_global_operations.h index e0a7807d67..ce0f88d1cb 100644 --- a/level_zero/tools/source/sysman/global_operations/os_global_operations.h +++ b/level_zero/tools/source/sysman/global_operations/os_global_operations.h @@ -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 &pProcessList) = 0; diff --git a/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.cpp b/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.cpp index 2303f4f043..92a7e94672 100644 --- a/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.cpp +++ b/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.cpp @@ -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; diff --git a/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.h b/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.h index 582c3a0292..2ecbb45fdb 100644 --- a/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.h +++ b/level_zero/tools/source/sysman/global_operations/windows/os_global_operations_imp.h @@ -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 &pProcessList) override; diff --git a/level_zero/tools/source/sysman/linux/firmware_util/CMakeLists.txt b/level_zero/tools/source/sysman/linux/firmware_util/CMakeLists.txt index 15c71321e6..b022d380e7 100644 --- a/level_zero/tools/source/sysman/linux/firmware_util/CMakeLists.txt +++ b/level_zero/tools/source/sysman/linux/firmware_util/CMakeLists.txt @@ -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} diff --git a/level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h index a8fc679a8a..92d3bf553e 100644 --- a/level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h +++ b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h @@ -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 #include 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 diff --git a/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_base.h b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_base.h new file mode 100644 index 0000000000..c93a5bc1fb --- /dev/null +++ b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_base.h @@ -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 diff --git a/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_extended.h b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_extended.h new file mode 100644 index 0000000000..bee8b52c2e --- /dev/null +++ b/level_zero/tools/source/sysman/linux/firmware_util/firmware_util_extended.h @@ -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 diff --git a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/CMakeLists.txt index 5f6ebae215..15a677bc56 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/CMakeLists.txt @@ -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() diff --git a/level_zero/tools/test/unit_tests/sources/sysman/firmware/linux/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/sysman/firmware/linux/CMakeLists.txt index 878f85d474..c03ecde713 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/firmware/linux/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/sources/sysman/firmware/linux/CMakeLists.txt @@ -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() diff --git a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/CMakeLists.txt index e39a97dfba..3c624b615c 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/CMakeLists.txt @@ -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() diff --git a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp index 4547f8d7f1..61e7bd5d10 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp @@ -268,20 +268,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsNotWedgedWhenCallingGetDevice EXPECT_EQ(0u, deviceState.reset); } -TEST_F(SysmanGlobalOperationsFixture, GivenWedgedFileNotFoundWhenCallingGetDeviceStateThenZeResultErrorUnsupportedFeatureIsReturned) { - ON_CALL(*pFsAccess.get(), read(_, Matcher(_))) - .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock::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(_))) - .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock::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(_))) .WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock::getRealPathVal));