Add support for reading GPU's unique ID

Add support and testing for reading the Unique ID associated with a
specific GPU. This ID will persist across reboots, even if the GPU is
moved to a different machine. Note that this is per-GPU, not per-card,
as some cards have multiple GPUs, and each GPU will get a unique
identifier

Change-Id: Idce50c6febc2ceb1a4c1200d2489ec8b9d8fe174
This commit is contained in:
Kent Russell
2019-06-20 06:55:56 -04:00
parent dbdb1a9248
commit 35d2807196
6 changed files with 48 additions and 0 deletions
Binary file not shown.
+16
View File
@@ -726,6 +726,22 @@ rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len);
*/
rsmi_status_t rsmi_dev_subsystem_vendor_id_get(uint32_t dv_ind, uint16_t *id);
/**
* @brief Get Unique ID
*
* @details Given a device index @p dv_ind and a pointer to a uint64_t @p
* id, this function will write the unique ID of the GPU pointed to @p
* id.
*
* @param[in] dv_ind a device index
*
* @param[inout] id a pointer to uint64_t to which the unique ID of the GPU
* is written
*
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call.
*/
rsmi_status_t rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *id);
/** @} */ // end of IDQuer
/*****************************************************************************/
+1
View File
@@ -91,6 +91,7 @@ enum DevInfoTypes {
kDevMemUsedVisVRAM,
kDevMemUsedVRAM,
kDevPCIEReplayCount,
kDevUniqueId,
};
class Device {
+11
View File
@@ -2107,3 +2107,14 @@ rsmi_dev_pci_replay_counter_get(uint32_t dv_ind, uint64_t *counter) {
CATCH
}
rsmi_status_t
rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *unique_id) {
TRY
DEVICE_MUTEX
rsmi_status_t ret;
ret = get_dev_value_int(amd::smi::kDevUniqueId, dv_ind, unique_id);
return ret;
CATCH
}
+7
View File
@@ -97,6 +97,7 @@ static const char *kDevMemUsedGTTFName = "mem_info_gtt_used";
static const char *kDevMemUsedVisVRAMFName = "mem_info_vis_vram_used";
static const char *kDevMemUsedVRAMFName = "mem_info_vram_used";
static const char *kDevPCIEReplayCountFName = "pcie_replay_count";
static const char *kDevUniqueIdFName = "unique_id";
// Strings that are found within sysfs files
static const char *kDevPerfLevelAutoStr = "auto";
@@ -138,6 +139,7 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
{kDevMemUsedVisVRAM, kDevMemUsedVisVRAMFName},
{kDevMemUsedVRAM, kDevMemUsedVRAMFName},
{kDevPCIEReplayCount, kDevPCIEReplayCountFName},
{kDevUniqueId, kDevUniqueIdFName},
};
static const std::map<rsmi_dev_perf_level, const char *> kDevPerfLvlMap = {
@@ -374,6 +376,11 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) {
RET_IF_NONZERO(ret);
*val = std::stoul(tempStr, 0);
break;
case kDevUniqueId:
ret = readDevInfoStr(type, &tempStr);
RET_IF_NONZERO(ret);
*val = std::stoul(tempStr, 0, 16);
break;
default:
return -1;
@@ -120,6 +120,19 @@ void TestSysInfoRead::Run(void) {
std::cout << " (" << std::dec << val_ui64 << ")" << std::endl;
}
err = rsmi_dev_unique_id_get(i, &val_ui64);
if (err == RSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**rsmi_dev_unique_id() is not supported"
" on this machine" << std::endl;
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**GPU Unique ID : " << std::hex << val_ui64 <<
std::endl;
}
}
err = rsmi_version_get(&ver);
CHK_ERR_ASRT(err)