feature(sysman): Add power control support with xe driver
Support to get power related sysfs names based on drm driver installed. Related-To: LOCI-4403 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
parent
f84f22d23c
commit
424784f7cf
|
@ -11,18 +11,12 @@
|
|||
|
||||
#include "level_zero/sysman/source/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.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::sustainedPowerLimit("power1_max");
|
||||
const std::string LinuxPowerImp::sustainedPowerLimitInterval("power1_max_interval");
|
||||
const std::string LinuxPowerImp::energyCounterNode("energy1_input");
|
||||
const std::string LinuxPowerImp::defaultPowerLimit("power1_rated_max");
|
||||
|
||||
ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
|
||||
pProperties->onSubdevice = isSubdevice;
|
||||
pProperties->subdeviceId = subdeviceId;
|
||||
|
@ -39,11 +33,12 @@ ze_result_t LinuxPowerImp::getPropertiesExt(zes_power_ext_properties_t *pExtPope
|
|||
if (pExtPoperties->defaultLimit) {
|
||||
if (!isSubdevice) {
|
||||
uint32_t val = 0;
|
||||
ze_result_t result = pSysfsAccess->read(i915HwmonDir + "/" + defaultPowerLimit, val);
|
||||
std::string defaultPowerLimit = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameDefaultPowerLimit, subdeviceId, false);
|
||||
ze_result_t result = pSysfsAccess->read(defaultPowerLimit, val);
|
||||
if (result == ZE_RESULT_SUCCESS) {
|
||||
pExtPoperties->defaultLimit->limit = static_cast<int32_t>(val / milliFactor); // need to convert from microwatt to milliwatt
|
||||
} else {
|
||||
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(), defaultPowerLimit.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(), defaultPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
} else {
|
||||
|
@ -70,14 +65,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;
|
||||
|
@ -89,9 +85,9 @@ ze_result_t LinuxPowerImp::getLimits(zes_power_sustained_limit_t *pSustained, ze
|
|||
uint64_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
val = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
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
|
||||
|
@ -104,9 +100,9 @@ ze_result_t LinuxPowerImp::getLimits(zes_power_sustained_limit_t *pSustained, ze
|
|||
pBurst->enabled = false;
|
||||
}
|
||||
if (pPeak != nullptr) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
result = pSysfsAccess->read(criticalPowerLimit, 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(), criticalPowerLimit.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(), criticalPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
val /= milliFactor; // Convert microwatts to milliwatts
|
||||
|
@ -124,17 +120,17 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
|
|||
int32_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
val = static_cast<uint32_t>(pSustained->power) * milliFactor; // Convert milliwatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (pPeak != nullptr) {
|
||||
val = static_cast<uint32_t>(pPeak->powerAC) * milliFactor; // Convert milliwatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
result = pSysfsAccess->write(criticalPowerLimit, 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(), criticalPowerLimit.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(), criticalPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
}
|
||||
|
@ -153,16 +149,16 @@ ze_result_t LinuxPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_de
|
|||
uint64_t val = 0;
|
||||
uint8_t count = 0;
|
||||
if (count < *pCount) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
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);
|
||||
}
|
||||
|
||||
int32_t interval = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimitInterval, interval);
|
||||
result = pSysfsAccess->read(sustainedPowerLimitInterval, interval);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -179,9 +175,9 @@ ze_result_t LinuxPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_de
|
|||
}
|
||||
|
||||
if (count < *pCount) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
result = pSysfsAccess->read(criticalPowerLimit, val);
|
||||
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(), criticalPowerLimit.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(), criticalPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
|
@ -210,15 +206,15 @@ ze_result_t LinuxPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_de
|
|||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
if (pSustained[i].level == ZES_POWER_LEVEL_SUSTAINED) {
|
||||
val = pSustained[i].limit * milliFactor; // Convert milliwatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
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[i].interval);
|
||||
result = pSysfsAccess->write(sustainedPowerLimitInterval, pSustained[i].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);
|
||||
}
|
||||
} else if (pSustained[i].level == ZES_POWER_LEVEL_PEAK) {
|
||||
|
@ -227,9 +223,9 @@ ze_result_t LinuxPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_de
|
|||
} else {
|
||||
val = pSustained[i].limit * milliFactor; // Convert milliwatts to microwatts
|
||||
}
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
result = pSysfsAccess->write(criticalPowerLimit, 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(), criticalPowerLimit.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(), criticalPowerLimit.c_str(), getErrorCode(result));
|
||||
return getErrorCode(result);
|
||||
}
|
||||
} else {
|
||||
|
@ -258,12 +254,9 @@ ze_result_t LinuxPowerImp::setEnergyThreshold(double threshold) {
|
|||
// device/hwmon/hwmon2/energy1_input name = "i915_gt0" (Tile 0)
|
||||
// device/hwmon/hwmon3/energy1_input name = "i915_gt1" (Tile 1)
|
||||
|
||||
bool LinuxPowerImp::isHwmonDir(std::string name) {
|
||||
if (isSubdevice == true) {
|
||||
if (name == (i915 + "_gt" + std::to_string(subdeviceId))) {
|
||||
return true;
|
||||
}
|
||||
} else if (name == i915) {
|
||||
bool LinuxPowerImp::isIntelGraphicsHwmonDir(const std::string &name) {
|
||||
std::string intelGraphicsHwmonName = pSysmanKmdInterface->getHwmonName(subdeviceId, isSubdevice);
|
||||
if (name == intelGraphicsHwmonName) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -272,17 +265,18 @@ bool LinuxPowerImp::isHwmonDir(std::string name) {
|
|||
bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
std::vector<std::string> listOfAllHwmonDirs = {};
|
||||
bool hwmonDirExists = false;
|
||||
const std::string hwmonDir("device/hwmon");
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->scanDirEntries(hwmonDir, listOfAllHwmonDirs)) {
|
||||
hwmonDirExists = false;
|
||||
}
|
||||
for (const auto &tempHwmonDirEntry : listOfAllHwmonDirs) {
|
||||
const std::string i915NameFile = hwmonDir + "/" + tempHwmonDirEntry + "/" + "name";
|
||||
const std::string hwmonNameFile = hwmonDir + "/" + tempHwmonDirEntry + "/" + "name";
|
||||
std::string name;
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->read(i915NameFile, name)) {
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->read(hwmonNameFile, name)) {
|
||||
continue;
|
||||
}
|
||||
if (isHwmonDir(name)) {
|
||||
i915HwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
if (isIntelGraphicsHwmonDir(name)) {
|
||||
intelGraphicsHwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
hwmonDirExists = true;
|
||||
canControl = isSubdevice ? false : true;
|
||||
}
|
||||
|
@ -290,11 +284,14 @@ bool LinuxPowerImp::isPowerModuleSupported() {
|
|||
|
||||
if (!isSubdevice) {
|
||||
uint64_t val = 0;
|
||||
if (ZE_RESULT_SUCCESS == pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimit, val)) {
|
||||
sustainedPowerLimit = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimit, subdeviceId, false);
|
||||
criticalPowerLimit = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameCriticalPowerLimit, subdeviceId, false);
|
||||
sustainedPowerLimitInterval = intelGraphicsHwmonDir + "/" + pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameSustainedPowerLimitInterval, subdeviceId, false);
|
||||
if (ZE_RESULT_SUCCESS == pSysfsAccess->read(sustainedPowerLimit, val)) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
|
||||
if (ZE_RESULT_SUCCESS == pSysfsAccess->read(i915HwmonDir + "/" + criticalPowerLimit, val)) {
|
||||
if (ZE_RESULT_SUCCESS == pSysfsAccess->read(criticalPowerLimit, val)) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
}
|
||||
|
@ -309,12 +306,8 @@ LinuxPowerImp::LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_
|
|||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
productFamily = pLinuxSysmanImp->getProductFamily();
|
||||
if (productFamily == IGFX_PVC) {
|
||||
criticalPowerLimit = "curr1_crit";
|
||||
} else {
|
||||
criticalPowerLimit = "power1_crit";
|
||||
}
|
||||
}
|
||||
|
||||
OsPower *OsPower::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysmanKmdInterface;
|
||||
|
||||
class SysfsAccess;
|
||||
class PlatformMonitoringTech;
|
||||
class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
|
@ -33,7 +35,7 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
|||
ze_result_t getPropertiesExt(zes_power_ext_properties_t *pExtPoperties) override;
|
||||
|
||||
bool isPowerModuleSupported() override;
|
||||
bool isHwmonDir(std::string name);
|
||||
bool isIntelGraphicsHwmonDir(const std::string &name);
|
||||
ze_result_t getPmtEnergyCounter(zes_power_energy_counter_t *pEnergy);
|
||||
LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
LinuxPowerImp() = default;
|
||||
|
@ -42,16 +44,13 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
|||
protected:
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
|
||||
private:
|
||||
std::string i915HwmonDir;
|
||||
std::string criticalPowerLimit;
|
||||
static const std::string hwmonDir;
|
||||
static const std::string i915;
|
||||
static const std::string sustainedPowerLimit;
|
||||
static const std::string sustainedPowerLimitInterval;
|
||||
static const std::string energyCounterNode;
|
||||
static const std::string defaultPowerLimit;
|
||||
std::string intelGraphicsHwmonDir = {};
|
||||
std::string criticalPowerLimit = {};
|
||||
std::string sustainedPowerLimit = {};
|
||||
std::string sustainedPowerLimitInterval = {};
|
||||
bool canControl = false;
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/i915_prelim.h"
|
||||
|
||||
|
@ -19,11 +21,14 @@ using NEO::PrelimI915::I915_SAMPLE_BUSY;
|
|||
std::unique_ptr<SysmanKmdInterface> SysmanKmdInterface::create(const NEO::Drm &drm) {
|
||||
std::unique_ptr<SysmanKmdInterface> pSysmanKmdInterface;
|
||||
auto drmVersion = drm.getDrmVersion(drm.getFileDescriptor());
|
||||
auto pHwInfo = drm.getRootDeviceEnvironment().getHardwareInfo();
|
||||
const auto productFamily = pHwInfo->platform.eProductFamily;
|
||||
if ("xe" == drmVersion) {
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>(productFamily);
|
||||
} else {
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(productFamily);
|
||||
}
|
||||
|
||||
return pSysmanKmdInterface;
|
||||
}
|
||||
|
||||
|
@ -35,7 +40,7 @@ std::string SysmanKmdInterfaceXe::getBasePath(int subDeviceId) const {
|
|||
return "device/gt" + std::to_string(subDeviceId) + "/";
|
||||
}
|
||||
|
||||
void SysmanKmdInterfaceI915::initSysfsNameToFileMap() {
|
||||
void SysmanKmdInterfaceI915::initSysfsNameToFileMap(const PRODUCT_FAMILY productFamily) {
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinFrequency] = std::make_pair("rps_min_freq_mhz", "gt_min_freq_mhz");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMaxFrequency] = std::make_pair("rps_max_freq_mhz", "gt_max_freq_mhz");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinDefaultFrequency] = std::make_pair(".defaults/rps_min_freq_mhz", "");
|
||||
|
@ -52,9 +57,14 @@ void SysmanKmdInterfaceI915::initSysfsNameToFileMap() {
|
|||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonPL2] = std::make_pair("throttle_reason_pl2", "gt_throttle_reason_status_pl2");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonPL4] = std::make_pair("throttle_reason_pl4", "gt_throttle_reason_status_pl4");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonThermal] = std::make_pair("throttle_reason_thermal", "gt_throttle_reason_status_thermal");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameSustainedPowerLimit] = std::make_pair("", "power1_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameSustainedPowerLimitInterval] = std::make_pair("", "power1_max_interval");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameEnergyCounterNode] = std::make_pair("", "energy1_input");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameDefaultPowerLimit] = std::make_pair("", "power1_rated_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameCriticalPowerLimit] = std::make_pair("", (productFamily == IGFX_PVC) ? "curr1_crit" : "power1_crit");
|
||||
}
|
||||
|
||||
void SysmanKmdInterfaceXe::initSysfsNameToFileMap() {
|
||||
void SysmanKmdInterfaceXe::initSysfsNameToFileMap(const PRODUCT_FAMILY productFamily) {
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinFrequency] = std::make_pair("rps_min_freq_mhz", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMaxFrequency] = std::make_pair("rps_max_freq_mhz", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinDefaultFrequency] = std::make_pair(".defaults/rps_min_freq_mhz", "");
|
||||
|
@ -71,6 +81,11 @@ void SysmanKmdInterfaceXe::initSysfsNameToFileMap() {
|
|||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonPL2] = std::make_pair("throttle_reason_pl2", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonPL4] = std::make_pair("throttle_reason_pl4", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameThrottleReasonThermal] = std::make_pair("throttle_reason_thermal", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameSustainedPowerLimit] = std::make_pair("", "power1_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameSustainedPowerLimitInterval] = std::make_pair("", "power1_max_interval");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameEnergyCounterNode] = std::make_pair("", "energy1_input");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameDefaultPowerLimit] = std::make_pair("", "power1_rated_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameCriticalPowerLimit] = std::make_pair("", (productFamily == IGFX_PVC) ? "curr1_crit" : "power1_crit");
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceI915::getSysfsFilePath(SysfsName sysfsName, int subDeviceId, bool baseDirectoryExists) {
|
||||
|
@ -111,5 +126,15 @@ int64_t SysmanKmdInterfaceXe::getEngineActivityFd(zes_engine_group_t engineGroup
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceI915::getHwmonName(int subDeviceId, bool isSubdevice) const {
|
||||
std::string filePath = isSubdevice ? "i915_gt" + std::to_string(subDeviceId) : "i915";
|
||||
return filePath;
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceXe::getHwmonName(int subDeviceId, bool isSubdevice) const {
|
||||
std::string filePath = isSubdevice ? "xe_tile" + std::to_string(subDeviceId) : "xe";
|
||||
return filePath;
|
||||
}
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
|
@ -64,6 +66,11 @@ enum class SysfsName {
|
|||
sysfsNameThrottleReasonPL2,
|
||||
sysfsNameThrottleReasonPL4,
|
||||
sysfsNameThrottleReasonThermal,
|
||||
sysfsNameSustainedPowerLimit,
|
||||
sysfsNameSustainedPowerLimitInterval,
|
||||
sysfsNameEnergyCounterNode,
|
||||
sysfsNameDefaultPowerLimit,
|
||||
sysfsNameCriticalPowerLimit,
|
||||
};
|
||||
|
||||
class SysmanKmdInterface {
|
||||
|
@ -74,34 +81,37 @@ class SysmanKmdInterface {
|
|||
virtual std::string getBasePath(int subDeviceId) const = 0;
|
||||
virtual std::string getSysfsFilePath(SysfsName sysfsName, int subDeviceId, bool baseDirectoryExists) = 0;
|
||||
virtual int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) = 0;
|
||||
virtual std::string getHwmonName(int subDeviceId, bool isSubdevice) const = 0;
|
||||
};
|
||||
|
||||
class SysmanKmdInterfaceI915 : public SysmanKmdInterface {
|
||||
public:
|
||||
SysmanKmdInterfaceI915() { initSysfsNameToFileMap(); }
|
||||
SysmanKmdInterfaceI915(const PRODUCT_FAMILY productFamily) { initSysfsNameToFileMap(productFamily); }
|
||||
~SysmanKmdInterfaceI915() override = default;
|
||||
|
||||
std::string getBasePath(int subDeviceId) const override;
|
||||
std::string getSysfsFilePath(SysfsName sysfsName, int subDeviceId, bool baseDirectoryExists) override;
|
||||
int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) override;
|
||||
std::string getHwmonName(int subDeviceId, bool isSubdevice) const override;
|
||||
|
||||
protected:
|
||||
std::map<SysfsName, valuePair> sysfsNameToFileMap;
|
||||
void initSysfsNameToFileMap();
|
||||
void initSysfsNameToFileMap(const PRODUCT_FAMILY productFamily);
|
||||
};
|
||||
|
||||
class SysmanKmdInterfaceXe : public SysmanKmdInterface {
|
||||
public:
|
||||
SysmanKmdInterfaceXe() { initSysfsNameToFileMap(); }
|
||||
SysmanKmdInterfaceXe(const PRODUCT_FAMILY productFamily) { initSysfsNameToFileMap(productFamily); }
|
||||
~SysmanKmdInterfaceXe() override = default;
|
||||
|
||||
std::string getBasePath(int subDeviceId) const override;
|
||||
std::string getSysfsFilePath(SysfsName sysfsName, int subDeviceId, bool baseDirectoryExists) override;
|
||||
int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) override;
|
||||
std::string getHwmonName(int subDeviceId, bool isSubdevice) const override;
|
||||
|
||||
protected:
|
||||
std::map<SysfsName, valuePair> sysfsNameToFileMap;
|
||||
void initSysfsNameToFileMap();
|
||||
void initSysfsNameToFileMap(const PRODUCT_FAMILY productFamily);
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
|
|
@ -51,7 +51,7 @@ class ZesEngineFixture : public SysmanDeviceFixture {
|
|||
pPmuInterface = std::make_unique<MockEnginePmuInterfaceImp>(pLinuxSysmanImp);
|
||||
pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
|
||||
pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(productFamily);
|
||||
std::swap(pLinuxSysmanImp->pSysmanKmdInterface, pSysmanKmdInterface);
|
||||
|
||||
pSysmanDeviceImp->pEngineHandleContext->handleList.clear();
|
||||
|
@ -303,7 +303,7 @@ class ZesEngineMultiFixture : public SysmanMultiDeviceFixture {
|
|||
pPmuInterface = std::make_unique<MockEnginePmuInterfaceImp>(pLinuxSysmanImp);
|
||||
pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
|
||||
pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>();
|
||||
pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(productFamily);
|
||||
std::swap(pLinuxSysmanImp->pSysmanKmdInterface, pSysmanKmdInterface);
|
||||
|
||||
pDrm->mockReadSysmanQueryEngineInfoMultiDevice = true;
|
||||
|
|
|
@ -93,7 +93,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
|||
};
|
||||
|
||||
TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFrequencyFilesForI915VersionAndBaseDirectoryExistsThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>();
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(productFamily);
|
||||
bool baseDirectoryExists = true;
|
||||
EXPECT_STREQ("gt/gt1/rps_min_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinFrequency, 1, baseDirectoryExists).c_str());
|
||||
EXPECT_STREQ("gt/gt1/rps_max_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxFrequency, 1, baseDirectoryExists).c_str());
|
||||
|
@ -114,7 +114,7 @@ TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFre
|
|||
}
|
||||
|
||||
TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFrequencyFilesForXeVersionAndBaseDirectoryExistsThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>();
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>(productFamily);
|
||||
bool baseDirectoryExists = true;
|
||||
EXPECT_STREQ("device/gt1/rps_min_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinFrequency, 1, baseDirectoryExists).c_str());
|
||||
EXPECT_STREQ("device/gt1/rps_max_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxFrequency, 1, baseDirectoryExists).c_str());
|
||||
|
|
|
@ -111,7 +111,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
|||
};
|
||||
|
||||
TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFrequencyFilesForI915VersionAndBaseDirectoryExistsThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>();
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(device->getNEODevice()->getHardwareInfo().platform.eProductFamily);
|
||||
bool baseDirectoryExists = true;
|
||||
EXPECT_STREQ("gt/gt1/rps_min_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinFrequency, 1, baseDirectoryExists).c_str());
|
||||
EXPECT_STREQ("gt/gt1/rps_max_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxFrequency, 1, baseDirectoryExists).c_str());
|
||||
|
@ -132,7 +132,7 @@ TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFre
|
|||
}
|
||||
|
||||
TEST_F(SysmanDeviceFrequencyFixture, GivenKmdInterfaceWhenGettingFilenamesForFrequencyFilesForXeVersionAndBaseDirectoryExistsThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>();
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>(device->getNEODevice()->getHardwareInfo().platform.eProductFamily);
|
||||
bool baseDirectoryExists = true;
|
||||
EXPECT_STREQ("device/gt1/rps_min_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinFrequency, 1, baseDirectoryExists).c_str());
|
||||
EXPECT_STREQ("device/gt1/rps_max_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxFrequency, 1, baseDirectoryExists).c_str());
|
||||
|
|
Loading…
Reference in New Issue