Skip to content

Commit f1a2cd4

Browse files
Will Aitkenalexdeucher
authored andcommitted
drm/amdgpu: Refactor sriov xgmi topology filling to common code
amdgpu_xgmi_fill_topology_info and psp_xgmi_reflect_topology_info perform the same logic of copying topology info of one node to every other node in the hive. Instead of having two functions that purport to do the same thing, this refactoring moves the logic of the fill function to the reflect function and adds reflecting port number info as well for complete functionality. Signed-off-by: Will Aitken <wiaitken@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent b84bc92 commit f1a2cd4

2 files changed

Lines changed: 14 additions & 32 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,7 @@ static void psp_xgmi_reflect_topology_info(struct psp_context *psp,
15391539
uint64_t src_node_id = psp->adev->gmc.xgmi.node_id;
15401540
uint64_t dst_node_id = node_info.node_id;
15411541
uint8_t dst_num_hops = node_info.num_hops;
1542+
uint8_t dst_is_sharing_enabled = node_info.is_sharing_enabled;
15421543
uint8_t dst_num_links = node_info.num_links;
15431544

15441545
hive = amdgpu_get_xgmi_hive(psp->adev);
@@ -1558,13 +1559,20 @@ static void psp_xgmi_reflect_topology_info(struct psp_context *psp,
15581559
continue;
15591560

15601561
mirror_top_info->nodes[j].num_hops = dst_num_hops;
1561-
/*
1562-
* prevent 0 num_links value re-reflection since reflection
1562+
mirror_top_info->nodes[j].is_sharing_enabled = dst_is_sharing_enabled;
1563+
/* prevent 0 num_links value re-reflection since reflection
15631564
* criteria is based on num_hops (direct or indirect).
1564-
*
15651565
*/
1566-
if (dst_num_links)
1566+
if (dst_num_links) {
15671567
mirror_top_info->nodes[j].num_links = dst_num_links;
1568+
/* swap src and dst due to frame of reference */
1569+
for (int k = 0; k < dst_num_links; k++) {
1570+
mirror_top_info->nodes[j].port_num[k].src_xgmi_port_num =
1571+
node_info.port_num[k].dst_xgmi_port_num;
1572+
mirror_top_info->nodes[j].port_num[k].dst_xgmi_port_num =
1573+
node_info.port_num[k].src_xgmi_port_num;
1574+
}
1575+
}
15681576

15691577
break;
15701578
}
@@ -1639,7 +1647,8 @@ int psp_xgmi_get_topology_info(struct psp_context *psp,
16391647
amdgpu_ip_version(psp->adev, MP0_HWIP, 0) ==
16401648
IP_VERSION(13, 0, 6) ||
16411649
amdgpu_ip_version(psp->adev, MP0_HWIP, 0) ==
1642-
IP_VERSION(13, 0, 14);
1650+
IP_VERSION(13, 0, 14) ||
1651+
amdgpu_sriov_vf(psp->adev);
16431652
bool ta_port_num_support = amdgpu_sriov_vf(psp->adev) ? 0 :
16441653
psp->xgmi_context.xgmi_ta_caps & EXTEND_PEER_LINK_INFO_CMD_FLAG;
16451654

drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -968,28 +968,6 @@ static int amdgpu_xgmi_initialize_hive_get_data_partition(struct amdgpu_hive_inf
968968
return 0;
969969
}
970970

971-
static void amdgpu_xgmi_fill_topology_info(struct amdgpu_device *adev,
972-
struct amdgpu_device *peer_adev)
973-
{
974-
struct psp_xgmi_topology_info *top_info = &adev->psp.xgmi_context.top_info;
975-
struct psp_xgmi_topology_info *peer_info = &peer_adev->psp.xgmi_context.top_info;
976-
977-
for (int i = 0; i < peer_info->num_nodes; i++) {
978-
if (peer_info->nodes[i].node_id == adev->gmc.xgmi.node_id) {
979-
for (int j = 0; j < top_info->num_nodes; j++) {
980-
if (top_info->nodes[j].node_id == peer_adev->gmc.xgmi.node_id) {
981-
peer_info->nodes[i].num_hops = top_info->nodes[j].num_hops;
982-
peer_info->nodes[i].is_sharing_enabled =
983-
top_info->nodes[j].is_sharing_enabled;
984-
peer_info->nodes[i].num_links =
985-
top_info->nodes[j].num_links;
986-
return;
987-
}
988-
}
989-
}
990-
}
991-
}
992-
993971
int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
994972
{
995973
struct psp_xgmi_topology_info *top_info;
@@ -1075,11 +1053,6 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
10751053
/* To do: continue with some node failed or disable the whole hive*/
10761054
goto exit_unlock;
10771055
}
1078-
1079-
/* fill the topology info for peers instead of getting from PSP */
1080-
list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
1081-
amdgpu_xgmi_fill_topology_info(adev, tmp_adev);
1082-
}
10831056
} else {
10841057
/* get latest topology info for each device from psp */
10851058
list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {

0 commit comments

Comments
 (0)