Make calls to igsc from Sysman thread safe
Related-To: LOCI-4325 Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
parent
10d48dde59
commit
b733d56a36
|
@ -106,6 +106,7 @@ ze_result_t FirmwareUtilImp::fwDeviceInit() {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwGetVersion(std::string &fwVersion) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
igsc_fw_version deviceFwVersion;
|
||||
memset(&deviceFwVersion, 0, sizeof(deviceFwVersion));
|
||||
int ret = deviceGetFwVersion(&fwDeviceHandle, &deviceFwVersion);
|
||||
|
@ -121,6 +122,7 @@ ze_result_t FirmwareUtilImp::fwGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::opromGetVersion(std::string &fwVersion) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
igsc_oprom_version opromVersion;
|
||||
memset(&opromVersion, 0, sizeof(opromVersion));
|
||||
int ret = deviceOpromVersion(&fwDeviceHandle, IGSC_OPROM_CODE, &opromVersion);
|
||||
|
@ -145,6 +147,7 @@ ze_result_t FirmwareUtilImp::opromGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashGSC(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
int ret = deviceFwUpdate(&fwDeviceHandle, static_cast<const uint8_t *>(pImage), size, progressFunc, nullptr);
|
||||
if (ret != IGSC_SUCCESS) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
@ -153,6 +156,7 @@ ze_result_t FirmwareUtilImp::fwFlashGSC(void *pImage, uint32_t size) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashOprom(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
struct igsc_oprom_image *opromImg = nullptr;
|
||||
uint32_t opromImgType = 0;
|
||||
int retData = 0, retCode = 0;
|
||||
|
@ -180,6 +184,7 @@ FirmwareUtilImp::FirmwareUtilImp(uint16_t domain, uint8_t bus, uint8_t device, u
|
|||
}
|
||||
|
||||
FirmwareUtilImp::~FirmwareUtilImp() {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
if (nullptr != libraryHandle) {
|
||||
deviceClose(&fwDeviceHandle);
|
||||
delete libraryHandle;
|
||||
|
|
|
@ -51,6 +51,7 @@ ze_result_t FirmwareUtilImp::fwIfrApplied(bool &ifrStatus) {
|
|||
|
||||
// fwCallGetstatusExt() is a helper function to get the status of IFR after the diagnostics tests are run
|
||||
ze_result_t FirmwareUtilImp::fwCallGetstatusExt(uint32_t &supportedTests, uint32_t &ifrApplied, uint32_t &prevErrors, uint32_t &pendingReset) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
uint32_t hwCapabilities = 0;
|
||||
ifrApplied = 0;
|
||||
prevErrors = 0;
|
||||
|
@ -113,6 +114,7 @@ ze_result_t FirmwareUtilImp::fwGetMemoryErrorCount(zes_ras_error_type_t type, ui
|
|||
}
|
||||
|
||||
void FirmwareUtilImp::fwGetMemoryHealthIndicator(zes_mem_health_t *health) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
gfspGetHealthIndicator = reinterpret_cast<pIgscGfspGetHealthIndicator>(libraryHandle->getProcAddress(fwGfspGetHealthIndicator));
|
||||
if (gfspGetHealthIndicator != nullptr) {
|
||||
uint8_t healthIndicator = 0;
|
||||
|
@ -142,6 +144,7 @@ void FirmwareUtilImp::fwGetMemoryHealthIndicator(zes_mem_health_t *health) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
getEccConfig = reinterpret_cast<pIgscGetEccConfig>(libraryHandle->getProcAddress(fwEccConfigGet));
|
||||
if (getEccConfig != nullptr) {
|
||||
int ret = getEccConfig(&fwDeviceHandle, currentState, pendingState);
|
||||
|
@ -154,6 +157,7 @@ ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pend
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
setEccConfig = reinterpret_cast<pIgscSetEccConfig>(libraryHandle->getProcAddress(fwEccConfigSet));
|
||||
if (setEccConfig != nullptr) {
|
||||
int ret = setEccConfig(&fwDeviceHandle, newState, currentState, pendingState);
|
||||
|
@ -188,6 +192,7 @@ ze_result_t FirmwareUtilImp::fwSupportedDiagTests(std::vector<std::string> &supp
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
uint32_t status = 0;
|
||||
uint32_t extendedStatus = 0;
|
||||
uint32_t pendingReset = 0;
|
||||
|
@ -244,6 +249,7 @@ ze_result_t FirmwareUtilImp::pscGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashIafPsc(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
iafPscUpdate = reinterpret_cast<pIgscIafPscUpdate>(libraryHandle->getProcAddress(fwIafPscUpdate));
|
||||
|
||||
if (iafPscUpdate == nullptr) {
|
||||
|
|
|
@ -197,6 +197,7 @@ void LinuxSysmanImp::createFwUtilInterface() {
|
|||
}
|
||||
|
||||
FirmwareUtil *LinuxSysmanImp::getFwUtilInterface() {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
if (pFwUtilInterface == nullptr) {
|
||||
createFwUtilInterface();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "level_zero/sysman/source/sysman_device_imp.h"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
|
@ -87,6 +88,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
|||
static const std::string deviceDir;
|
||||
void createFwUtilInterface();
|
||||
void clearHPIE(int fd);
|
||||
std::mutex fwLock;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
|
|
@ -105,6 +105,7 @@ ze_result_t FirmwareUtilImp::fwDeviceInit() {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwGetVersion(std::string &fwVersion) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
igsc_fw_version deviceFwVersion;
|
||||
memset(&deviceFwVersion, 0, sizeof(deviceFwVersion));
|
||||
int ret = deviceGetFwVersion(&fwDeviceHandle, &deviceFwVersion);
|
||||
|
@ -120,6 +121,7 @@ ze_result_t FirmwareUtilImp::fwGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::opromGetVersion(std::string &fwVersion) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
igsc_oprom_version opromVersion;
|
||||
memset(&opromVersion, 0, sizeof(opromVersion));
|
||||
int ret = deviceOpromVersion(&fwDeviceHandle, IGSC_OPROM_CODE, &opromVersion);
|
||||
|
@ -144,6 +146,7 @@ ze_result_t FirmwareUtilImp::opromGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashGSC(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
int ret = deviceFwUpdate(&fwDeviceHandle, static_cast<const uint8_t *>(pImage), size, progressFunc, nullptr);
|
||||
if (ret != IGSC_SUCCESS) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
@ -152,6 +155,7 @@ ze_result_t FirmwareUtilImp::fwFlashGSC(void *pImage, uint32_t size) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashOprom(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
struct igsc_oprom_image *opromImg = nullptr;
|
||||
uint32_t opromImgType = 0;
|
||||
int retData = 0, retCode = 0;
|
||||
|
@ -179,6 +183,7 @@ FirmwareUtilImp::FirmwareUtilImp(uint16_t domain, uint8_t bus, uint8_t device, u
|
|||
}
|
||||
|
||||
FirmwareUtilImp::~FirmwareUtilImp() {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
if (nullptr != libraryHandle) {
|
||||
deviceClose(&fwDeviceHandle);
|
||||
delete libraryHandle;
|
||||
|
|
|
@ -50,6 +50,7 @@ ze_result_t FirmwareUtilImp::fwIfrApplied(bool &ifrStatus) {
|
|||
|
||||
// fwCallGetstatusExt() is a helper function to get the status of IFR after the diagnostics tests are run
|
||||
ze_result_t FirmwareUtilImp::fwCallGetstatusExt(uint32_t &supportedTests, uint32_t &ifrApplied, uint32_t &prevErrors, uint32_t &pendingReset) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
uint32_t hwCapabilities = 0;
|
||||
ifrApplied = 0;
|
||||
prevErrors = 0;
|
||||
|
@ -112,6 +113,7 @@ ze_result_t FirmwareUtilImp::fwGetMemoryErrorCount(zes_ras_error_type_t type, ui
|
|||
}
|
||||
|
||||
void FirmwareUtilImp::fwGetMemoryHealthIndicator(zes_mem_health_t *health) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
gfspGetHealthIndicator = reinterpret_cast<pIgscGfspGetHealthIndicator>(libraryHandle->getProcAddress(fwGfspGetHealthIndicator));
|
||||
if (gfspGetHealthIndicator != nullptr) {
|
||||
uint8_t healthIndicator = 0;
|
||||
|
@ -141,6 +143,7 @@ void FirmwareUtilImp::fwGetMemoryHealthIndicator(zes_mem_health_t *health) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
getEccConfig = reinterpret_cast<pIgscGetEccConfig>(libraryHandle->getProcAddress(fwEccConfigGet));
|
||||
if (getEccConfig != nullptr) {
|
||||
int ret = getEccConfig(&fwDeviceHandle, currentState, pendingState);
|
||||
|
@ -153,6 +156,7 @@ ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pend
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
setEccConfig = reinterpret_cast<pIgscSetEccConfig>(libraryHandle->getProcAddress(fwEccConfigSet));
|
||||
if (setEccConfig != nullptr) {
|
||||
int ret = setEccConfig(&fwDeviceHandle, newState, currentState, pendingState);
|
||||
|
@ -187,6 +191,7 @@ ze_result_t FirmwareUtilImp::fwSupportedDiagTests(std::vector<std::string> &supp
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
uint32_t status = 0;
|
||||
uint32_t extendedStatus = 0;
|
||||
uint32_t pendingReset = 0;
|
||||
|
@ -243,6 +248,7 @@ ze_result_t FirmwareUtilImp::pscGetVersion(std::string &fwVersion) {
|
|||
}
|
||||
|
||||
ze_result_t FirmwareUtilImp::fwFlashIafPsc(void *pImage, uint32_t size) {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
iafPscUpdate = reinterpret_cast<pIgscIafPscUpdate>(libraryHandle->getProcAddress(fwIafPscUpdate));
|
||||
|
||||
if (iafPscUpdate == nullptr) {
|
||||
|
|
|
@ -84,6 +84,7 @@ PmuInterface *LinuxSysmanImp::getPmuInterface() {
|
|||
}
|
||||
|
||||
FirmwareUtil *LinuxSysmanImp::getFwUtilInterface() {
|
||||
const std::lock_guard<std::mutex> lock(this->fwLock);
|
||||
if (pFwUtilInterface == nullptr) {
|
||||
createFwUtilInterface();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <linux/pci_regs.h>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
|
@ -104,6 +105,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
|||
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
|
||||
static const std::string deviceDir;
|
||||
void clearHPIE(int fd);
|
||||
std::mutex fwLock;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
|
Loading…
Reference in New Issue