Correct subsystem name by matching device id.

The rsmi_dev_subsystem_name_get() only matches subvendor id and
subdevice id for a vendor. The change will also match device id.

Change-Id: Ife3aedaf6fc7390ed7fa62edbde40c2340689b23


[ROCm/amdsmi commit: 0c82a9d577]
Этот коммит содержится в:
Bill(Shuzhou) Liu
2023-03-24 15:36:30 -05:00
родитель 7e2d0970e5
Коммит b875784232
+10 -2
Просмотреть файл
@@ -1811,6 +1811,8 @@ static rsmi_status_t get_dev_name_from_id(uint32_t dv_ind, char *name,
uint16_t subsys_vend_id; uint16_t subsys_vend_id;
uint16_t subsys_id; uint16_t subsys_id;
bool found_device_vendor = false; bool found_device_vendor = false;
// to match subsystem, it must match the device id at previous line
bool found_device_id_for_subsys = false;
std::string val_str; std::string val_str;
assert(name != nullptr); assert(name != nullptr);
@@ -1857,8 +1859,8 @@ static rsmi_status_t get_dev_name_from_id(uint32_t dv_ind, char *name,
if (ln[0] == '\t') { if (ln[0] == '\t') {
if (found_device_vendor) { if (found_device_vendor) {
if (ln[1] == '\t') { if (ln[1] == '\t') {
// This is a subsystem line // The subsystem line, ignore a line if the device id not match
if (typ == NAME_STR_SUBSYS) { if (typ == NAME_STR_SUBSYS && found_device_id_for_subsys) {
val_str = get_id_name_str_from_line(subsys_vend_id, ln, &ln_str); val_str = get_id_name_str_from_line(subsys_vend_id, ln, &ln_str);
if (val_str.size() > 0) { if (val_str.size() > 0) {
@@ -1880,6 +1882,12 @@ static rsmi_status_t get_dev_name_from_id(uint32_t dv_ind, char *name,
if (val_str.size() > 0) { if (val_str.size() > 0) {
break; break;
} }
} else if (typ == NAME_STR_SUBSYS) {
// match the device id line
val_str = get_id_name_str_from_line(device_id, ln, &ln_str);
if (val_str.size() > 0) {
found_device_id_for_subsys = true;
}
} }
} }
} else { // ln[0] != '\t'; Vendor line } else { // ln[0] != '\t'; Vendor line