Skip to content

Commit 723fac6

Browse files
Shiwu Zhangalexdeucher
authored andcommitted
drm/amdgpu: support the port num info based on the capability flag
XGMI TA will set the capability flag to indicate whether the port_num info is supported or not. KGD checks the flag and accordingly picks up the right buffer format and send the right command to TA to retrieve the info. v2: simplify the code by reusing the same statement (lijo) Signed-off-by: Shiwu Zhang <[email protected]> Acked-by: Lijo Lazar <[email protected]> Reviewed-by: Le Ma <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent e8a5ded commit 723fac6

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

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

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool lo
12671267
xgmi_cmd->cmd_id = TA_COMMAND_XGMI__INITIALIZE;
12681268

12691269
ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
1270+
/* note down the capbility flag for XGMI TA */
1271+
psp->xgmi_context.xgmi_ta_caps = xgmi_cmd->caps_flag;
12701272

12711273
return ret;
12721274
}
@@ -1425,35 +1427,52 @@ int psp_xgmi_get_topology_info(struct psp_context *psp,
14251427
/* Invoke xgmi ta again to get the link information */
14261428
if (psp_xgmi_peer_link_info_supported(psp)) {
14271429
struct ta_xgmi_cmd_get_peer_link_info *link_info_output;
1430+
struct ta_xgmi_cmd_get_extend_peer_link_info *link_extend_info_output;
14281431
bool requires_reflection =
14291432
(psp->xgmi_context.supports_extended_data &&
14301433
get_extended_data) ||
14311434
amdgpu_ip_version(psp->adev, MP0_HWIP, 0) ==
14321435
IP_VERSION(13, 0, 6);
1436+
bool ta_port_num_support = psp->xgmi_context.xgmi_ta_caps &
1437+
EXTEND_PEER_LINK_INFO_CMD_FLAG;
14331438

1434-
link_info_output = &xgmi_cmd->xgmi_out_message.get_link_info;
14351439
/* popluate the shared output buffer rather than the cmd input buffer
14361440
* with node_ids as the input for GET_PEER_LINKS command execution.
1437-
* This is required for GET_PEER_LINKS only per xgmi ta implementation
1441+
* This is required for GET_PEER_LINKS per xgmi ta implementation.
1442+
* The same requirement for GET_EXTEND_PEER_LINKS command.
14381443
*/
1439-
for (i = 0; i < topology->num_nodes; i++) {
1440-
link_info_output->nodes[i].node_id = topology->nodes[i].node_id;
1441-
}
1442-
link_info_output->num_nodes = topology->num_nodes;
1444+
if (ta_port_num_support) {
1445+
link_extend_info_output = &xgmi_cmd->xgmi_out_message.get_extend_link_info;
1446+
1447+
for (i = 0; i < topology->num_nodes; i++)
1448+
link_extend_info_output->nodes[i].node_id = topology->nodes[i].node_id;
1449+
1450+
link_extend_info_output->num_nodes = topology->num_nodes;
1451+
xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_EXTEND_PEER_LINKS;
1452+
} else {
1453+
link_info_output = &xgmi_cmd->xgmi_out_message.get_link_info;
14431454

1444-
xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_PEER_LINKS;
1445-
ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_PEER_LINKS);
1455+
for (i = 0; i < topology->num_nodes; i++)
1456+
link_info_output->nodes[i].node_id = topology->nodes[i].node_id;
14461457

1458+
link_info_output->num_nodes = topology->num_nodes;
1459+
xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_PEER_LINKS;
1460+
}
1461+
1462+
ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
14471463
if (ret)
14481464
return ret;
14491465

14501466
for (i = 0; i < topology->num_nodes; i++) {
1467+
uint8_t node_num_links = ta_port_num_support ?
1468+
link_extend_info_output->nodes[i].num_links : link_info_output->nodes[i].num_links;
14511469
/* accumulate num_links on extended data */
1452-
topology->nodes[i].num_links = get_extended_data ?
1453-
topology->nodes[i].num_links +
1454-
link_info_output->nodes[i].num_links :
1455-
((requires_reflection && topology->nodes[i].num_links) ? topology->nodes[i].num_links :
1456-
link_info_output->nodes[i].num_links);
1470+
if (get_extended_data) {
1471+
topology->nodes[i].num_links = topology->nodes[i].num_links + node_num_links;
1472+
} else {
1473+
topology->nodes[i].num_links = (requires_reflection && topology->nodes[i].num_links) ?
1474+
topology->nodes[i].num_links : node_num_links;
1475+
}
14571476

14581477
/* reflect the topology information for bi-directionality */
14591478
if (requires_reflection && topology->nodes[i].num_hops)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct psp_xgmi_context {
189189
struct ta_context context;
190190
struct psp_xgmi_topology_info top_info;
191191
bool supports_extended_data;
192+
uint8_t xgmi_ta_caps;
192193
};
193194

194195
struct psp_ras_context {

0 commit comments

Comments
 (0)