drm/amdgpu: add psp command to get num xgmi links between direct peers
authorJonathan Kim <jonathan.kim@amd.com>
Wed, 12 May 2021 16:26:20 +0000 (12:26 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 23 Jul 2021 14:07:59 +0000 (10:07 -0400)
The TA can now be invoked to provide the number of xgmi links connecting
a direct source and destination peer.
Non-direct peers will report zero links.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
drivers/gpu/drm/amd/amdgpu/ta_xgmi_if.h

index 77e794e..a74455a 100644 (file)
@@ -1078,6 +1078,12 @@ int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id)
        return 0;
 }
 
+static bool psp_xgmi_peer_link_info_supported(struct psp_context *psp)
+{
+       return psp->adev->asic_type == CHIP_ALDEBARAN &&
+                               psp->ta_xgmi_ucode_version >= 0x2000000b;
+}
+
 int psp_xgmi_get_topology_info(struct psp_context *psp,
                               int number_devices,
                               struct psp_xgmi_topology_info *topology)
@@ -1121,6 +1127,23 @@ int psp_xgmi_get_topology_info(struct psp_context *psp,
                topology->nodes[i].sdma_engine = topology_info_output->nodes[i].sdma_engine;
        }
 
+       /* Invoke xgmi ta again to get the link information */
+       if (psp_xgmi_peer_link_info_supported(psp)) {
+               struct ta_xgmi_cmd_get_peer_link_info_output *link_info_output;
+
+               xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_PEER_LINKS;
+
+               ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_PEER_LINKS);
+
+               if (ret)
+                       return ret;
+
+               link_info_output = &xgmi_cmd->xgmi_out_message.get_link_info;
+               for (i = 0; i < topology->num_nodes; i++)
+                       topology->nodes[i].num_links =
+                                       link_info_output->nodes[i].num_links;
+       }
+
        return 0;
 }
 
index 5fd8928..f0e32a9 100644 (file)
@@ -116,6 +116,7 @@ struct psp_xgmi_node_info {
        uint8_t                                 num_hops;
        uint8_t                                 is_sharing_enabled;
        enum ta_xgmi_assigned_sdma_engine       sdma_engine;
+       uint8_t                                 num_links;
 };
 
 struct psp_xgmi_topology_info {
index ac2c27b..cce7127 100644 (file)
@@ -33,7 +33,8 @@ enum ta_command_xgmi {
        TA_COMMAND_XGMI__GET_NODE_ID                    = 0x01,
        TA_COMMAND_XGMI__GET_HIVE_ID                    = 0x02,
        TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO          = 0x03,
-       TA_COMMAND_XGMI__SET_TOPOLOGY_INFO              = 0x04
+       TA_COMMAND_XGMI__SET_TOPOLOGY_INFO              = 0x04,
+       TA_COMMAND_XGMI__GET_PEER_LINKS                 = 0x0B
 };
 
 /* XGMI related enumerations */
@@ -75,6 +76,11 @@ struct ta_xgmi_node_info {
        enum ta_xgmi_assigned_sdma_engine       sdma_engine;
 };
 
+struct ta_xgmi_peer_link_info {
+       uint64_t                                node_id;
+       uint8_t                                 num_links;
+};
+
 struct ta_xgmi_cmd_initialize_output {
        uint32_t        status;
 };
@@ -97,6 +103,11 @@ struct ta_xgmi_cmd_get_topology_info_output {
        struct ta_xgmi_node_info        nodes[TA_XGMI__MAX_CONNECTED_NODES];
 };
 
+struct ta_xgmi_cmd_get_peer_link_info_output {
+       uint32_t                        num_nodes;
+       struct ta_xgmi_peer_link_info   nodes[TA_XGMI__MAX_CONNECTED_NODES];
+};
+
 struct ta_xgmi_cmd_set_topology_info_input {
        uint32_t                        num_nodes;
        struct ta_xgmi_node_info        nodes[TA_XGMI__MAX_CONNECTED_NODES];
@@ -115,6 +126,7 @@ union ta_xgmi_cmd_output {
        struct ta_xgmi_cmd_get_node_id_output           get_node_id;
        struct ta_xgmi_cmd_get_hive_id_output           get_hive_id;
        struct ta_xgmi_cmd_get_topology_info_output     get_topology_info;
+       struct ta_xgmi_cmd_get_peer_link_info_output    get_link_info;
 };
 /**********************************************************/