fix(sysman): Update fimrware handles discovery using igsc
Related-To: NEO-14891 Signed-off-by: Vishnu Khanth <vishnu.khanth.b@intel.com>
This commit is contained in:
parent
3989471ffc
commit
f2df772552
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -20,37 +20,13 @@
|
|||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
static const std::string mtdDescriptor("/proc/mtd");
|
||||
|
||||
void OsFirmware::getSupportedFwTypes(std::vector<std::string> &supportedFwTypes, OsSysman *pOsSysman) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
std::vector<std ::string> deviceSupportedFwTypes = {};
|
||||
supportedFwTypes.clear();
|
||||
if (pFwInterface != nullptr) {
|
||||
auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
|
||||
pSysmanProductHelper->getDeviceSupportedFwTypes(pFwInterface, deviceSupportedFwTypes);
|
||||
}
|
||||
|
||||
if (deviceSupportedFwTypes.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
std::vector<std::string> mtdDescriptorStrings = {};
|
||||
ze_result_t result = pFsAccess->read(mtdDescriptor, mtdDescriptorStrings);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read %s and returning error:0x%x \n", __FUNCTION__, mtdDescriptor.c_str(), result);
|
||||
return;
|
||||
}
|
||||
for (const auto &readByteLine : mtdDescriptorStrings) {
|
||||
for (const auto &fwType : deviceSupportedFwTypes) {
|
||||
if (std::string::npos != readByteLine.find(fwType)) {
|
||||
if (std::find(supportedFwTypes.begin(), supportedFwTypes.end(), fwType) == supportedFwTypes.end()) {
|
||||
supportedFwTypes.push_back(fwType);
|
||||
}
|
||||
}
|
||||
}
|
||||
pSysmanProductHelper->getDeviceSupportedFwTypes(pFwInterface, supportedFwTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
* Copyright (C) 2022-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ const std::string fwImageOpromInit = "igsc_image_oprom_init";
|
|||
const std::string fwImageOpromType = "igsc_image_oprom_type";
|
||||
const std::string fwDeviceOpromUpdate = "igsc_device_oprom_update";
|
||||
const std::string fwDeviceOpromVersion = "igsc_device_oprom_version";
|
||||
const std::string fwDevicePscVersion = "igsc_device_psc_version";
|
||||
const std::string fwDeviceClose = "igsc_device_close";
|
||||
|
||||
pIgscDeviceInitByDevice deviceInitByDevice;
|
||||
|
@ -37,6 +38,7 @@ pIgscImageOpromInit imageOpromInit;
|
|||
pIgscImageOpromType imageOpromType;
|
||||
pIgscDeviceOpromUpdate deviceOpromUpdate;
|
||||
pIgscDeviceOpromVersion deviceOpromVersion;
|
||||
pIgscDevicePscVersion deviceGetPscVersion;
|
||||
pIgscDeviceClose deviceClose;
|
||||
|
||||
bool FirmwareUtilImp::loadEntryPoints() {
|
||||
|
@ -51,6 +53,7 @@ bool FirmwareUtilImp::loadEntryPoints() {
|
|||
ok = ok && getSymbolAddr(fwImageOpromType, imageOpromType);
|
||||
ok = ok && getSymbolAddr(fwDeviceOpromUpdate, deviceOpromUpdate);
|
||||
ok = ok && getSymbolAddr(fwDeviceOpromVersion, deviceOpromVersion);
|
||||
ok = ok && getSymbolAddr(fwDevicePscVersion, deviceGetPscVersion);
|
||||
ok = ok && getSymbolAddr(fwDeviceClose, deviceClose);
|
||||
ok = ok && loadEntryPointsExt();
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ typedef int (*pIgscIfrGetStatusExt)(struct igsc_device_handle *handle,
|
|||
uint32_t *ifrApplied,
|
||||
uint32_t *prevErrors,
|
||||
uint32_t *pendingReset);
|
||||
|
||||
typedef int (*pIgscDevicePscVersion)(struct igsc_device_handle *handle,
|
||||
struct igsc_psc_version *version);
|
||||
typedef int (*pIgscIafPscUpdate)(struct igsc_device_handle *handle,
|
||||
const uint8_t *buffer,
|
||||
const uint32_t bufferLen,
|
||||
|
@ -82,6 +85,10 @@ typedef int (*pIgscGfspHeciCmd)(struct igsc_device_handle *handle,
|
|||
size_t outBufferSize,
|
||||
size_t *actualOutBufferSize);
|
||||
|
||||
extern const std::string fwDeviceFwVersion;
|
||||
extern const std::string fwDeviceOpromVersion;
|
||||
extern const std::string fwDevicePscVersion;
|
||||
|
||||
extern pIgscDeviceInitByDevice deviceInitByDevice;
|
||||
extern pIgscDeviceGetDeviceInfo deviceGetDeviceInfo;
|
||||
extern pIgscDeviceFwVersion deviceGetFwVersion;
|
||||
|
@ -95,6 +102,7 @@ extern pIgscDeviceOpromUpdate deviceOpromUpdate;
|
|||
extern pIgscDeviceOpromVersion deviceOpromVersion;
|
||||
extern pIgscDeviceClose deviceClose;
|
||||
extern pIgscIfrGetStatusExt deviceIfrGetStatusExt;
|
||||
extern pIgscDevicePscVersion deviceGetPscVersion;
|
||||
extern pIgscIafPscUpdate iafPscUpdate;
|
||||
extern pIgscGfspMemoryErrors gfspMemoryErrors;
|
||||
extern pIgscGfspCountTiles gfspCountTiles;
|
||||
|
|
|
@ -343,7 +343,35 @@ ze_result_t FirmwareUtilImp::flashFirmware(std::string fwType, void *pImage, uin
|
|||
}
|
||||
|
||||
void FirmwareUtilImp::getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) {
|
||||
fwTypes = deviceSupportedFirmwareTypes;
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
igsc_fw_version deviceFwVersion;
|
||||
memset(&deviceFwVersion, 0, sizeof(deviceFwVersion));
|
||||
deviceGetFwVersion = reinterpret_cast<pIgscDeviceFwVersion>(libraryHandle->getProcAddress(fwDeviceFwVersion));
|
||||
int ret = deviceGetFwVersion(&fwDeviceHandle, &deviceFwVersion);
|
||||
if (ret == IGSC_SUCCESS) {
|
||||
fwTypes.push_back(deviceSupportedFirmwareTypes[0]);
|
||||
}
|
||||
|
||||
igsc_oprom_version opromVersion;
|
||||
memset(&opromVersion, 0, sizeof(opromVersion));
|
||||
deviceOpromVersion = reinterpret_cast<pIgscDeviceOpromVersion>(libraryHandle->getProcAddress(fwDeviceOpromVersion));
|
||||
ret = deviceOpromVersion(&fwDeviceHandle, IGSC_OPROM_CODE, &opromVersion);
|
||||
|
||||
if (ret == IGSC_SUCCESS) {
|
||||
memset(&opromVersion, 0, sizeof(opromVersion));
|
||||
int ret = deviceOpromVersion(&fwDeviceHandle, IGSC_OPROM_DATA, &opromVersion);
|
||||
if (ret == IGSC_SUCCESS) {
|
||||
fwTypes.push_back(deviceSupportedFirmwareTypes[1]);
|
||||
}
|
||||
}
|
||||
|
||||
igsc_psc_version devicePscVersion;
|
||||
memset(&devicePscVersion, 0, sizeof(devicePscVersion));
|
||||
deviceGetPscVersion = reinterpret_cast<pIgscDevicePscVersion>(libraryHandle->getProcAddress(fwDevicePscVersion));
|
||||
ret = deviceGetPscVersion(&fwDeviceHandle, &devicePscVersion);
|
||||
if (ret == IGSC_SUCCESS) {
|
||||
fwTypes.push_back(deviceSupportedFirmwareTypes[2]);
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::getFwVersion(std::string fwType, std::string &firmwareVersion) {
|
||||
|
|
|
@ -26,20 +26,7 @@ class FirmwareInterface : public L0::Sysman::FirmwareUtil {};
|
|||
class FirmwareFsAccess : public L0::Sysman::FsAccessInterface {};
|
||||
class FirmwareSysfsAccess : public L0::Sysman::SysFsAccessInterface {};
|
||||
|
||||
struct MockFirmwareFsAccess : public FirmwareFsAccess {
|
||||
ze_bool_t isReadFwTypes = true;
|
||||
ze_result_t read(const std::string file, std::vector<std::string> &val) override {
|
||||
if (isReadFwTypes) {
|
||||
val.push_back("mtd3: 005ef000 00001000 \"i915-spi.42.auto.GSC\"");
|
||||
val.push_back("mtd4: 00200000 00001000 \"i915-spi.42.auto.OptionROM\"");
|
||||
val.push_back("mtd5: 00200000 00001000 \"i915-spi.42.auto.PSC\"");
|
||||
} else {
|
||||
val.push_back("mtd3: 005ef000 00001000 \"i915-spi.42.auto.GSC\"");
|
||||
val.push_back("mtd3: 005ef000 00001000 \"i915-spi.42.auto.GSC\"");
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
};
|
||||
struct MockFirmwareFsAccess : public FirmwareFsAccess {};
|
||||
|
||||
struct MockFirmwareSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
|
@ -83,6 +70,7 @@ struct MockFirmwareSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
|||
struct MockFirmwareInterface : public FirmwareInterface {
|
||||
|
||||
ze_result_t getFwVersionResult = ZE_RESULT_SUCCESS;
|
||||
ze_bool_t isFirmwareVersionsSupported = true;
|
||||
|
||||
ze_result_t mockFwGetVersion(std::string &fwVersion) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
@ -112,7 +100,9 @@ struct MockFirmwareInterface : public FirmwareInterface {
|
|||
}
|
||||
|
||||
void getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) override {
|
||||
fwTypes = mockSupportedFirmwareTypes;
|
||||
if (isFirmwareVersionsSupported) {
|
||||
fwTypes = mockSupportedFirmwareTypes;
|
||||
}
|
||||
}
|
||||
|
||||
MockFirmwareInterface() = default;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -196,16 +196,16 @@ HWTEST2_F(ZesSysmanFirmwareFixture, GivenValidFirmwareHandleWhenFailedToReadPSCV
|
|||
delete ptestFirmwareImp;
|
||||
}
|
||||
|
||||
HWTEST2_F(ZesSysmanFirmwareFixture, GivenRepeatedFWTypesWhenInitializingFirmwareContextThenexpectNoHandles, IsXeHpcOrXeHpgCore) {
|
||||
HWTEST2_F(ZesSysmanFirmwareFixture, GivenFwVersionsUnsupportedWhenInitializingFirmwareContextThenExpectZeroHandles, IsXeHpcOrXeHpgCore) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pFirmwareHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pFirmwareHandleContext->handleList.clear();
|
||||
pFsAccess->isReadFwTypes = false;
|
||||
pMockFwInterface->isFirmwareVersionsSupported = false;
|
||||
|
||||
pSysmanDeviceImp->pFirmwareHandleContext->init();
|
||||
|
||||
EXPECT_EQ(1u, pSysmanDeviceImp->pFirmwareHandleContext->handleList.size());
|
||||
EXPECT_EQ(0u, pSysmanDeviceImp->pFirmwareHandleContext->handleList.size());
|
||||
}
|
||||
|
||||
HWTEST2_F(ZesSysmanFirmwareFixture, GivenValidFirmwareHandleWhenFlashingGscFirmwareThenSuccessIsReturned, IsXeHpcOrXeHpgCore) {
|
||||
|
|
|
@ -24,7 +24,13 @@ namespace ult {
|
|||
|
||||
constexpr static uint32_t mockMaxTileCount = 2;
|
||||
static int mockMemoryHealthIndicator = IGSC_HEALTH_INDICATOR_HEALTHY;
|
||||
std::vector<uint32_t> mockSupportedHeciCmds = {GfspHeciConstants::Cmd::getEccConfigurationCmd16, GfspHeciConstants::Cmd::setEccConfigurationCmd15};
|
||||
static int mockGetFwVersion = IGSC_SUCCESS;
|
||||
static int mockGetOpromCodeVersion = IGSC_SUCCESS;
|
||||
static int mockGetOpromDataVersion = IGSC_SUCCESS;
|
||||
static int mockGetPscVersion = IGSC_SUCCESS;
|
||||
|
||||
std::vector<uint32_t>
|
||||
mockSupportedHeciCmds = {GfspHeciConstants::Cmd::getEccConfigurationCmd16, GfspHeciConstants::Cmd::setEccConfigurationCmd15};
|
||||
uint8_t mockEccCurrentState = 1;
|
||||
uint8_t mockEccPendingState = 1;
|
||||
uint8_t mockEccHeciCmd16Val = 1;
|
||||
|
@ -136,6 +142,28 @@ static int mockGetEccConfig(struct igsc_device_handle *handle, uint32_t gfspCmd,
|
|||
}
|
||||
}
|
||||
|
||||
static int mockIgscDeviceFwVersion(struct igsc_device_handle *handle,
|
||||
struct igsc_fw_version *version) {
|
||||
return mockGetFwVersion;
|
||||
}
|
||||
|
||||
static int mockIgscDeviceOpromVersion(struct igsc_device_handle *handle,
|
||||
uint32_t opromType,
|
||||
struct igsc_oprom_version *version) {
|
||||
if (opromType == IGSC_OPROM_CODE) {
|
||||
return mockGetOpromCodeVersion;
|
||||
} else if (opromType == IGSC_OPROM_DATA) {
|
||||
return mockGetOpromDataVersion;
|
||||
} else {
|
||||
return IGSC_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
static int mockIgscDevicePscVersion(struct igsc_device_handle *handle,
|
||||
struct igsc_psc_version *version) {
|
||||
return mockGetPscVersion;
|
||||
}
|
||||
|
||||
TEST(FwStatusExtTest, GivenIFRWasSetWhenFirmwareUtilChecksIFRThenIFRStatusIsUpdated) {
|
||||
|
||||
VariableBackup<decltype(L0::Sysman::deviceIfrGetStatusExt)> mockDeviceIfrGetStatusExt(&L0::Sysman::deviceIfrGetStatusExt, [](struct igsc_device_handle *handle, uint32_t *supportedTests, uint32_t *hwCapabilities, uint32_t *ifrApplied, uint32_t *prevErrors, uint32_t *pendingReset) -> int {
|
||||
|
@ -892,6 +920,72 @@ TEST(LinuxFwEccTest, GivenHeciCmd15IsNotSupportedButCmd8IsSupportedThenWhenCalli
|
|||
delete pFwUtilImp;
|
||||
}
|
||||
|
||||
TEST(FwGetSupportedFwTypesTest, GivenFirmwareUtilAndAllFwTypesSupportedWhenCallingGetSupportedFwTypesThenExpectValidFwTypes) {
|
||||
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
|
||||
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
|
||||
osLibHandle->funcMap["igsc_device_fw_version"] = reinterpret_cast<void *>(&mockIgscDeviceFwVersion);
|
||||
osLibHandle->funcMap["igsc_device_oprom_version"] = reinterpret_cast<void *>(&mockIgscDeviceOpromVersion);
|
||||
osLibHandle->funcMap["igsc_device_psc_version"] = reinterpret_cast<void *>(&mockIgscDevicePscVersion);
|
||||
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
|
||||
|
||||
mockGetFwVersion = IGSC_SUCCESS;
|
||||
mockGetOpromCodeVersion = IGSC_SUCCESS;
|
||||
mockGetOpromDataVersion = IGSC_SUCCESS;
|
||||
mockGetPscVersion = IGSC_SUCCESS;
|
||||
|
||||
std::vector<std::string> fwTypes{};
|
||||
pFwUtilImp->getDeviceSupportedFwTypes(fwTypes);
|
||||
EXPECT_EQ(fwTypes.size(), 3u);
|
||||
|
||||
delete pFwUtilImp->libraryHandle;
|
||||
pFwUtilImp->libraryHandle = nullptr;
|
||||
delete pFwUtilImp;
|
||||
}
|
||||
|
||||
TEST(FwGetSupportedFwTypesTest, GivenFirmwareUtilAndAllFwTypesUnsupportedWhenCallingGetSupportedFwTypesThenExpectZeroFwTypes) {
|
||||
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
|
||||
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
|
||||
osLibHandle->funcMap["igsc_device_fw_version"] = reinterpret_cast<void *>(&mockIgscDeviceFwVersion);
|
||||
osLibHandle->funcMap["igsc_device_oprom_version"] = reinterpret_cast<void *>(&mockIgscDeviceOpromVersion);
|
||||
osLibHandle->funcMap["igsc_device_psc_version"] = reinterpret_cast<void *>(&mockIgscDevicePscVersion);
|
||||
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
|
||||
|
||||
mockGetFwVersion = IGSC_ERROR_NOT_SUPPORTED;
|
||||
mockGetOpromCodeVersion = IGSC_ERROR_NOT_SUPPORTED;
|
||||
mockGetOpromDataVersion = IGSC_ERROR_NOT_SUPPORTED;
|
||||
mockGetPscVersion = IGSC_ERROR_NOT_SUPPORTED;
|
||||
|
||||
std::vector<std::string> fwTypes{};
|
||||
pFwUtilImp->getDeviceSupportedFwTypes(fwTypes);
|
||||
EXPECT_EQ(fwTypes.size(), 0u);
|
||||
|
||||
delete pFwUtilImp->libraryHandle;
|
||||
pFwUtilImp->libraryHandle = nullptr;
|
||||
delete pFwUtilImp;
|
||||
}
|
||||
|
||||
TEST(FwGetSupportedFwTypesTest, GivenFirmwareUtilAndOnlyOpromCodeSupportedWhenCallingGetSupportedFwTypesThenExpectOpromFwTypeIsUnsupported) {
|
||||
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
|
||||
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
|
||||
osLibHandle->funcMap["igsc_device_fw_version"] = reinterpret_cast<void *>(&mockIgscDeviceFwVersion);
|
||||
osLibHandle->funcMap["igsc_device_oprom_version"] = reinterpret_cast<void *>(&mockIgscDeviceOpromVersion);
|
||||
osLibHandle->funcMap["igsc_device_psc_version"] = reinterpret_cast<void *>(&mockIgscDevicePscVersion);
|
||||
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
|
||||
|
||||
mockGetFwVersion = IGSC_SUCCESS;
|
||||
mockGetOpromCodeVersion = IGSC_SUCCESS;
|
||||
mockGetOpromDataVersion = IGSC_ERROR_NOT_SUPPORTED;
|
||||
mockGetPscVersion = IGSC_SUCCESS;
|
||||
|
||||
std::vector<std::string> fwTypes{};
|
||||
pFwUtilImp->getDeviceSupportedFwTypes(fwTypes);
|
||||
EXPECT_EQ(fwTypes.size(), 2u);
|
||||
|
||||
delete pFwUtilImp->libraryHandle;
|
||||
pFwUtilImp->libraryHandle = nullptr;
|
||||
delete pFwUtilImp;
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
|
Loading…
Reference in New Issue