pre-req fixes for mes user compute queue reset
Subsystems (3)
cover pre-req fixes for mes user compute queue reset
A bunch of unrelated fixes needed to for MES based user compute queue reset.
Jonathan Kim (6):
drm/amdgpu: fix gfx12 mes packet status return check drm/amdgpu: fix initialization of doorbell array for detect and hang drm/amdgpu: fix hung reset queue array return for hws user compute drm/amdgpu: enable suspend/resume all for gfx 12 drm/amdkfd: fix suspend/resume all calls in mes based eviction path drm/amdgpu: update remove after reset flag for MES remove queue
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 33 ++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 2 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 6 +- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 9 ++- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 11 ++- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 73 ++++++------------- drivers/gpu/drm/amd/include/mes_v11_api_def.h | 3 +- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 3 +- 8 files changed, 64 insertions(+), 76 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/6 drm/amdgpu: fix gfx12 mes packet status return check
GFX12 MES uses low 32 bits of status return for success (1 or 0) and high bits for debug information if low bits are 0.
GFX11 MES doesn't do this so checking full 64-bit status return for 1 or 0 is still valid.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
@@ -228,7 +228,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, pipe, x_pkt->header.opcode); r =amdgpu_fence_wait_polling (ring, seq, timeout); -if (r <1 || !*status_ptr) { +if (r <1 || !(*status_ptr &0xffffffff )) {if (misc_op_str) dev_err(adev->dev, "MES(%d) failed to respond to msg=%s (%s)\n",
Signature · 1 line
2.34.1
Re: [PATCH 1/6] drm/amdgpu: fix gfx12 mes packet status return check
Quoted 17 lines · Jonathan Kim
GFX12 MES uses low 32 bits of status return for success (1 or 0) and high bits for debug information if low bits are 0.
GFX11 MES doesn't do this so checking full 64-bit status return for 1 or 0 is still valid.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, · line 231
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1@@ -228,7 +228,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, pipe, x_pkt->header.opcode); r =amdgpu_fence_wait_polling (ring, seq, timeout); -if (r <1 || !*status_ptr) { +if (r <1 || !(*status_ptr &0xffffffff )) {
You could also use lower_32_bits() here, I think that would be clearer. Please add a comment here about the status in the upper 32 bits if the value is 0.
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +0
-1if (misc_op_str) dev_err(adev->dev, "MES(%d) failed to respond to msg=%s (%s)\n", --2.34.1
PATCH 2/6 drm/amdgpu: fix initialization of doorbell array for detect and hang
In reply to Jonathan KimInitialized doorbells should be set to invalid rather than 0 to prevent driver from over counting hung doorbells since it checks against the invalid value to begin with.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -1
@@ -409,7 +409,7 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,return -EINVAL ;/* Clear the doorbell array before detection */ -memset (adev->mes.hung_queue_db_array_cpu_addr,0 , +memset (adev->mes.hung_queue_db_array_cpu_addr,AMDGPU_MES_INVALID_DB_OFFSET , adev->mes.hung_queue_db_array_size *sizeof (u32)); input.queue_type = queue_type; input.detect_only = detect_only;
Signature · 1 line
2.34.1
Re: [PATCH 2/6] drm/amdgpu: fix initialization of doorbell array for detect and hang
Quoted 6 lines · Jonathan Kim
Initialized doorbells should be set to invalid rather than 0 to prevent driver from over counting hung doorbells since it checks against the invalid value to begin with.
Signed-off-by Jonathan Kim <[email protected]>
Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-2@@ -409,7 +409,7 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,return -EINVAL ;/* Clear the doorbell array before detection */ -memset (adev->mes.hung_queue_db_array_cpu_addr,0 , +memset (adev->mes.hung_queue_db_array_cpu_addr,AMDGPU_MES_INVALID_DB_OFFSET , adev->mes.hung_queue_db_array_size *sizeof (u32)); input.queue_type = queue_type; input.detect_only = detect_only; --2.34.1
PATCH 3/6 drm/amdgpu: fix hung reset queue array return for hws user compute
In reply to Jonathan KimBy design the MES will return an array result that is twice the number of hung doorbells it can report.
i.e. if up k reported doorbells are supported, then the second half of the array, also of length k, holds the HQD information (type/queue/pipe) where queue 1 corresponds to index 0 and k, queue 2 corresponds to index 1 and k + 1 etc ...
The driver will use the HDQ info to target queue/pipe reset for hardware scheduled user compute queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 20 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 8 +++++--- 5 files changed, 30 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +16 -4
@@ -419,12 +419,24 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,if (r) {dev_err (adev->dev,"failed to detect and reset\n" ); }else { +int array_hqd_info_offset = adev->mes.hung_queue_hqd_info_offset; +int array_size = adev->mes.hung_queue_db_array_size; *hung_db_num =0 ; -for (i =0 ; i < adev->mes.hung_queue_db_array_size; i++) { -if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) { + +for (i =0 ; i < array_hqd_info_offset; i++) { +if (db_array[i] ==AMDGPU_MES_INVALID_DB_OFFSET ) +continue ; + + hung_db_array[i] = db_array[i]; + *hung_db_num +=1 ; + } + +for (i = array_hqd_info_offset; i < array_size; i++) { +if (!hung_db_num || queue_type !=AMDGPU_RING_TYPE_COMPUTE ) +break ; + +if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) hung_db_array[i] = db_array[i]; - *hung_db_num +=1 ; - } } }
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -0
@@ -149,6 +149,7 @@ struct amdgpu_mes {void *resource_1_addr[AMDGPU_MAX_MES_PIPES ];int hung_queue_db_array_size; +int hung_queue_hqd_info_offset;struct amdgpu_bo *hung_queue_db_array_gpu_obj;uint64_t hung_queue_db_array_gpu_addr;void *hung_queue_db_array_cpu_addr;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3 -3
@@ -208,10 +208,10 @@ static int mes_userq_detect_and_reset(struct amdgpu_device *adev,struct amdgpu_userq_mgr *uqm, *tmp;unsigned int hung_db_num =0 ;int queue_id, r, i; -u32 db_array[4 ]; +u32 db_array[8 ]; -if (db_array_size >4 ) { -dev_err (adev->dev,"DB array size (%d vs 4) too small\n" , +if (db_array_size >8 ) { +dev_err (adev->dev,"DB array size (%d vs 8) too small\n" , db_array_size);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +5 -3
@@ -66,7 +66,8 @@ static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev);#define GFX_MES_DRAM_SIZE 0x80000#define MES11_HW_RESOURCE_1_SIZE (128 * AMDGPU_GPU_PAGE_SIZE) -#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset, [4:7] = hqd info */ +#define MES11_HUNG_HQD_INFO_OFFSET 4static void mes_v11_0_ring_set_wptr (struct amdgpu_ring *ring) {
@@ -1720,8 +1721,9 @@ static int mes_v11_0_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_hqd_info_offset =MES11_HUNG_HQD_INFO_OFFSET ; +for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE )continue ;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +5 -3
@@ -47,7 +47,8 @@ static int mes_v12_0_kiq_hw_fini(struct amdgpu_device *adev);#define MES_EOP_SIZE 2048 -#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset [4:7] hqd info */ +#define MES12_HUNG_HQD_INFO_OFFSET 4static void mes_v12_0_ring_set_wptr (struct amdgpu_ring *ring) {
@@ -1899,8 +1900,9 @@ static int mes_v12_0_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_hqd_info_offset =MES12_HUNG_HQD_INFO_OFFSET ; +for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { r =amdgpu_mes_init_microcode (adev, pipe);if (r)
Signature · 1 line
2.34.1
Re: [PATCH 3/6] drm/amdgpu: fix hung reset queue array return for hws user compute
Quoted 8 lines · Jonathan Kim
By design the MES will return an array result that is twice the number of hung doorbells it can report.
i.e. if up k reported doorbells are supported, then the second half of the array, also of length k, holds the HQD information (type/queue/pipe) where queue 1 corresponds to index 0 and k, queue 2 corresponds to index 1 and k + 1 etc ...
Has this always been the case? If not, what mes version changed this?
Quoted 27 lines
The driver will use the HDQ info to target queue/pipe reset for hardware scheduled user compute queues.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 20 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 8 +++++--- 5 files changed, 30 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-2@@ -419,12 +419,24 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,if (r) {dev_err (adev->dev,"failed to detect and reset\n" ); }else { +int array_hqd_info_offset = adev->mes.hung_queue_hqd_info_offset; +int array_size = adev->mes.hung_queue_db_array_size; *hung_db_num =0 ; -for (i =0 ; i < adev->mes.hung_queue_db_array_size; i++) { -if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) { +
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, · line 435
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +10
-0+for (i =0 ; i < array_hqd_info_offset; i++) { +if (db_array[i] ==AMDGPU_MES_INVALID_DB_OFFSET ) +continue ; + + hung_db_array[i] = db_array[i]; + *hung_db_num +=1 ; + } + +for (i = array_hqd_info_offset; i < array_size; i++) { +if (!hung_db_num || queue_type !=AMDGPU_RING_TYPE_COMPUTE )
Might be better to move the queue_type check before the loop.
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, · line 439
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-0+break ; + +if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) hung_db_array[i] = db_array[i];
What is the point of this? If this is hqd info, then it's not a doorbell, so why add it to the list? Maybe drop the hqd array handling until we actually use it.
Alex
Quoted 90 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-2- *hung_db_num +=1 ; - } } }drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1
-0@@ -149,6 +149,7 @@ struct amdgpu_mes {void *resource_1_addr[AMDGPU_MAX_MES_PIPES ];int hung_queue_db_array_size; +int hung_queue_hqd_info_offset;struct amdgpu_bo *hung_queue_db_array_gpu_obj;uint64_t hung_queue_db_array_gpu_addr;void *hung_queue_db_array_cpu_addr;drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-3@@ -208,10 +208,10 @@ static int mes_userq_detect_and_reset(struct amdgpu_device *adev,struct amdgpu_userq_mgr *uqm, *tmp;unsigned int hung_db_num =0 ;int queue_id, r, i; -u32 db_array[4 ]; +u32 db_array[8 ]; -if (db_array_size >4 ) { -dev_err (adev->dev,"DB array size (%d vs 4) too small\n" , +if (db_array_size >8 ) { +dev_err (adev->dev,"DB array size (%d vs 8) too small\n" , db_array_size);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +5
-3@@ -66,7 +66,8 @@ static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev);#define GFX_MES_DRAM_SIZE 0x80000#define MES11_HW_RESOURCE_1_SIZE (128 * AMDGPU_GPU_PAGE_SIZE) -#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset, [4:7] = hqd info */ +#define MES11_HUNG_HQD_INFO_OFFSET 4static void mes_v11_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1720,8 +1721,9 @@ static int mes_v11_0_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_hqd_info_offset =MES11_HUNG_HQD_INFO_OFFSET ; +for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE )continue ;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +5
-4@@ -47,7 +47,8 @@ static int mes_v12_0_kiq_hw_fini(struct amdgpu_device *adev);#define MES_EOP_SIZE 2048 -#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset [4:7] hqd info */ +#define MES12_HUNG_HQD_INFO_OFFSET 4static void mes_v12_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1899,8 +1900,9 @@ static int mes_v12_0_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_hqd_info_offset =MES12_HUNG_HQD_INFO_OFFSET ; +for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { r =amdgpu_mes_init_microcode (adev, pipe);if (r) --2.34.1
RE: [PATCH 3/6] drm/amdgpu: fix hung reset queue array return for hws user compute
[Public]
Quoted 16 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, October 9, 2025 3:17 PM
To: Kim, Jonathan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Lin, Amber <[email protected]>
Subject: Re: [PATCH 3/6] drm/amdgpu: fix hung reset queue array return for hws user computeQuoted 4 lines · Jonathan Kim
By design the MES will return an array result that is twice the number of hung doorbells it can report.
Quoted 6 lines
Quoted 4 lines
i.e. if up k reported doorbells are supported, then the second half of the array, also of length k, holds the HQD information (type/queue/pipe) where queue 1 corresponds to index 0 and k, queue 2 corresponds to index 1 and k + 1 etc ...
Has this always been the case? If not, what mes version changed this?
It's been around since the beginning.
Quoted 42 lines
Quoted 14 lines
The driver will use the HDQ info to target queue/pipe reset for hardware scheduled user compute queues.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 20 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 8 +++++--- 5 files changed, 30 insertions(+), 13 deletions(-)Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.cdrivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int
Quoted 4 lines
index
c698e183beda..1af3ddb6f65c100644drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -419,12 +419,24 @@ intamdgpu_mes_detect_and_reset_hung_queues(struct
amdgpu_device*adev,Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-2if (r) {dev_err (adev->dev,"failed to detect and reset\n" ); }else { +int array_hqd_info_offset = adev->mes.hung_queue_hqd_info_offset; +int array_size = adev->mes.hung_queue_db_array_size; *hung_db_num =0 ; -for (i =0 ; i < adev->mes.hung_queue_db_array_size; i++) { -if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) { +drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +10
-0+for (i =0 ; i < array_hqd_info_offset; i++) { +if (db_array[i] ==AMDGPU_MES_INVALID_DB_OFFSET ) +continue ; + + hung_db_array[i] = db_array[i]; + *hung_db_num +=1 ; + } + + for (i = array_hqd_info_offset; i < array_size; i++) { + if (!hung_db_num || queue_type !=
AMDGPU_RING_TYPE_COMPUTE)
Quoted 1 line
Might be better to move the
queue_typecheck before the loop.
Ack.
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, · line 439
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-0+break ; + +if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) hung_db_array[i] = db_array[i];What is the point of this? If this is hqd info, then it's not a doorbell, so why add it to the list? Maybe drop the hqd array handling until we actually use it.
It's for later use with the current KFD.
We need to steer to the right queue/pipe coordinates for pipe reset and HQD active checks later via mmio r/w. Sure, I can squash this patch into a follow on series when we actually start to resetting queues.
Jon
Quoted 108 lines
Alex
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-2- *hung_db_num +=1 ; - } } }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.hReview
Quoted 12 lines
index
6b506fc72f58..97c137c90f97100644drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1
-0@@ -149,6 +149,7 @@ struct amdgpu_mes {void *resource_1_addr[AMDGPU_MAX_MES_PIPES ];int hung_queue_db_array_size; +int hung_queue_hqd_info_offset;struct amdgpu_bo *hung_queue_db_array_gpu_obj;uint64_t hung_queue_db_array_gpu_addr;void *hung_queue_db_array_cpu_addr;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.cdrivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_detect_and_reset(struct
Quoted 4 lines
index
829129ad7bd1..5c63480dda9c100644drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0@@ -208,10 +208,10 @@ static int mes_userq_detect_and_reset(struct
amdgpu_device*adev,Review
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-3struct amdgpu_userq_mgr *uqm, *tmp;unsigned int hung_db_num =0 ;int queue_id, r, i; -u32 db_array[4 ]; +u32 db_array[8 ]; -if (db_array_size >4 ) { -dev_err (adev->dev,"DB array size (%d vs 4) too small\n" , +if (db_array_size >8 ) { +dev_err (adev->dev,"DB array size (%d vs 8) too small\n" , db_array_size);return -EINVAL ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.cdrivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_kiq_hw_fini(struct amdgpu_device
Quoted 4 lines
index
e82188431f79..da575bb1377f100644drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0
-0@@ -66,7 +66,8 @@ static int mes_v11_0_kiq_hw_fini(struct amdgpu_device*adev);
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev);
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-1#define GFX_MES_DRAM_SIZE 0x80000#define MES11_HW_RESOURCE_1_SIZE (128 * AMDGPU_GPU_PAGE_SIZE) -#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset, [4:7] = hqd info */
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+#define MES11_HUNG_HQD_INFO_OFFSET 4static void mes_v11_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1720,8 +1721,9 @@ static int mes_v11_0_early_init(struct
amdgpu_ip_block*ip_block)drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct amdgpu_ip_block *ip_block)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-2struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =
MES11_HUNG_DB_OFFSET_ARRAY_SIZE;drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct · line 1725
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+ adev->mes.hung_queue_hqd_info_offset =
MES11_HUNG_HQD_INFO_OFFSET;Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE )continue ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_v12_0.cdrivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_kiq_hw_fini(struct amdgpu_device
Quoted 4 lines
index
be8a352f9771..79dd2261ad04100644drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +0
-0@@ -47,7 +47,8 @@ static int mes_v12_0_kiq_hw_fini(struct amdgpu_device*adev);
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_kiq_hw_fini(struct amdgpu_device *adev);
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1#define MES_EOP_SIZE 2048 -#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset [4:7] hqd info */
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-0+#define MES12_HUNG_HQD_INFO_OFFSET 4static void mes_v12_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1899,8 +1900,9 @@ static int mes_v12_0_early_init(struct
amdgpu_ip_block*ip_block)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct amdgpu_ip_block *ip_block)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-2struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =
MES12_HUNG_DB_OFFSET_ARRAY_SIZE;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct · line 1904
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-0+ adev->mes.hung_queue_hqd_info_offset =
MES12_HUNG_HQD_INFO_OFFSET;Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1+for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { r =amdgpu_mes_init_microcode (adev, pipe);if (r) --2.34.1
Re: [PATCH 3/6] drm/amdgpu: fix hung reset queue array return for hws user compute
Quoted 80 lines · Jonathan
[Public]
Quoted 16 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, October 9, 2025 3:17 PM
To: Kim, Jonathan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Lin, Amber <[email protected]>
Subject: Re: [PATCH 3/6] drm/amdgpu: fix hung reset queue array return for hws user computeQuoted 4 lines · Jonathan Kim
By design the MES will return an array result that is twice the number of hung doorbells it can report.
Quoted 6 lines
Quoted 4 lines
i.e. if up k reported doorbells are supported, then the second half of the array, also of length k, holds the HQD information (type/queue/pipe) where queue 1 corresponds to index 0 and k, queue 2 corresponds to index 1 and k + 1 etc ...
Has this always been the case? If not, what mes version changed this?
It's been around since the beginning.
Quoted 42 lines
Quoted 14 lines
The driver will use the HDQ info to target queue/pipe reset for hardware scheduled user compute queues.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 20 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 8 +++++--- 5 files changed, 30 insertions(+), 13 deletions(-)Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.cdrivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int
Quoted 4 lines
index
c698e183beda..1af3ddb6f65c100644drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -419,12 +419,24 @@ intamdgpu_mes_detect_and_reset_hung_queues(struct
amdgpu_device*adev,Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-2if (r) {dev_err (adev->dev,"failed to detect and reset\n" ); }else { +int array_hqd_info_offset = adev->mes.hung_queue_hqd_info_offset; +int array_size = adev->mes.hung_queue_db_array_size; *hung_db_num =0 ; -for (i =0 ; i < adev->mes.hung_queue_db_array_size; i++) { -if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) { +drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +10
-0+for (i =0 ; i < array_hqd_info_offset; i++) { +if (db_array[i] ==AMDGPU_MES_INVALID_DB_OFFSET ) +continue ; + + hung_db_array[i] = db_array[i]; + *hung_db_num +=1 ; + } + + for (i = array_hqd_info_offset; i < array_size; i++) { + if (!hung_db_num || queue_type !=
AMDGPU_RING_TYPE_COMPUTE)Quoted 1 line
Might be better to move the
queue_typecheck before the loop.Ack.
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-0+break ; + +if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) hung_db_array[i] = db_array[i];
Quoted 7 lines
Quoted 3 lines
What is the point of this? If this is hqd info, then it's not a doorbell, so why add it to the list? Maybe drop the hqd array handling until we actually use it.
It's for later use with the current KFD.
We need to steer to the right queue/pipe coordinates for pipe reset and HQD active checks later via mmio r/w. Sure, I can squash this patch into a follow on series when we actually start to resetting queues.
We should still increase the array size so that we allocate enough memory, but maybe hold off on returning the hqd info until you use it.
Alex
Quoted 112 lines
Jon
Quoted 108 lines
Alex
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-2- *hung_db_num +=1 ; - } } }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.hReview
Quoted 12 lines
index
6b506fc72f58..97c137c90f97100644drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1
-0@@ -149,6 +149,7 @@ struct amdgpu_mes {void *resource_1_addr[AMDGPU_MAX_MES_PIPES ];int hung_queue_db_array_size; +int hung_queue_hqd_info_offset;struct amdgpu_bo *hung_queue_db_array_gpu_obj;uint64_t hung_queue_db_array_gpu_addr;void *hung_queue_db_array_cpu_addr;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.cdrivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_detect_and_reset(struct
Quoted 4 lines
index
829129ad7bd1..5c63480dda9c100644drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0@@ -208,10 +208,10 @@ static int mes_userq_detect_and_reset(struct
amdgpu_device*adev,Review
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-3struct amdgpu_userq_mgr *uqm, *tmp;unsigned int hung_db_num =0 ;int queue_id, r, i; -u32 db_array[4 ]; +u32 db_array[8 ]; -if (db_array_size >4 ) { -dev_err (adev->dev,"DB array size (%d vs 4) too small\n" , +if (db_array_size >8 ) { +dev_err (adev->dev,"DB array size (%d vs 8) too small\n" , db_array_size);return -EINVAL ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.cdrivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_kiq_hw_fini(struct amdgpu_device
Quoted 4 lines
index
e82188431f79..da575bb1377f100644drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0
-0@@ -66,7 +66,8 @@ static int mes_v11_0_kiq_hw_fini(struct amdgpu_device*adev);
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev);
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-1#define GFX_MES_DRAM_SIZE 0x80000#define MES11_HW_RESOURCE_1_SIZE (128 * AMDGPU_GPU_PAGE_SIZE) -#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES11_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset, [4:7] = hqd info */
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+#define MES11_HUNG_HQD_INFO_OFFSET 4static void mes_v11_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1720,8 +1721,9 @@ static int mes_v11_0_early_init(struct
amdgpu_ip_block*ip_block)drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct amdgpu_ip_block *ip_block)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-2struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES11_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =
MES11_HUNG_DB_OFFSET_ARRAY_SIZE;drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_early_init(struct · line 1725
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+ adev->mes.hung_queue_hqd_info_offset =
MES11_HUNG_HQD_INFO_OFFSET;Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0+for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE )continue ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/mes_v12_0.cdrivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_kiq_hw_fini(struct amdgpu_device
Quoted 4 lines
index
be8a352f9771..79dd2261ad04100644drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +0
-0@@ -47,7 +47,8 @@ static int mes_v12_0_kiq_hw_fini(struct amdgpu_device*adev);
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_kiq_hw_fini(struct amdgpu_device *adev);
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1#define MES_EOP_SIZE 2048 -#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 4 +#define MES12_HUNG_DB_OFFSET_ARRAY_SIZE 8/* [0:3] = db offset [4:7] hqd info */
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-0+#define MES12_HUNG_HQD_INFO_OFFSET 4static void mes_v12_0_ring_set_wptr (struct amdgpu_ring *ring) {@@ -1899,8 +1900,9 @@ static int mes_v12_0_early_init(struct
amdgpu_ip_block*ip_block)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct amdgpu_ip_block *ip_block)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-2struct amdgpu_device *adev = ip_block->adev;int pipe, r; - adev->mes.hung_queue_db_array_size = -MES12_HUNG_DB_OFFSET_ARRAY_SIZE ; + adev->mes.hung_queue_db_array_size =
MES12_HUNG_DB_OFFSET_ARRAY_SIZE;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c static int mes_v12_0_early_init(struct · line 1904
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-0+ adev->mes.hung_queue_hqd_info_offset =
MES12_HUNG_HQD_INFO_OFFSET;Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1+for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { r =amdgpu_mes_init_microcode (adev, pipe);if (r) --2.34.1
PATCH 4/6 drm/amdgpu: enable suspend/resume all for gfx 12
In reply to Jonathan KimSuspend/resume all gangs has been available for GFX12 for a while now so enable it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +4 -7
@@ -698,14 +698,11 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)bool amdgpu_mes_suspend_resume_all_supported (struct amdgpu_device *adev) {uint32_t mes_rev = adev->mes.sched_version &AMDGPU_MES_VERSION_MASK ; -bool is_supported = false; -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 ) && -amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && - mes_rev >=0x63 ) - is_supported = true; - -return is_supported; +return ((amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 ) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && + mes_rev >=0x63 ) || +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (12 ,0 ,0 )); }/* Fix me -- node_id is used to identify the correct MES instances in the future */
Signature · 1 line
2.34.1
Re: [PATCH 4/6] drm/amdgpu: enable suspend/resume all for gfx 12
Quoted 3 lines · Jonathan Kim
Suspend/resume all gangs has been available for GFX12 for a while now so enable it.
Is this true for all released gfx12 MES firmwares? If so,
Quoted 32 lines
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +4
-8@@ -698,14 +698,11 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)bool amdgpu_mes_suspend_resume_all_supported (struct amdgpu_device *adev) {uint32_t mes_rev = adev->mes.sched_version &AMDGPU_MES_VERSION_MASK ; -bool is_supported = false; -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 ) && -amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && - mes_rev >=0x63 ) - is_supported = true; - -return is_supported; +return ((amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 ) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && + mes_rev >=0x63 ) || +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (12 ,0 ,0 )); }/* Fix me -- node_id is used to identify the correct MES instances in the future */ --2.34.1
RE: [PATCH 4/6] drm/amdgpu: enable suspend/resume all for gfx 12
[Public]
Quoted 10 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, October 9, 2025 3:09 PM
To: Kim, Jonathan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Lin, Amber <[email protected]>
Subject: Re: [PATCH 4/6] drm/amdgpu: enable suspend/resume all for gfx 12
Quoted 7 lines
Quoted 3 lines · Jonathan Kim
Suspend/resume all gangs has been available for GFX12 for a while now so enable it.
Is this true for all released gfx12 MES firmwares? If so,
Acked-by Alex Deucher <[email protected]>
Yes this has been available for all of GFX 12 for a while.
Jon
Quoted 39 lines
Review
Quoted 8 lines
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.cdrivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init_microcode(struct
Quoted 4 lines
index
1af3ddb6f65c..b2f87bc29f00100644drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -698,14 +698,11 @@ int amdgpu_mes_init_microcode(struct
amdgpu_device*adev, int pipe)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init_microcode(struct · line 698
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0bool amdgpu_mes_suspend_resume_all_supported(struct amdgpu_device*adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init_microcode(struct · line 700
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0{ uint32_t mes_rev = adev->mes.sched_version &
AMDGPU_MES_VERSION_MASK;drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-7-bool is_supported = false; -if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 ) && -amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && - mes_rev >=0x63 ) - is_supported = true; - -return is_supported; + return ((amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(11, 0, 0)&&
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-0+amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (12 ,0 ,0 ) && + mes_rev >= 0x63) || + amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0)); }/* Fix me -- node_id is used to identify the correct MES instances in the future */
Quoted 3 lines
--
2.34.1
PATCH 5/6 drm/amdkfd: fix suspend/resume all calls in mes based eviction path
In reply to Jonathan KimSuspend/resume all gangs should be done with the device lock is held.
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 73 ++++++------------- 1 file changed, 21 insertions(+), 52 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +21 -52
@@ -1209,6 +1209,15 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,pr_debug_ratelimited ("Evicting process pid %d queues\n" , pdd->process->lead_thread->pid); +if (dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); + retval =suspend_all_queues_mes (dqm); +if (retval) { +dev_err (dev,"Suspending all queues failed" ); + goto out; + } + } +/* Mark all queues as evicted. Deactivate all active queues on * the qpd. */
@@ -1221,23 +1230,27 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { -int err; - - err =remove_queue_mes (dqm, q, qpd); -if (err) { + retval =remove_queue_mes (dqm, q, qpd); +if (retval) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - retval = err; + goto out; } } } - pdd->last_evict_timestamp =get_jiffies_64 (); -if (!dqm->dev->kfd->shared_resources.enable_mes) + +if (!dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); retval =execute_queues_cpsch (dqm, qpd->is_debug ?KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES :KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES ,0 ,USE_DEFAULT_GRACE_PERIOD ); + }else { + retval =resume_all_queues_mes (dqm); +if (retval) +dev_err (dev,"Resuming all queues failed" ); + } out:dqm_unlock (dqm);
@@ -3098,61 +3111,17 @@ int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbelreturn ret; } -static int kfd_dqm_evict_pasid_mes (struct device_queue_manager *dqm, -struct qcm_process_device *qpd) -{ -struct device *dev = dqm->dev->adev->dev; -int ret =0 ; - -/* Check if process is already evicted */ -dqm_lock (dqm); -if (qpd->evicted) { -/* Increment the evicted count to make sure the -* process stays evicted before its terminated. -*/ - qpd->evicted++; -dqm_unlock (dqm); - goto out; - } -dqm_unlock (dqm); - - ret =suspend_all_queues_mes (dqm); -if (ret) { -dev_err (dev,"Suspending all queues failed" ); - goto out; - } - - ret = dqm->ops.evict_process_queues (dqm, qpd); -if (ret) { -dev_err (dev,"Evicting process queues failed" ); - goto out; - } - - ret =resume_all_queues_mes (dqm); -if (ret) -dev_err (dev,"Resuming all queues failed" ); - -out: -return ret; -} -int kfd_evict_process_device (struct kfd_process_device *pdd) {struct device_queue_manager *dqm;struct kfd_process *p; -int ret =0 ; p = pdd->process; dqm = pdd->dev->dqm;WARN (debug_evictions,"Evicting pid %d" , p->lead_thread->pid); -if (dqm->dev->kfd->shared_resources.enable_mes) - ret =kfd_dqm_evict_pasid_mes (dqm, &pdd->qpd); -else - ret = dqm->ops.evict_process_queues (dqm, &pdd->qpd); - -return ret; +return dqm->ops.evict_process_queues (dqm, &pdd->qpd); } int reserve_debug_trap_vmid(struct device_queue_manager *dqm,
Signature · 1 line
2.34.1
Re: [PATCH 5/6] drm/amdkfd: fix suspend/resume all calls in mes based eviction path
Quoted 4 lines · Jonathan Kim
Suspend/resume all gangs should be done with the device lock is held.
Signed-off-by Jonathan Kim <[email protected]>
Quoted 125 lines
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 73 ++++++------------- 1 file changed, 21 insertions(+), 52 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +21
-53@@ -1209,6 +1209,15 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,pr_debug_ratelimited ("Evicting process pid %d queues\n" , pdd->process->lead_thread->pid); +if (dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); + retval =suspend_all_queues_mes (dqm); +if (retval) { +dev_err (dev,"Suspending all queues failed" ); + goto out; + } + } +/* Mark all queues as evicted. Deactivate all active queues on * the qpd. */ @@ -1221,23 +1230,27 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { -int err; - - err =remove_queue_mes (dqm, q, qpd); -if (err) { + retval =remove_queue_mes (dqm, q, qpd); +if (retval) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - retval = err; + goto out; } } } - pdd->last_evict_timestamp =get_jiffies_64 (); -if (!dqm->dev->kfd->shared_resources.enable_mes) + +if (!dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); retval =execute_queues_cpsch (dqm, qpd->is_debug ?KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES :KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES ,0 ,USE_DEFAULT_GRACE_PERIOD ); + }else { + retval =resume_all_queues_mes (dqm); +if (retval) +dev_err (dev,"Resuming all queues failed" ); + } out:dqm_unlock (dqm);@@ -3098,61 +3111,17 @@ int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbelreturn ret; } -static int kfd_dqm_evict_pasid_mes (struct device_queue_manager *dqm, -struct qcm_process_device *qpd) -{ -struct device *dev = dqm->dev->adev->dev; -int ret =0 ; - -/* Check if process is already evicted */ -dqm_lock (dqm); -if (qpd->evicted) { -/* Increment the evicted count to make sure the -* process stays evicted before its terminated. -*/ - qpd->evicted++; -dqm_unlock (dqm); - goto out; - } -dqm_unlock (dqm); - - ret =suspend_all_queues_mes (dqm); -if (ret) { -dev_err (dev,"Suspending all queues failed" ); - goto out; - } - - ret = dqm->ops.evict_process_queues (dqm, qpd); -if (ret) { -dev_err (dev,"Evicting process queues failed" ); - goto out; - } - - ret =resume_all_queues_mes (dqm); -if (ret) -dev_err (dev,"Resuming all queues failed" ); - -out: -return ret; -} -int kfd_evict_process_device (struct kfd_process_device *pdd) {struct device_queue_manager *dqm;struct kfd_process *p; -int ret =0 ; p = pdd->process; dqm = pdd->dev->dqm;WARN (debug_evictions,"Evicting pid %d" , p->lead_thread->pid); -if (dqm->dev->kfd->shared_resources.enable_mes) - ret =kfd_dqm_evict_pasid_mes (dqm, &pdd->qpd); -else - ret = dqm->ops.evict_process_queues (dqm, &pdd->qpd); - -return ret; +return dqm->ops.evict_process_queues (dqm, &pdd->qpd); } int reserve_debug_trap_vmid(struct device_queue_manager *dqm, --2.34.1
RE: [PATCH 5/6] drm/amdkfd: fix suspend/resume all calls in mes based eviction path
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, October 9, 2025 3:10 PM
To: Kim, Jonathan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Lin, Amber <[email protected]>
Subject: Re: [PATCH 5/6] drm/amdkfd: fix suspend/resume all calls in mes based eviction path
Quoted 4 lines · Jonathan Kim
Suspend/resume all gangs should be done with the device lock is held.
Signed-off-by Jonathan Kim <[email protected]>
Quoted 125 lines
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 73 ++++++------------- 1 file changed, 21 insertions(+), 52 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +21
-53@@ -1209,6 +1209,15 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,pr_debug_ratelimited ("Evicting process pid %d queues\n" , pdd->process->lead_thread->pid); +if (dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); + retval =suspend_all_queues_mes (dqm); +if (retval) { +dev_err (dev,"Suspending all queues failed" ); + goto out; + } + } +/* Mark all queues as evicted. Deactivate all active queues on * the qpd. */ @@ -1221,23 +1230,27 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { -int err; - - err =remove_queue_mes (dqm, q, qpd); -if (err) { + retval =remove_queue_mes (dqm, q, qpd); +if (retval) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - retval = err; + goto out; } } } - pdd->last_evict_timestamp =get_jiffies_64 (); -if (!dqm->dev->kfd->shared_resources.enable_mes) + +if (!dqm->dev->kfd->shared_resources.enable_mes) { + pdd->last_evict_timestamp =get_jiffies_64 (); retval =execute_queues_cpsch (dqm, qpd->is_debug ?KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES :KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES ,0 ,USE_DEFAULT_GRACE_PERIOD ); + }else { + retval =resume_all_queues_mes (dqm); +if (retval) +dev_err (dev,"Resuming all queues failed" ); + } out:dqm_unlock (dqm);@@ -3098,61 +3111,17 @@ int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbelreturn ret; } -static int kfd_dqm_evict_pasid_mes (struct device_queue_manager *dqm, -struct qcm_process_device *qpd) -{ -struct device *dev = dqm->dev->adev->dev; -int ret =0 ; - -/* Check if process is already evicted */ -dqm_lock (dqm); -if (qpd->evicted) { -/* Increment the evicted count to make sure the -* process stays evicted before its terminated. -*/ - qpd->evicted++; -dqm_unlock (dqm); - goto out; - } -dqm_unlock (dqm); - - ret =suspend_all_queues_mes (dqm); -if (ret) { -dev_err (dev,"Suspending all queues failed" ); - goto out; - } - - ret = dqm->ops.evict_process_queues (dqm, qpd); -if (ret) { -dev_err (dev,"Evicting process queues failed" ); - goto out; - } - - ret =resume_all_queues_mes (dqm); -if (ret) -dev_err (dev,"Resuming all queues failed" ); - -out: -return ret; -} -int kfd_evict_process_device (struct kfd_process_device *pdd) {struct device_queue_manager *dqm;struct kfd_process *p; -int ret =0 ; p = pdd->process; dqm = pdd->dev->dqm;WARN (debug_evictions,"Evicting pid %d" , p->lead_thread->pid); -if (dqm->dev->kfd->shared_resources.enable_mes) - ret =kfd_dqm_evict_pasid_mes (dqm, &pdd->qpd); -else - ret = dqm->ops.evict_process_queues (dqm, &pdd->qpd); - -return ret; +return dqm->ops.evict_process_queues (dqm, &pdd->qpd); } int reserve_debug_trap_vmid(struct device_queue_manager *dqm, --2.34.1
PATCH 6/6 drm/amdgpu: update remove after reset flag for MES remove queue
In reply to Jonathan KimRemove queue after reset flag is required to remove a queue that has been successfully reset to clean up the MES' internal state.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 1 + drivers/gpu/drm/amd/include/mes_v11_api_def.h | 3 ++- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 3 ++- 5 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -0
@@ -239,6 +239,7 @@ struct mes_add_queue_input {struct mes_remove_queue_input {uint32_t doorbell_offset;uint64_t gang_context_addr; +bool remove_queue_after_reset; };struct mes_map_legacy_queue_input {
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -0
@@ -378,6 +378,7 @@ static int mes_v11_0_remove_hw_queue(struct amdgpu_mes *mes, mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset; mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr; + mes_remove_queue_pkt.remove_queue_after_reset = input->remove_queue_after_reset; return mes_v11_0_submit_pkt_and_poll_completion(mes, &mes_remove_queue_pkt, sizeof(mes_remove_queue_pkt),
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -0
@@ -365,6 +365,7 @@ static int mes_v12_0_remove_hw_queue(struct amdgpu_mes *mes, mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset; mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr; + mes_remove_queue_pkt.remove_queue_after_reset = input->remove_queue_after_reset; return mes_v12_0_submit_pkt_and_poll_completion(mes, AMDGPU_MES_SCHED_PIPE,
drivers/gpu/drm/amd/include/mes_v11_api_def.h +2 -1
@@ -345,7 +345,8 @@ union MESAPI__REMOVE_QUEUE { uint32_t unmap_kiq_utility_queue : 1; uint32_t preempt_legacy_gfx_queue : 1; uint32_t unmap_legacy_queue : 1; - uint32_t reserved : 28; + uint32_t remove_queue_after_reset : 1; + uint32_t reserved : 27; };struct MES_API_STATUS api_status;
drivers/gpu/drm/amd/include/mes_v12_api_def.h +2 -1
@@ -399,7 +399,8 @@ union MESAPI__REMOVE_QUEUE { uint32_t unmap_kiq_utility_queue : 1; uint32_t preempt_legacy_gfx_queue : 1; uint32_t unmap_legacy_queue : 1; - uint32_t reserved : 28; + uint32_t remove_queue_after_reset : 1; + uint32_t reserved : 27; };struct MES_API_STATUS api_status;
Signature · 1 line
2.34.1
Re: [PATCH 6/6] drm/amdgpu: update remove after reset flag for MES remove queue
Quoted 3 lines · Jonathan Kim
Remove queue after reset flag is required to remove a queue that has been successfully reset to clean up the MES' internal state.
Is there a minimum mes version which has this functionality?
Alex
Quoted 77 lines
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 + drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 1 + drivers/gpu/drm/amd/include/mes_v11_api_def.h | 3 ++- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 3 ++- 5 files changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1
-0@@ -239,6 +239,7 @@ struct mes_add_queue_input {struct mes_remove_queue_input {uint32_t doorbell_offset;uint64_t gang_context_addr; +bool remove_queue_after_reset; };struct mes_map_legacy_queue_input {drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-0@@ -378,6 +378,7 @@ static int mes_v11_0_remove_hw_queue(struct amdgpu_mes *mes, mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset; mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr; + mes_remove_queue_pkt.remove_queue_after_reset = input->remove_queue_after_reset; return mes_v11_0_submit_pkt_and_poll_completion(mes, &mes_remove_queue_pkt, sizeof(mes_remove_queue_pkt),drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-0@@ -365,6 +365,7 @@ static int mes_v12_0_remove_hw_queue(struct amdgpu_mes *mes, mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset; mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr; + mes_remove_queue_pkt.remove_queue_after_reset = input->remove_queue_after_reset; return mes_v12_0_submit_pkt_and_poll_completion(mes, AMDGPU_MES_SCHED_PIPE,drivers/gpu/drm/amd/include/mes_v11_api_def.h +2
-1@@ -345,7 +345,8 @@ union MESAPI__REMOVE_QUEUE { uint32_t unmap_kiq_utility_queue : 1; uint32_t preempt_legacy_gfx_queue : 1; uint32_t unmap_legacy_queue : 1; - uint32_t reserved : 28; + uint32_t remove_queue_after_reset : 1; + uint32_t reserved : 27; };struct MES_API_STATUS api_status;drivers/gpu/drm/amd/include/mes_v12_api_def.h +2
-2@@ -399,7 +399,8 @@ union MESAPI__REMOVE_QUEUE { uint32_t unmap_kiq_utility_queue : 1; uint32_t preempt_legacy_gfx_queue : 1; uint32_t unmap_legacy_queue : 1; - uint32_t reserved : 28; + uint32_t remove_queue_after_reset : 1; + uint32_t reserved : 27; };struct MES_API_STATUS api_status; --2.34.1