mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Revert "feature: Remove support for min power limit property"
This reverts commit cb924cfe6e.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
10313b7b84
commit
b44725b371
@@ -19,6 +19,33 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class LinuxPowerImp::PowerLimitRestorer : NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
PowerLimitRestorer(L0::Sysman::SysFsAccessInterface *pSysfsAccess, std::string powerLimit) : pSysfsAccess(pSysfsAccess), powerLimit(powerLimit) {
|
||||
result = pSysfsAccess->read(powerLimit, powerLimitValue);
|
||||
}
|
||||
|
||||
~PowerLimitRestorer() {
|
||||
if (result == ZE_RESULT_SUCCESS) {
|
||||
result = pSysfsAccess->write(powerLimit, powerLimitValue);
|
||||
DEBUG_BREAK_IF(result != ZE_RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
operator ze_result_t() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
std::string powerLimit = {};
|
||||
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;
|
||||
@@ -37,7 +64,59 @@ ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
|
||||
return result;
|
||||
}
|
||||
|
||||
pProperties->maxLimit = pProperties->defaultLimit;
|
||||
auto lock = this->obtainMutex();
|
||||
auto powerLimitRestorer = L0::Sysman::LinuxPowerImp::PowerLimitRestorer(pSysfsAccess, sustainedPowerLimit);
|
||||
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);
|
||||
}
|
||||
|
||||
result = getMinLimit(pProperties->minLimit);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return getMaxLimit(pProperties->maxLimit);
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getMinLimit(int32_t &minLimit) {
|
||||
// Fw clamps to minimum value if power limit requested to set is less than min limit, Set to 100 micro watt to get min limit
|
||||
uint64_t powerLimit = 100;
|
||||
auto result = pSysfsAccess->write(sustainedPowerLimit, powerLimit);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to write %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
|
||||
result = pSysfsAccess->read(sustainedPowerLimit, powerLimit);
|
||||
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);
|
||||
}
|
||||
|
||||
pSysmanKmdInterface->convertSysfsValueUnit(SysmanKmdInterface::milli, pSysmanKmdInterface->getNativeUnit(SysfsName::sysfsNameSustainedPowerLimit), powerLimit, powerLimit);
|
||||
minLimit = static_cast<int32_t>(powerLimit);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getMaxLimit(int32_t &maxLimit) {
|
||||
// Fw clamps to maximum value if power limit requested to set is greater than max limit, Set to max value to get max limit
|
||||
uint64_t powerLimit = std::numeric_limits<int32_t>::max();
|
||||
auto result = pSysfsAccess->write(sustainedPowerLimit, powerLimit);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to write %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
|
||||
result = pSysfsAccess->read(sustainedPowerLimit, powerLimit);
|
||||
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);
|
||||
}
|
||||
|
||||
pSysmanKmdInterface->convertSysfsValueUnit(SysmanKmdInterface::milli, pSysmanKmdInterface->getNativeUnit(SysfsName::sysfsNameSustainedPowerLimit), powerLimit, powerLimit);
|
||||
maxLimit = static_cast<int32_t>(powerLimit);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,16 +45,19 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
SysmanProductHelper *pSysmanProductHelper = nullptr;
|
||||
virtual std::unique_lock<std::mutex> obtainMutex();
|
||||
|
||||
private:
|
||||
std::string intelGraphicsHwmonDir = {};
|
||||
std::string criticalPowerLimit = {};
|
||||
std::string sustainedPowerLimit = {};
|
||||
std::string sustainedPowerLimitInterval = {};
|
||||
std::mutex powerLimitMutex{};
|
||||
bool canControl = false;
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
uint32_t powerLimitCount = 0;
|
||||
class PowerLimitRestorer;
|
||||
|
||||
ze_result_t getErrorCode(ze_result_t result) {
|
||||
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
|
||||
@@ -63,6 +66,8 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t getMinLimit(int32_t &minLimit);
|
||||
ze_result_t getMaxLimit(int32_t &maxLimit);
|
||||
ze_result_t getDefaultLimit(int32_t &defaultLimit);
|
||||
};
|
||||
} // namespace Sysman
|
||||
|
||||
Reference in New Issue
Block a user