Add rsmi_dev_firmware_version_get()

Change-Id: Iba3e5f3eaa0eb031fc013fc168bded22bc249b5c


[ROCm/amdsmi commit: 31e02fdc61]
This commit is contained in:
Chris Freehill
2019-07-09 20:48:28 -05:00
parent 64f22d2749
commit 270c881cf8
7 changed files with 380 additions and 0 deletions
@@ -413,6 +413,39 @@ typedef enum {
typedef rsmi_freq_ind_t rsmi_freq_ind;
/// \endcond
/**
* @brief The values of this enum are used to identify the various firmware
* blocks.
*/
typedef enum {
RSMI_FW_BLOCK_FIRST = 0,
RSMI_FW_BLOCK_ASD = RSMI_FW_BLOCK_FIRST,
RSMI_FW_BLOCK_CE,
RSMI_FW_BLOCK_DMCU,
RSMI_FW_BLOCK_MC,
RSMI_FW_BLOCK_ME,
RSMI_FW_BLOCK_MEC,
RSMI_FW_BLOCK_MEC2,
RSMI_FW_BLOCK_PFP,
RSMI_FW_BLOCK_RLC,
RSMI_FW_BLOCK_RLC_SRLC,
RSMI_FW_BLOCK_RLC_SRLG,
RSMI_FW_BLOCK_RLC_SRLS,
RSMI_FW_BLOCK_SDMA,
RSMI_FW_BLOCK_SDMA2,
RSMI_FW_BLOCK_SMC,
RSMI_FW_BLOCK_SOS,
RSMI_FW_BLOCK_TA_RAS,
RSMI_FW_BLOCK_TA_XGMI,
RSMI_FW_BLOCK_UVD,
RSMI_FW_BLOCK_VCE,
RSMI_FW_BLOCK_VCN,
RSMI_FW_BLOCK_LAST = RSMI_FW_BLOCK_VCN
} rsmi_fw_block_t;
/**
* @brief XGMI Status
*/
@@ -1642,6 +1675,27 @@ rsmi_version_str_get(rsmi_sw_component_t component, char *ver_str,
rsmi_status_t
rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len);
/**
* @brief Get the firmware versions for a device
*
* @details Given a device ID @p dv_ind, and a pointer to a uint64_t,
* @p fw_version, this function will write the FW Versions as a string (up to @p len
* characters) for device @p dv_ind to @p vbios. The caller must ensure that
* it is safe to write at least @p len characters to @p vbios.
*
* @param[in] dv_ind a device index
*
* @param[in] block The firmware block for which the version is being requested
*
* @param[inout] fw_version The version for the firmware block
*
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call.
*
*/
rsmi_status_t
rsmi_dev_firmware_version_get(uint32_t dv_ind, rsmi_fw_block_t block,
uint64_t *fw_version);
/** @} */ // end of VersQuer
/*****************************************************************************/
@@ -97,6 +97,27 @@ enum DevInfoTypes {
kDevDFCountersAvailable,
kDevMemBusyPercent,
kDevXGMIError,
kDevFwVersionAsd,
kDevFwVersionCe,
kDevFwVersionDmcu,
kDevFwVersionMc,
kDevFwVersionMe,
kDevFwVersionMec,
kDevFwVersionMec2,
kDevFwVersionPfp,
kDevFwVersionRlc,
kDevFwVersionRlcSrlc,
kDevFwVersionRlcSrlg,
kDevFwVersionRlcSrls,
kDevFwVersionSdma,
kDevFwVersionSdma2,
kDevFwVersionSmc,
kDevFwVersionSos,
kDevFwVersionTaRas,
kDevFwVersionTaXgmi,
kDevFwVersionUvd,
kDevFwVersionVce,
kDevFwVersionVcn,
};
class Device {
+89
View File
@@ -1080,6 +1080,95 @@ rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, rsmi_clk_type_t clk_type,
CATCH
}
rsmi_status_t
rsmi_dev_firmware_version_get(uint32_t dv_ind, rsmi_fw_block_t block,
uint64_t *fw_version) {
rsmi_status_t ret;
if (fw_version == nullptr) {
return RSMI_STATUS_INVALID_ARGS;
}
TRY
GET_DEV_FROM_INDX
std::string val_str;
amd::smi::DevInfoTypes dev_type;
switch (block) {
case RSMI_FW_BLOCK_ASD:
dev_type = amd::smi::kDevFwVersionAsd;
break;
case RSMI_FW_BLOCK_CE:
dev_type = amd::smi::kDevFwVersionCe;
break;
case RSMI_FW_BLOCK_DMCU:
dev_type = amd::smi::kDevFwVersionDmcu;
break;
case RSMI_FW_BLOCK_MC:
dev_type = amd::smi::kDevFwVersionMc;
break;
case RSMI_FW_BLOCK_ME:
dev_type = amd::smi::kDevFwVersionMe;
break;
case RSMI_FW_BLOCK_MEC:
dev_type = amd::smi::kDevFwVersionMec;
break;
case RSMI_FW_BLOCK_MEC2:
dev_type = amd::smi::kDevFwVersionMec2;
break;
case RSMI_FW_BLOCK_PFP:
dev_type = amd::smi::kDevFwVersionPfp;
break;
case RSMI_FW_BLOCK_RLC:
dev_type = amd::smi::kDevFwVersionRlc;
break;
case RSMI_FW_BLOCK_RLC_SRLC:
dev_type = amd::smi::kDevFwVersionRlcSrlc;
break;
case RSMI_FW_BLOCK_RLC_SRLG:
dev_type = amd::smi::kDevFwVersionRlcSrlg;
break;
case RSMI_FW_BLOCK_RLC_SRLS:
dev_type = amd::smi::kDevFwVersionRlcSrls;
break;
case RSMI_FW_BLOCK_SDMA:
dev_type = amd::smi::kDevFwVersionSdma;
break;
case RSMI_FW_BLOCK_SDMA2:
dev_type = amd::smi::kDevFwVersionSdma2;
break;
case RSMI_FW_BLOCK_SMC:
dev_type = amd::smi::kDevFwVersionSmc;
break;
case RSMI_FW_BLOCK_SOS:
dev_type = amd::smi::kDevFwVersionSos;
break;
case RSMI_FW_BLOCK_TA_RAS:
dev_type = amd::smi::kDevFwVersionTaRas;
break;
case RSMI_FW_BLOCK_TA_XGMI:
dev_type = amd::smi::kDevFwVersionTaXgmi;
break;
case RSMI_FW_BLOCK_UVD:
dev_type = amd::smi::kDevFwVersionUvd;
break;
case RSMI_FW_BLOCK_VCE:
dev_type = amd::smi::kDevFwVersionVce;
break;
case RSMI_FW_BLOCK_VCN:
dev_type = amd::smi::kDevFwVersionVcn;
break;
}
ret = get_dev_value_int(dev_type, dv_ind, fw_version);
if (ret != 0) {
return errno_to_rsmi_status(ret);
}
return RSMI_STATUS_SUCCESS;
CATCH
}
static std::string bitfield_to_freq_string(uint64_t bitf,
uint32_t num_supported) {
std::string bf_str("");
+67
View File
@@ -114,6 +114,30 @@ static const char *kDevPerfLevelMinSClkStr = "profile_min_sclk";
static const char *kDevPerfLevelPeakStr = "profile_peak";
static const char *kDevPerfLevelUnknownStr = "unknown";
// Firmware version files
static const char *kDevFwVersionAsdFName = "fw_version/asd_fw_version";
static const char *kDevFwVersionCeFName = "fw_version/ce_fw_version";
static const char *kDevFwVersionDmcuFName = "fw_version/dmcu_fw_version";
static const char *kDevFwVersionMcFName = "fw_version/mc_fw_version";
static const char *kDevFwVersionMeFName = "fw_version/me_fw_version";
static const char *kDevFwVersionMecFName = "fw_version/mec_fw_version";
static const char *kDevFwVersionMec2FName = "fw_version/mec2_fw_version";
static const char *kDevFwVersionPfpFName = "fw_version/pfp_fw_version";
static const char *kDevFwVersionRlcFName = "fw_version/rlc_fw_version";
static const char *kDevFwVersionRlcSrlcFName = "fw_version/rlc_srlc_fw_version";
static const char *kDevFwVersionRlcSrlgFName = "fw_version/rlc_srlg_fw_version";
static const char *kDevFwVersionRlcSrlsFName = "fw_version/rlc_srls_fw_version";
static const char *kDevFwVersionSdmaFName = "fw_version/sdma_fw_version";
static const char *kDevFwVersionSdma2FName = "fw_version/sdma2_fw_version";
static const char *kDevFwVersionSmcFName = "fw_version/smc_fw_version";
static const char *kDevFwVersionSosFName = "fw_version/sos_fw_version";
static const char *kDevFwVersionTaRasFName = "fw_version/ta_ras_fw_version";
static const char *kDevFwVersionTaXgmiFName = "fw_version/ta_xgmi_fw_version";
static const char *kDevFwVersionUvdFName = "fw_version/uvd_fw_version";
static const char *kDevFwVersionVceFName = "fw_version/vce_fw_version";
static const char *kDevFwVersionVcnFName = "fw_version/vcn_fw_version";
static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
{kDevPerfLevel, kDevPerfLevelFName},
{kDevOverDriveLevel, kDevOverDriveLevelFName},
@@ -147,6 +171,27 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
{kDevUniqueId, kDevUniqueIdFName},
{kDevDFCountersAvailable, kDevDFCountersAvailableFName},
{kDevXGMIError, kDevXGMIErrorFName},
{kDevFwVersionAsd, kDevFwVersionAsdFName},
{kDevFwVersionCe, kDevFwVersionCeFName},
{kDevFwVersionDmcu, kDevFwVersionDmcuFName},
{kDevFwVersionMc, kDevFwVersionMcFName},
{kDevFwVersionMe, kDevFwVersionMeFName},
{kDevFwVersionMec, kDevFwVersionMecFName},
{kDevFwVersionMec2, kDevFwVersionMec2FName},
{kDevFwVersionPfp, kDevFwVersionPfpFName},
{kDevFwVersionRlc, kDevFwVersionRlcFName},
{kDevFwVersionRlcSrlc, kDevFwVersionRlcSrlcFName},
{kDevFwVersionRlcSrlg, kDevFwVersionRlcSrlgFName},
{kDevFwVersionRlcSrls, kDevFwVersionRlcSrlsFName},
{kDevFwVersionSdma, kDevFwVersionSdmaFName},
{kDevFwVersionSdma2, kDevFwVersionSdma2FName},
{kDevFwVersionSmc, kDevFwVersionSmcFName},
{kDevFwVersionSos, kDevFwVersionSosFName},
{kDevFwVersionTaRas, kDevFwVersionTaRasFName},
{kDevFwVersionTaXgmi, kDevFwVersionTaXgmiFName},
{kDevFwVersionUvd, kDevFwVersionUvdFName},
{kDevFwVersionVce, kDevFwVersionVceFName},
{kDevFwVersionVcn, kDevFwVersionVcnFName},
};
static const std::map<rsmi_dev_perf_level, const char *> kDevPerfLvlMap = {
@@ -387,7 +432,29 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) {
RET_IF_NONZERO(ret);
*val = std::stoul(tempStr, 0);
break;
case kDevUniqueId:
case kDevFwVersionAsd:
case kDevFwVersionCe:
case kDevFwVersionDmcu:
case kDevFwVersionMc:
case kDevFwVersionMe:
case kDevFwVersionMec:
case kDevFwVersionMec2:
case kDevFwVersionPfp:
case kDevFwVersionRlc:
case kDevFwVersionRlcSrlc:
case kDevFwVersionRlcSrlg:
case kDevFwVersionRlcSrls:
case kDevFwVersionSdma:
case kDevFwVersionSdma2:
case kDevFwVersionSmc:
case kDevFwVersionSos:
case kDevFwVersionTaRas:
case kDevFwVersionTaXgmi:
case kDevFwVersionUvd:
case kDevFwVersionVce:
case kDevFwVersionVcn:
ret = readDevInfoStr(type, &tempStr);
RET_IF_NONZERO(ret);
*val = std::stoul(tempStr, 0, 16);
@@ -53,6 +53,7 @@
#include "rocm_smi/rocm_smi.h"
#include "rocm_smi_test/functional/sys_info_read.h"
#include "rocm_smi_test/test_common.h"
#include "rocm_smi_test/test_utils.h"
TestSysInfoRead::TestSysInfoRead() : TestBase() {
set_title("RSMI System Info Read Test");
@@ -142,5 +143,20 @@ void TestSysInfoRead::Run(void) {
std::cout << "\t**RocM SMI Library version: " << ver.major << "." <<
ver.minor << "." << ver.patch << " (" << ver.build << ")" << std::endl;
}
std::cout << std::setbase(10);
for (int x = RSMI_FW_BLOCK_FIRST; x <= RSMI_FW_BLOCK_LAST; ++x) {
rsmi_fw_block_t block = static_cast<rsmi_fw_block_t>(x);
err = rsmi_dev_firmware_version_get(i, block, &val_ui64);
if (err) {
std::cout << "\t**No FW block " << NameFromFWEnum(block) <<
" available on this system" << std::endl;
continue;
}
IF_VERB(STANDARD) {
std::cout << "\t**FW VERSION for " << NameFromFWEnum(block) <<
": " << val_ui64 << std::endl;
}
}
}
}
+79
View File
@@ -0,0 +1,79 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2019, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS WITH THE SOFTWARE.
*
*/
#include <map>
#include "rocm_smi/rocm_smi.h"
#include "rocm_smi_test/test_utils.h"
static const std::map<rsmi_fw_block_t, const char *> kDevFWNameMap = {
{RSMI_FW_BLOCK_ASD, "asd"},
{RSMI_FW_BLOCK_CE, "ce"},
{RSMI_FW_BLOCK_DMCU, "dmcu"},
{RSMI_FW_BLOCK_MC, "mc"},
{RSMI_FW_BLOCK_ME, "me"},
{RSMI_FW_BLOCK_MEC, "mec"},
{RSMI_FW_BLOCK_MEC2, "mec2"},
{RSMI_FW_BLOCK_PFP, "pfp"},
{RSMI_FW_BLOCK_RLC, "rlc"},
{RSMI_FW_BLOCK_RLC_SRLC, "rlc_srlc"},
{RSMI_FW_BLOCK_RLC_SRLG, "rlc_srlg"},
{RSMI_FW_BLOCK_RLC_SRLS, "rlc_srls"},
{RSMI_FW_BLOCK_SDMA, "sdma"},
{RSMI_FW_BLOCK_SDMA2, "sdma2"},
{RSMI_FW_BLOCK_SMC, "smc"},
{RSMI_FW_BLOCK_SOS, "sos"},
{RSMI_FW_BLOCK_TA_RAS, "ta_ras"},
{RSMI_FW_BLOCK_TA_XGMI, "ta_xgmi"},
{RSMI_FW_BLOCK_UVD, "uvd"},
{RSMI_FW_BLOCK_VCE, "vce"},
{RSMI_FW_BLOCK_VCN, "vcn"},
};
const char *
NameFromFWEnum(rsmi_fw_block_t blk) {
return kDevFWNameMap.at(blk);
}
+54
View File
@@ -0,0 +1,54 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2019, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS WITH THE SOFTWARE.
*
*/
#ifndef TESTS_ROCM_SMI_TEST_TEST_UTILS_H_
#define TESTS_ROCM_SMI_TEST_TEST_UTILS_H_
#include "rocm_smi/rocm_smi.h"
const char *
NameFromFWEnum(rsmi_fw_block_t blk);
#endif // TESTS_ROCM_SMI_TEST_TEST_UTILS_H_