mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
feature(sysman): Xe porting of Power Module
Related-To: LOCI-4851 Signed-off-by: Kumar, Shubham <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b3a7f5dccb
commit
03a8b76e02
@@ -10,20 +10,17 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
const std::string LinuxPowerImp::hwmonDir("device/hwmon");
|
||||
const std::string LinuxPowerImp::i915("i915");
|
||||
const std::string LinuxPowerImp::sustainedPowerLimitEnabled("power1_max_enable");
|
||||
const std::string LinuxPowerImp::sustainedPowerLimit("power1_max");
|
||||
const std::string LinuxPowerImp::sustainedPowerLimitInterval("power1_max_interval");
|
||||
const std::string LinuxPowerImp::burstPowerLimitEnabled("power1_cap_enable");
|
||||
const std::string LinuxPowerImp::burstPowerLimit("power1_cap");
|
||||
const std::string LinuxPowerImp::energyCounterNode("energy1_input");
|
||||
const std::string LinuxPowerImp::defaultPowerLimit("power_default_limit");
|
||||
const std::string LinuxPowerImp::minPowerLimit("power_min_limit");
|
||||
const std::string LinuxPowerImp::maxPowerLimit("power_max_limit");
|
||||
@@ -38,17 +35,17 @@ ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
|
||||
pProperties->maxLimit = -1;
|
||||
|
||||
uint32_t val = 0;
|
||||
auto result = pSysfsAccess->read(i915HwmonDir + "/" + defaultPowerLimit, val);
|
||||
auto result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + defaultPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
pProperties->defaultLimit = static_cast<int32_t>(val / milliFactor); // need to convert from microwatt to milliwatt
|
||||
}
|
||||
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + minPowerLimit, val);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + minPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS == result && val != 0) {
|
||||
pProperties->minLimit = static_cast<int32_t>(val / milliFactor); // need to convert from microwatt to milliwatt
|
||||
}
|
||||
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + maxPowerLimit, val);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + maxPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS == result && val != std::numeric_limits<uint32_t>::max()) {
|
||||
pProperties->maxLimit = static_cast<int32_t>(val / milliFactor); // need to convert from microwatt to milliwatt
|
||||
}
|
||||
@@ -71,14 +68,15 @@ ze_result_t LinuxPowerImp::getPmtEnergyCounter(zes_power_energy_counter_t *pEner
|
||||
}
|
||||
ze_result_t LinuxPowerImp::getEnergyCounter(zes_power_energy_counter_t *pEnergy) {
|
||||
pEnergy->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
ze_result_t result = pSysfsAccess->read(i915HwmonDir + "/" + energyCounterNode, pEnergy->energy);
|
||||
std::string energyCounterNode = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameEnergyCounterNode, subdeviceId, false);
|
||||
ze_result_t result = pSysfsAccess->read(energyCounterNode, pEnergy->energy);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
if (pPmt != nullptr) {
|
||||
return getPmtEnergyCounter(pEnergy);
|
||||
}
|
||||
}
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), energyCounterNode.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), energyCounterNode.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
return result;
|
||||
@@ -88,44 +86,46 @@ ze_result_t LinuxPowerImp::getLimits(zes_power_sustained_limit_t *pSustained, ze
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||
uint64_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimitEnabled, val);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + sustainedPowerLimitEnabled, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
pSustained->enabled = static_cast<ze_bool_t>(val);
|
||||
|
||||
if (pSustained->enabled) {
|
||||
val = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
std::string sustainedPowerLimit = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimit, subdeviceId, false);
|
||||
result = pSysfsAccess->read(sustainedPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
val /= milliFactor; // Convert microWatts to milliwatts
|
||||
pSustained->power = static_cast<int32_t>(val);
|
||||
|
||||
val = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimitInterval, val);
|
||||
std::string sustainedPowerLimitInterval = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimitInterval, subdeviceId, false);
|
||||
result = pSysfsAccess->read(sustainedPowerLimitInterval, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimitInterval.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimitInterval.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
pSustained->interval = static_cast<int32_t>(val);
|
||||
}
|
||||
}
|
||||
if (pBurst != nullptr) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + burstPowerLimitEnabled, val);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + burstPowerLimitEnabled, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), burstPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), burstPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
pBurst->enabled = static_cast<ze_bool_t>(val);
|
||||
|
||||
if (pBurst->enabled) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + burstPowerLimit, val);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + burstPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), burstPowerLimit.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), burstPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
val /= milliFactor; // Convert microWatts to milliwatts
|
||||
@@ -145,15 +145,15 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
|
||||
int32_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
uint64_t isSustainedPowerLimitEnabled = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimitEnabled, isSustainedPowerLimitEnabled);
|
||||
result = pSysfsAccess->read(intelGraphicsHwmonDir + "/" + sustainedPowerLimitEnabled, isSustainedPowerLimitEnabled);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->read() failed to read %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
if (isSustainedPowerLimitEnabled != static_cast<uint64_t>(pSustained->enabled)) {
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimitEnabled, static_cast<int>(pSustained->enabled));
|
||||
result = pSysfsAccess->write(intelGraphicsHwmonDir + "/" + sustainedPowerLimitEnabled, static_cast<int>(pSustained->enabled));
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
isSustainedPowerLimitEnabled = static_cast<uint64_t>(pSustained->enabled);
|
||||
@@ -161,32 +161,34 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
|
||||
|
||||
if (isSustainedPowerLimitEnabled) {
|
||||
val = static_cast<uint32_t>(pSustained->power) * milliFactor; // Convert milliWatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
std::string sustainedPowerLimit = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimit, subdeviceId, false);
|
||||
result = pSysfsAccess->write(sustainedPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimitInterval, pSustained->interval);
|
||||
std::string sustainedPowerLimitInterval = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimitInterval, subdeviceId, false);
|
||||
result = pSysfsAccess->write(sustainedPowerLimitInterval, pSustained->interval);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), sustainedPowerLimitInterval.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), sustainedPowerLimitInterval.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
}
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
if (pBurst != nullptr) {
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + burstPowerLimitEnabled, static_cast<int>(pBurst->enabled));
|
||||
result = pSysfsAccess->write(intelGraphicsHwmonDir + "/" + burstPowerLimitEnabled, static_cast<int>(pBurst->enabled));
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), burstPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), burstPowerLimitEnabled.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
|
||||
if (pBurst->enabled) {
|
||||
val = static_cast<uint32_t>(pBurst->power) * milliFactor; // Convert milliWatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + burstPowerLimit, val);
|
||||
result = pSysfsAccess->write(intelGraphicsHwmonDir + "/" + burstPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, i915HwmonDir.c_str(), burstPowerLimit.c_str(), getErrorCode(result));
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): SysfsAccess->write() failed to write into %s/%s and returning error:0x%x \n", __FUNCTION__, intelGraphicsHwmonDir.c_str(), burstPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
}
|
||||
@@ -215,7 +217,8 @@ ze_result_t LinuxPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_de
|
||||
}
|
||||
|
||||
bool LinuxPowerImp::isHwmonDir(std::string name) {
|
||||
if (isSubdevice == false && (name == i915)) {
|
||||
std::string intelGraphicsHwmonName = pSysmanKmdInterface->getHwmonName(subdeviceId, isSubdevice);
|
||||
if (isSubdevice == false && (name == intelGraphicsHwmonName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -223,6 +226,7 @@ bool LinuxPowerImp::isHwmonDir(std::string name) {
|
||||
|
||||
bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
std::vector<std::string> listOfAllHwmonDirs = {};
|
||||
const std::string hwmonDir("device/hwmon");
|
||||
bool hwmonDirExists = false;
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->scanDirEntries(hwmonDir, listOfAllHwmonDirs)) {
|
||||
hwmonDirExists = false;
|
||||
@@ -234,7 +238,7 @@ bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
continue;
|
||||
}
|
||||
if (isHwmonDir(name)) {
|
||||
i915HwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
intelGraphicsHwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
hwmonDirExists = true;
|
||||
canControl = true;
|
||||
}
|
||||
@@ -248,13 +252,13 @@ bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
LinuxPowerImp::LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
pSysfsAccess = pSysmanKmdInterface->getSysFsAccess(pLinuxSysmanImp->getDeviceName());
|
||||
}
|
||||
|
||||
OsPower *OsPower::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
LinuxPowerImp *pLinuxPowerImp = new LinuxPowerImp(pOsSysman, onSubdevice, subdeviceId);
|
||||
return static_cast<OsPower *>(pLinuxPowerImp);
|
||||
}
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysfsAccess;
|
||||
class PlatformMonitoringTech;
|
||||
class SysFsAccessInterface;
|
||||
class SysmanKmdInterface;
|
||||
class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t getProperties(zes_power_properties_t *pProperties) override;
|
||||
@@ -39,13 +40,12 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
|
||||
private:
|
||||
std::string i915HwmonDir;
|
||||
std::string intelGraphicsHwmonDir;
|
||||
std::string energyHwmonDir;
|
||||
static const std::string hwmonDir;
|
||||
static const std::string i915;
|
||||
static const std::string sustainedPowerLimitEnabled;
|
||||
static const std::string sustainedPowerLimit;
|
||||
static const std::string sustainedPowerLimitInterval;
|
||||
|
||||
Reference in New Issue
Block a user