firmware: Avoid adding the FWtype if already exists in vector

- Avoid adding the duplicate FWtypes in case of multi GPU devices

Related-To: LOCI-2623
Signed-off-by: Pichika Uday Kiran <pichika.uday.kiran@intel.com>
This commit is contained in:
Pichika Uday Kiran 2021-10-14 10:39:09 +00:00 committed by Compute-Runtime-Automation
parent c1a4e3ad50
commit 3efa0330f4
3 changed files with 21 additions and 1 deletions

View File

@ -27,7 +27,9 @@ ze_result_t OsFirmware::getSupportedFwTypes(std::vector<std::string> &supportedF
for (const auto &readByteLine : mtdDescriptorStrings) {
for (const auto &fwType : deviceSupportedFwTypes) {
if (std::string::npos != readByteLine.find(fwType)) {
supportedFwTypes.push_back(fwType);
if (std::find(supportedFwTypes.begin(), supportedFwTypes.end(), fwType) == supportedFwTypes.end()) {
supportedFwTypes.push_back(fwType);
}
}
}
}

View File

@ -30,6 +30,11 @@ struct Mock<FirmwareFsAccess> : public FirmwareFsAccess {
val.push_back("mtd5: 00200000 00001000 \"i915-spi.42.auto.OptionROM\"");
return ZE_RESULT_SUCCESS;
}
ze_result_t readMtdValSuccess(const std::string file, std::vector<std::string> &val) {
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;
}
ze_result_t readValFailure(const std::string file, std::vector<std::string> &val) {
return ZE_RESULT_ERROR_NOT_AVAILABLE;
}

View File

@ -146,6 +146,19 @@ TEST_F(ZesFirmwareFixture, GivenFailedFirmwareInitializationWhenInitializingFirm
EXPECT_EQ(0u, pSysmanDeviceImp->pFirmwareHandleContext->handleList.size());
}
TEST_F(ZesFirmwareFixture, GivenRepeatedFWTypesWhenInitializingFirmwareContextThenexpectNoHandles) {
for (const auto &handle : pSysmanDeviceImp->pFirmwareHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pFirmwareHandleContext->handleList.clear();
ON_CALL(*pFsAccess.get(), read(_, _))
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<FirmwareFsAccess>::readMtdValSuccess));
pSysmanDeviceImp->pFirmwareHandleContext->init();
EXPECT_EQ(1u, pSysmanDeviceImp->pFirmwareHandleContext->handleList.size());
}
TEST_F(ZesFirmwareFixture, GivenValidFirmwareHandleWhenFlashingGscFirmwareThenSuccessIsReturned) {
FirmwareImp *ptestFirmwareImp = new FirmwareImp(pSysmanDeviceImp->pFirmwareHandleContext->pOsSysman, mockSupportedFwTypes[0]);
pSysmanDeviceImp->pFirmwareHandleContext->handleList.push_back(ptestFirmwareImp);