Skip to content

Commit 99cbd1b

Browse files
Pichika Uday KiranCompute-Runtime-Automation
Pichika Uday Kiran
authored andcommitted
firmware: Read new firmware version from sysfs
- Read the newly added firmware version from sysfs node Related-To: LOCI-2557 Signed-off-by: Pichika Uday Kiran <[email protected]>
1 parent ca4af1d commit 99cbd1b

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

level_zero/tools/source/sysman/firmware/linux/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020 Intel Corporation
2+
# Copyright (C) 2020-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -8,6 +8,7 @@ set(L0_SRCS_TOOLS_SYSMAN_FIRMWARE_LINUX
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/os_firmware_imp.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/os_firmware_imp.h
11+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}os_firmware_imp_helper.cpp
1112
)
1213

1314
if(UNIX)

level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ bool LinuxFirmwareImp::isFirmwareSupported(void) {
4848
}
4949

5050
void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
51-
std::string fwVersion;
52-
if (ZE_RESULT_SUCCESS == pFwInterface->getFwVersion(osFwType, fwVersion)) {
53-
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE);
54-
} else {
51+
if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) {
5552
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
5653
}
5754
pProperties->canControl = true; //Assuming that user has permission to flash the firmware
@@ -63,6 +60,7 @@ ze_result_t LinuxFirmwareImp::osFirmwareFlash(void *pImage, uint32_t size) {
6360

6461
LinuxFirmwareImp::LinuxFirmwareImp(OsSysman *pOsSysman, const std::string &fwType) : osFwType(fwType) {
6562
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
63+
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
6664
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
6765
}
6866

level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
1919
bool isFirmwareSupported(void) override;
2020
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
2121
ze_result_t osFirmwareFlash(void *pImage, uint32_t size) override;
22+
ze_result_t getFirmwareVersion(std::string fwType, zes_firmware_properties_t *pProperties);
2223
LinuxFirmwareImp() = default;
2324
LinuxFirmwareImp(OsSysman *pOsSysman, const std::string &fwType);
2425
~LinuxFirmwareImp() override = default;
2526

2627
protected:
2728
FirmwareUtil *pFwInterface = nullptr;
29+
SysfsAccess *pSysfsAccess = nullptr;
2830
bool isFWInitalized = false;
2931
std::string osFwType;
3032
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.h"
9+
10+
namespace L0 {
11+
12+
ze_result_t LinuxFirmwareImp::getFirmwareVersion(std::string fwType, zes_firmware_properties_t *pProperties) {
13+
std::string fwVersion;
14+
ze_result_t result = pFwInterface->getFwVersion(fwType, fwVersion);
15+
if (ZE_RESULT_SUCCESS == result) {
16+
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE);
17+
}
18+
return result;
19+
}
20+
21+
} // namespace L0

0 commit comments

Comments
 (0)