Add VBIOS version get function
Also, consolidate "get version" type function tests into 1 test.
[ROCm/amdsmi commit: 021f13a68f]
Este commit está contenido en:
@@ -1369,6 +1369,26 @@ rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) {
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len) {
|
||||
if (vbios == nullptr || len == 0) {
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
TRY
|
||||
GET_DEV_FROM_INDX
|
||||
std::string val_str;
|
||||
int ret = dev->readDevInfo(amd::smi::kDevVBiosVer, &val_str);
|
||||
|
||||
uint32_t ln = val_str.copy(vbios, len);
|
||||
|
||||
vbios[std::min(len - 1, ln)] = '\0';
|
||||
|
||||
return errno_to_rsmi_status(ret);
|
||||
|
||||
CATCH
|
||||
}
|
||||
|
||||
rsmi_status_t
|
||||
rsmi_version_get(rsmi_version *version) {
|
||||
TRY
|
||||
|
||||
@@ -68,6 +68,7 @@ static const char *kDevGPUPCIEClkFname = "pp_dpm_pcie";
|
||||
static const char *kDevPowerProfileModeFName = "pp_power_profile_mode";
|
||||
static const char *kDevPowerODVoltageFName = "pp_od_clk_voltage";
|
||||
static const char *kDevUsageFName = "gpu_busy_percent";
|
||||
static const char *kDevVBiosVerFName = "vbios_version";
|
||||
|
||||
static const char *kDevPerfLevelAutoStr = "auto";
|
||||
static const char *kDevPerfLevelLowStr = "low";
|
||||
@@ -89,6 +90,7 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
|
||||
{kDevPowerProfileMode, kDevPowerProfileModeFName},
|
||||
{kDevUsage, kDevUsageFName},
|
||||
{kDevPowerODVoltage, kDevPowerODVoltageFName},
|
||||
{kDevVBiosVer, kDevVBiosVerFName},
|
||||
};
|
||||
|
||||
static const std::map<rsmi_dev_perf_level, const char *> kDevPerfLvlMap = {
|
||||
@@ -121,30 +123,45 @@ Device::Device(std::string p, RocmSMI_env_vars const *e) : path_(p), env_(e) {
|
||||
Device:: ~Device() {
|
||||
}
|
||||
|
||||
int Device::readDevInfoStr(DevInfoTypes type, std::string *retStr) {
|
||||
auto tempPath = path_;
|
||||
|
||||
assert(retStr != nullptr);
|
||||
template <typename T>
|
||||
int Device::openSysfsFileStream(DevInfoTypes type, T *fs, bool write) {
|
||||
auto sysfs_path = path_;
|
||||
|
||||
if (env_->path_DRM_root_override && type == env_->enum_override) {
|
||||
tempPath = env_->path_DRM_root_override;
|
||||
sysfs_path = env_->path_DRM_root_override;
|
||||
}
|
||||
if (write) {
|
||||
sysfs_path += ".write";
|
||||
}
|
||||
|
||||
tempPath += "/device/";
|
||||
tempPath += kDevAttribNameMap.at(type);
|
||||
sysfs_path += "/device/";
|
||||
sysfs_path += kDevAttribNameMap.at(type);
|
||||
|
||||
DBG_FILE_ERROR(tempPath, (std::string *)nullptr);
|
||||
if (!isRegularFile(tempPath)) {
|
||||
DBG_FILE_ERROR(sysfs_path, (std::string *)nullptr);
|
||||
if (!isRegularFile(sysfs_path)) {
|
||||
return EISDIR;
|
||||
}
|
||||
|
||||
std::ifstream fs;
|
||||
fs.open(tempPath);
|
||||
fs->open(sysfs_path);
|
||||
|
||||
if (!fs.is_open()) {
|
||||
if (!fs->is_open()) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Device::readDevInfoStr(DevInfoTypes type, std::string *retStr) {
|
||||
std::ifstream fs;
|
||||
int ret = 0;
|
||||
|
||||
assert(retStr != nullptr);
|
||||
|
||||
ret = openSysfsFileStream(type, &fs);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
fs >> *retStr;
|
||||
fs.close();
|
||||
|
||||
@@ -153,28 +170,12 @@ int Device::readDevInfoStr(DevInfoTypes type, std::string *retStr) {
|
||||
|
||||
int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr) {
|
||||
auto tempPath = path_;
|
||||
|
||||
if (env_->path_DRM_root_override && type == env_->enum_override) {
|
||||
tempPath = env_->path_DRM_root_override;
|
||||
}
|
||||
|
||||
tempPath += "/device/";
|
||||
tempPath += kDevAttribNameMap.at(type);
|
||||
|
||||
if (env_->path_DRM_root_override && type == env_->enum_override) {
|
||||
tempPath += ".write";
|
||||
}
|
||||
|
||||
std::ofstream fs;
|
||||
fs.open(tempPath);
|
||||
int ret;
|
||||
|
||||
DBG_FILE_ERROR(tempPath, &valStr);
|
||||
if (!isRegularFile(tempPath)) {
|
||||
return EISDIR;
|
||||
}
|
||||
|
||||
if (!fs.is_open()) {
|
||||
return errno;
|
||||
ret = openSysfsFileStream(type, &fs, true);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -245,21 +246,14 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
|
||||
std::vector<std::string> *retVec) {
|
||||
auto tempPath = path_;
|
||||
std::string line;
|
||||
int ret;
|
||||
std::ifstream fs;
|
||||
|
||||
assert(retVec != nullptr);
|
||||
|
||||
if (env_->path_DRM_root_override && type == env_->enum_override) {
|
||||
tempPath = env_->path_DRM_root_override;
|
||||
}
|
||||
tempPath += "/device/";
|
||||
tempPath += kDevAttribNameMap.at(type);
|
||||
|
||||
std::ifstream fs(tempPath);
|
||||
std::stringstream buffer;
|
||||
|
||||
DBG_FILE_ERROR(tempPath, (std::string *)nullptr);
|
||||
if (!isRegularFile(tempPath)) {
|
||||
return EISDIR;
|
||||
ret = openSysfsFileStream(type, &fs);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
while (std::getline(fs, line)) {
|
||||
@@ -329,6 +323,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) {
|
||||
case kDevUsage:
|
||||
case kDevOverDriveLevel:
|
||||
case kDevDevID:
|
||||
case kDevVBiosVer:
|
||||
return readDevInfoStr(type, val);
|
||||
break;
|
||||
|
||||
|
||||
Referencia en una nueva incidencia
Block a user