Display GPU brand name

Add support and testing for reading the brand name associated with
a specific GPU (such as mi25, mi50, mi60, etc). The brand name is
associated with the SKU of the GPU, and some brand names can be
mapped from multiple different SKUs.

Change-Id: I36eb95ca8e72efdd294ccd684841195925dfe820
Signed-off-by: Ori Messinger <Ori.Messinger@amd.com>
This commit is contained in:
Ori Messinger
2019-08-19 11:26:27 -04:00
parent aa2db48237
commit 7f2d970a80
3 changed files with 71 additions and 0 deletions
+24
View File
@@ -784,6 +784,30 @@ rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id);
*/
rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len);
/**
* @brief Get the brand string of a gpu device.
*
* @details Given a device index @p dv_ind, a pointer to a caller provided
* char buffer @p brand, and a length of this buffer @p len, this function
* will write the brand of the device (up to @p len characters) to the buffer
* @p brand.
*
* If the sku associated with the device is not found as one of the values
* contained within rsmi_dev_brand_get, then this function will return the
* device marketing name as a string instead of the brand name.
*
* @param[in] dv_ind a device index
*
* @param[inout] brand a pointer to a caller provided char buffer to which the
* brand will be written
*
* @param[in] len the length of the caller provided buffer @p brand.
*
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call.
*
*/
rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, size_t len);
/**
* @brief Get the name string for a give vendor ID
*
+39
View File
@@ -45,6 +45,7 @@
#include <errno.h>
#include <sys/utsname.h>
#include <pthread.h>
#include <string.h>
#include <sstream>
#include <algorithm>
@@ -1421,6 +1422,44 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) {
CATCH
}
rsmi_status_t
rsmi_dev_brand_get(uint32_t dv_ind, char *brand, size_t len) {
GET_DEV_FROM_INDX
// Return 'invalid args' if arguments are invalid
if (brand == nullptr || len == 0){
return RSMI_STATUS_INVALID_ARGS;
}
std::map<std::string, std::string> brand_names =
{
{"D05121", "mi25"},
{"D05131", "mi25"},
{"D05133", "mi25"},
{"D05151", "mi25"},
{"D16304", "mi50"},
{"D16302", "mi60"}
};
std::map<std::string, std::string>::iterator it;
std::string vbios_value;
std::string sku_value;
// Retrieve vbios and store in vbios_value string
int ret = dev->readDevInfo(amd::smi::kDevVBiosVer, &vbios_value);
if (ret != 0) {
return errno_to_rsmi_status(ret);
}
if (vbios_value.length() == 16) {
sku_value = vbios_value.substr(4,6);
// Find the brand name using sku_value
it = brand_names.find(sku_value);
if (it != brand_names.end()) {
strcpy(brand, it->second.c_str());
return RSMI_STATUS_SUCCESS;
}
}
// If there is no SKU match, return marketing name instead
rsmi_dev_name_get(dv_ind, brand, len);
return RSMI_STATUS_SUCCESS;
}
rsmi_status_t
rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len) {
rsmi_status_t ret;
@@ -119,6 +119,14 @@ void TestIdInfoRead::Run(void) {
std::cout << "\t**Device Marketing name: " << buffer << std::endl;
}
}
err = rsmi_dev_brand_get(i, buffer, kBufferLen);
if(err != RSMI_STATUS_SUCCESS) {
CHK_ERR_ASRT(err)
} else {
IF_VERB(STANDARD) {
std::cout << "\t**Device Brand name: " << buffer << std::endl;
}
}
err = rsmi_dev_vendor_id_get(i, &id);
if (err != RSMI_STATUS_SUCCESS) {
CHK_ERR_ASRT(err)