drm/amdgpu/mes11: set connected queue index in the reset packet
Subsystems (2)
PATCH 1/3 drm/amdgpu/mes11: set connected queue index in the reset packet
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.
--- 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(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +11 -0
@@ -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));
drivers/gpu/drm/amd/include/mes_v11_api_def.h +10 -1
@@ -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 ];
Signature · 1 line
2.49.0
PATCH 2/3 drm/amdgpu/mes12: set connected queue index in the reset packet
Program the connected queue index into the MES reset packet on gfx12 as well, so the CP_CNTX_STAT fallback can find and reset a CP-frozen gfx user queue without query_status. mes_v12_api_def.h already carries the fields.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +11 -0
@@ -1151,6 +1151,17 @@ static int mes_v12_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_v12_0_submit_pkt_and_poll_completion (mes,AMDGPU_MES_SCHED_PIPE , &mes_reset_queue_pkt,sizeof (mes_reset_queue_pkt), offsetof(union MESAPI__RESET , api_status));
Signature · 1 line
2.49.0
PATCH 3/3 drm/amdgpu/mes: pass connected queue index to hung queue detection
In reply to Jesse ZhangThe MES query_status hang detection needs a live CP and so cannot find a CP-frozen gfx user queue. The MES firmware has a CP_CNTX_STAT fallback (find_hung_queue_by_cp_ctx_stat) that locates a hung gfx queue from its pipe/hqd slot without query_status, but the driver never fed it the slot.
Extend mes_detect_and_reset_queue_input and amdgpu_mes_detect_and_reset_hung_queues() with a connected pipe/queue hint (pipe 0 -> connected_queue_index, pipe 1 -> _p1); callers that do not know the slot pass -1 to keep the existing behaviour.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 19 +++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 9 ++++++++- 3 files changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2 -1
@@ -2299,7 +2299,8 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,*/ goto fence_reset; r =amdgpu_mes_detect_and_reset_hung_queues (adev,AMDGPU_RING_TYPE_COMPUTE , - true, &num_hung, adev->gfx.mec.mes_hung_db_array,0 ); + true, &num_hung, adev->gfx.mec.mes_hung_db_array,0 , +-1 ,0 );if (r) goto out;if (hung_queue_count)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +17 -2
@@ -513,9 +513,11 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,bool detect_only, unsigned int *hung_db_num, u32 *hung_db_array, - uint32_t xcc_id) + uint32_t xcc_id, + int connected_pipe, + int connected_queue_index) { - struct mes_detect_and_reset_queue_input input; + struct mes_detect_and_reset_queue_input input = {0};u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr[xcc_id];int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i;
@@ -534,6 +536,19 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, input.detect_only = detect_only; input.xcc_id = xcc_id; +/* +* For a CP-frozen gfx queue the MES query_status hang detection can't +* see it; hand the MES the exact pipe/queue slot so its CP_CNTX_STAT +* fallback can find and reset it. +*/ +if (connected_pipe ==0 ) { + input.use_connected_queue_index = true; + input.connected_queue_index = connected_queue_index; + }else if (connected_pipe ==1 ) { + input.use_connected_queue_index_p1 = true; + input.connected_queue_index_p1 = connected_queue_index; + } + r = adev->mes.funcs->detect_and_reset_hung_queues (&adev->mes, &input);
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +8 -1
@@ -350,6 +350,11 @@ struct mes_detect_and_reset_queue_input {u32 queue_type;bool detect_only;u32 xcc_id; +/* gfx-only: locate a CP-frozen queue the MES query_status path can't see */ +bool use_connected_queue_index; +bool use_connected_queue_index_p1; +u32 connected_queue_index; +u32 connected_queue_index_p1; };struct mes_inv_tlbs_pasid_input {
@@ -544,7 +549,9 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,bool detect_only, unsigned int *hung_db_num, u32 *hung_db_array, - uint32_t xcc_id); + uint32_t xcc_id, + int connected_pipe, + int connected_queue_index);uint32_t amdgpu_mes_rreg (struct amdgpu_device *adev,uint32_t reg,uint32_t xcc_id);
Signature · 1 line
2.49.0