fix: Synchronize power property retrievals

Related-To: NEO-10525

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2024-02-28 10:18:27 +00:00
committed by Compute-Runtime-Automation
parent 588921ed9b
commit a023b40c90
6 changed files with 71 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -45,6 +45,10 @@ class LinuxPowerImp::PowerLimitRestorer : NEO::NonCopyableOrMovableClass {
uint64_t powerLimitValue = 0;
};
std::unique_lock<std::mutex> LinuxPowerImp::obtainMutex() {
return std::unique_lock<std::mutex>(this->powerLimitMutex);
}
ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
@@ -64,7 +68,8 @@ ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
}
std::string sustainedLimit = i915HwmonDir + "/" + sustainedPowerLimit;
auto powerLimitRestorer = L0::LinuxPowerImp::PowerLimitRestorer(pSysfsAccess, sustainedLimit);
auto lock = this->obtainMutex();
auto powerLimitRestorer = L0::LinuxPowerImp::PowerLimitRestorer(pSysfsAccess, sustainedLimit); // 600
if (powerLimitRestorer != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(powerLimitRestorer));
return getErrorCode(powerLimitRestorer);
@@ -88,7 +93,7 @@ ze_result_t LinuxPowerImp::getMinLimit(int32_t &minLimit) {
return getErrorCode(result);
}
result = pSysfsAccess->read(sustainedLimit, powerLimit);
result = pSysfsAccess->read(sustainedLimit, powerLimit); // 300
if (ZE_RESULT_SUCCESS != result) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(result));
return getErrorCode(result);
@@ -109,7 +114,7 @@ ze_result_t LinuxPowerImp::getMaxLimit(int32_t &maxLimit) {
return getErrorCode(result);
}
result = pSysfsAccess->read(sustainedLimit, powerLimit);
result = pSysfsAccess->read(sustainedLimit, powerLimit); // 600
if (ZE_RESULT_SUCCESS != result) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(result));
return getErrorCode(result);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -42,10 +42,12 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
protected:
PlatformMonitoringTech *pPmt = nullptr;
SysfsAccess *pSysfsAccess = nullptr;
virtual std::unique_lock<std::mutex> obtainMutex();
private:
std::string i915HwmonDir;
std::string criticalPowerLimit;
std::mutex powerLimitMutex{};
static const std::string hwmonDir;
static const std::string i915;
static const std::string sustainedPowerLimit;