Sync MESAPI__RESET with the firmware definition (the
use_connected_queue_index[_p1] flags and the trailing active_vmids /
connected_queue_index[_p1] fields) and program the connected queue index
from the detect input, so the MES can locate a CP-frozen gfx user queue
via its CP_CNTX_STAT fallback.

An older MES firmware ignores the flags (previously reserved bits) and
falls back to query_status, so no firmware version gate is required.

Signed-off-by: Jesse Zhang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c        | 11 +++++++++++
 drivers/gpu/drm/amd/include/mes_v11_api_def.h | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
index b72da75dd851..3e6d3b5e9af9 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
@@ -1115,6 +1115,17 @@ static int mes_v11_0_detect_and_reset_hung_queues(struct 
amdgpu_mes *mes,
        else
                mes_reset_queue_pkt.hang_detect_then_reset = 1;
 
+       if (input->use_connected_queue_index) {
+               mes_reset_queue_pkt.use_connected_queue_index = 1;
+               mes_reset_queue_pkt.connected_queue_index =
+                       input->connected_queue_index;
+       }
+       if (input->use_connected_queue_index_p1) {
+               mes_reset_queue_pkt.use_connected_queue_index_p1 = 1;
+               mes_reset_queue_pkt.connected_queue_index_p1 =
+                       input->connected_queue_index_p1;
+       }
+
        return mes_v11_0_submit_pkt_and_poll_completion(mes,
                        &mes_reset_queue_pkt, sizeof(mes_reset_queue_pkt),
                        offsetof(union MESAPI__RESET, api_status));
diff --git a/drivers/gpu/drm/amd/include/mes_v11_api_def.h 
b/drivers/gpu/drm/amd/include/mes_v11_api_def.h
index a8e6ccc7817c..2762b55f3474 100644
--- a/drivers/gpu/drm/amd/include/mes_v11_api_def.h
+++ b/drivers/gpu/drm/amd/include/mes_v11_api_def.h
@@ -468,7 +468,11 @@ union MESAPI__RESET {
                        uint32_t                hang_detect_only : 1;
                        /* Rest HP and LP kernel queues not managed by MES */
                        uint32_t                reset_legacy_gfx : 1;
-                       uint32_t                reserved : 28;
+                       /* Fallback to connected queue index when CP_CNTX_STAT 
fails (gfx pipe 0) */
+                       uint32_t                use_connected_queue_index : 1;
+                       /* For gfx pipe 1 */
+                       uint32_t                use_connected_queue_index_p1 : 
1;
+                       uint32_t                reserved : 26;
                };
 
                uint64_t                        gang_context_addr;
@@ -496,6 +500,11 @@ union MESAPI__RESET {
                uint64_t                        wptr_addr_hp;
 
                struct MES_API_STATUS           api_status;
+               uint32_t                        active_vmids;
+               uint64_t                        timestamp;
+               uint32_t                        gang_context_array_index;
+               uint32_t                        connected_queue_index;
+               uint32_t                        connected_queue_index_p1;
        };
 
        uint32_t        max_dwords_in_api[API_FRAME_SIZE_IN_DWORDS];
-- 
2.49.0

Reply via email to