drm/amdgpu: Add debug messages for MES queue reset
Subsystems (3)
PATCH v2 1/4 drm/amdgpu: Add debug messages for MES queue reset
This patch adds debug messages to collect some MES queue reset data.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 12 ++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +10 -2
@@ -2495,15 +2495,21 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,*/ r =amdgpu_mes_suspend (adev,0 );/* if suspend all success, it should no hang queue */ -if (!r) +if (!r) { +dev_dbg (adev->dev,"Suspend all succeeds. xcc_id %d\n" , xcc_id);/* always reset the KCQ/userq since we need to signal the fence * and we could be stuck in a loop which is preemptable. */ 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 ); -if (r) +if (r) { +dev_dbg (adev->dev,"MES fails on detecting hung queues\n" ); goto out; + } +dev_dbg (adev->dev,"Detected %d hung queues\n" , num_hung); +if (hung_queue_count) *hung_queue_count = num_hung;
@@ -2530,6 +2536,8 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, pipe = hqd_info[i].pipe_index; queue = hqd_info[i].queue_index; queue_type = hqd_info[i].queue_type; +dev_dbg (adev->dev,"Hung queue: queue_id %d at pipe %d type %d\n" , + queue, pipe, queue_type);/* reset any KCQs */ r = amdgpu_gfx_reset_mes_kcq(adev, ring,
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -0
@@ -557,6 +557,7 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,for (i =0 ; i < adev->mes.hung_queue_hqd_info_offset; i++) {/* Finding hung queues where db_array[i] is a valid doorbell */ if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) { +dev_dbg (adev->dev,"MES: hung queue doorbell 0x%x\n" , db_array[i]); hung_db_array[i] = db_array[i]; *hung_db_num +=1 ; }
Signature · 1 line
2.43.0
PATCH v2 2/4 drm/amdgpu: Add xcp to reset_mes_compute function
Add xcp parameter to amdgpu_gfx_reset_mes_compute() so on an ASIC that supports compute partitioning, we can identify the partition's node ID and its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 +++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +13 -4
@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,
@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */
@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg (adev->dev,"Suspend all succeeds. xcc_id %d\n" , xcc_id);
@@ -2503,7 +2512,7 @@ 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, xcc_id);if (r) {dev_dbg (adev->dev,"MES fails on detecting hung queues\n" ); goto out;
@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r =amdgpu_amdkfd_reset_mes_queue (adev,0 , queue_type, pipe, queue, + r =amdgpu_amdkfd_reset_mes_queue (adev, xcp_id, queue_type, pipe, queue, adev->gfx.mec.mes_hung_db_array[i]);if (r) goto out;
@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, out:/* resume all will enable the non-hung queues */ -amdgpu_mes_resume (adev,0 ); +amdgpu_mes_resume (adev, xcc_id);/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue.
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence,NULL ,NULL ,NULL ); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence,NULL ,NULL ,NULL ); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v12_0_ring_begin_use (struct amdgpu_ring *ring)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -1
@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd =kfd_get_process_device_data (q->device, q->process);
Signature · 1 line
2.43.0
Re: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
Quoted 21 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that supports compute partitioning, we can identify the partition's node ID and its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 +++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, · line 2473
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,
Ring carries xcp_id. It's better to make use of the same (when xcp_mgr is also present).
It's harder to read the caller locations with NULL, NULL....
Thanks,
Lijo
Quoted 118 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +12
-4struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */ @@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg (adev->dev,"Suspend all succeeds. xcc_id %d\n" , xcc_id);@@ -2503,7 +2512,7 @@ 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, xcc_id);if (r) {dev_dbg (adev->dev,"MES fails on detecting hung queues\n" ); goto out;@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r =amdgpu_amdkfd_reset_mes_queue (adev,0 , queue_type, pipe, queue, + r =amdgpu_amdkfd_reset_mes_queue (adev, xcp_id, queue_type, pipe, queue, adev->gfx.mec.mes_hung_db_array[i]);if (r) goto out;@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, out:/* resume all will enable the non-hung queues */ -amdgpu_mes_resume (adev,0 ); +amdgpu_mes_resume (adev, xcc_id);/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue. drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence,NULL ,NULL ,NULL ); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence,NULL ,NULL ,NULL ); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v12_0_ring_begin_use (struct amdgpu_ring *ring)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd =kfd_get_process_device_data (q->device, q->process);
RE: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
AMD General
Regards,
Amber
Quoted 20 lines · Lijo
Quoted 17 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that supports compute partitioning, we can identify the partition's node ID and
its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 +++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct · line 2473
Quoted 10 lines
drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drm/amd/amdgpu/amdgpu_gfx.c
index0c1c8ae822d4..ef34f7b02d0e100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,Ring carries
xcp_id. It's better to make use of the same (whenxcp_mgris also present).
I need xcp_id (for KFD) and master xcc_id. When KFD calls this function, passing "struct amdgpu_xcp" can get both data. ring is non-NULL only when this function is called by KCQ (and I don't find any function to retrieve master xcc_id using xcp_id). When KFD or gfx user queue calls this function, ring is NULL.
Quoted 145 lines
It's harder to read the caller locations with NULL, NULL....
Thanks,
LijoQuoted 139 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8
-0struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg(adev->dev, "Suspend all succeeds. xcc_id %d\n",
xcc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2503,7 +2512,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_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-Quoted 1 line
gfx.mec.mes_hung_db_array,
xcc_id);if (r) { dev_dbg(adev->dev, "MES fails on detecting hung queues\n"); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r = amdgpu_amdkfd_reset_mes_queue(adev, 0, queue_type, pipe, queue, + r = amdgpu_amdkfd_reset_mes_queue(adev, xcp_id, queue_type, pipe, queue,adev->gfx.mec.mes_hung_db_array[i]); if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, out:/* resume all will enable the non-hung queues */ - amdgpu_mes_resume(adev, 0); +amdgpu_mes_resume (adev ,xcc_id );/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue. drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0
drm/amd/amdgpu/amdgpu_gfx.h
index5939e1fb3b24..26bbec8f92e8100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence,struct
amdgpu_usermode_queue*uq,drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drm/amd/amdgpu/amdgpu_userq.c
index1a2aa85c504e..7dfe6e83f8ce100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0
amd/amdgpu/gfx_v11_0.c
index315dfd806d56..fdc0620ca67f100644drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print(struct
amdgpu_ip_block*ip_block,
structdrm_printer*p)drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0
amd/amdgpu/gfx_v12_0.c
indexd334fb805020..ec5ec1fd8b9d100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void
gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)(quoted diff) renamed from drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cindexce67e56efa8c..0eb4081a5740100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd = kfd_get_process_device_data(q->device, q->process);
Re: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
Quoted 40 lines · Amber
AMD General
Regards,
AmberQuoted 20 lines · Lijo
Quoted 17 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that supports compute partitioning, we can identify the partition's node ID and
its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 +++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct · line 2473
Quoted 10 lines
drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drm/amd/amdgpu/amdgpu_gfx.c
index0c1c8ae822d4..ef34f7b02d0e100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,Ring carries
xcp_id. It's better to make use of the same (whenxcp_mgris also present).
Quoted 2 lines
I need
xcp_id(for KFD) and masterxcc_id. When KFD calls this function, passing "structamdgpu_xcp" can get both data. ring is non-NULL only when this function is called by KCQ (and I don't find any function to retrieve masterxcc_idusingxcp_id). When KFD or gfx user queue calls this function, ring is NULL.
There is a queue input argument carrying xcc_id (end of this patch). The same may be used for mes suspend etc. However, that doesn't cover xcp id.
Quoted 128 lines
Quoted 128 lines
It's harder to read the caller locations with NULL, NULL....
Thanks,
LijoQuoted 123 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8
-0struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg(adev->dev, "Suspend all succeeds. xcc_id %d\n",
xcc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2503,7 +2512,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_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-Quoted 1 line
gfx.mec.mes_hung_db_array,
xcc_id);if (r) { dev_dbg(adev->dev, "MES fails on detecting hung queues\n"); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r = amdgpu_amdkfd_reset_mes_queue(adev, 0, queue_type, pipe, queue, + r = amdgpu_amdkfd_reset_mes_queue(adev, xcp_id, queue_type, pipe, queue,adev->gfx.mec.mes_hung_db_array[i]); if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, out:/* resume all will enable the non-hung queues */ - amdgpu_mes_resume(adev, 0); +amdgpu_mes_resume (adev ,xcc_id );/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue. drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0
drm/amd/amdgpu/amdgpu_gfx.h
index5939e1fb3b24..26bbec8f92e8100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence,struct
amdgpu_usermode_queue*uq,drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drm/amd/amdgpu/amdgpu_userq.c
index1a2aa85c504e..7dfe6e83f8ce100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0
amd/amdgpu/gfx_v11_0.c
index315dfd806d56..fdc0620ca67f100644drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print(struct
amdgpu_ip_block*ip_block,
structdrm_printer*p)drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0
amd/amdgpu/gfx_v12_0.c
indexd334fb805020..ec5ec1fd8b9d100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void
gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)(quoted diff) renamed from drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int reset_queues_mes(struct · line 508
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cindexce67e56efa8c..0eb4081a5740100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;
This one is also sending the xcc_id in queue input. This is the master xcc for the kfd node.
Thanks,
Lijo
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd = kfd_get_process_device_data(q->device, q->process);
RE: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
AMD General
Regards,
Amber
Quoted 51 lines · Lijo
Quoted 41 lines · Amber
AMD General
Regards,
AmberQuoted 21 lines · Lijo
Quoted 18 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that supports compute partitioning, we can identify the partition's node ID and
its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 ++++++++++++ +---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct · line 2473
Quoted 10 lines
drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drm/amd/amdgpu/amdgpu_gfx.c
index0c1c8ae822d4..ef34f7b02d0e100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,Ring carries
xcp_id. It's better to make use of the same (whenxcp_mgris also present).Quoted 6 lines
I need
xcp_id(for KFD) and masterxcc_id. When KFD calls this function, passing "structamdgpu_xcp" can get both data. ring is non- NULL only when this function is called by KCQ (and I don't find any function to retrieve masterxcc_idusingxcp_id). When KFD or gfx user queue calls this function, ring is NULL.
Quoted 3 lines
There is a queue input argument carrying
xcc_id(end of this patch). The same may be used for mes suspend etc. However, that doesn't cover xcp id.
Thank you Lijo for your review and feedback. True, the *faulty_queue_input argument used by KFD has the xcc_id info (lack of xcp_id so will still need to add "int xcp_id" argument), but I'm planning on code cleanup next, which will remove *faulty_queue_input argument.
Due to the fact this function is created to coordinate KFD, KCQ, and gfx user queue when each of them having their own data structure, we can't avoid those NULLs though I agree it's not easy to read from the caller. I tried to avoid adding more argument, but after looking into available data structures on KFD side and KGD side, I do believe adding xcp structure is the most generic approach to support KFD now and flexible if we need to support KCQ/gfx user queues in a multi-compute partition ASIC in the future. One thing I can improve would be adding one line comment in each caller like this (this is when the caller is gfx user queue):
/* adev, *xcp, *ring, *guilty_fence, *uq, *hung_queue_count, *faulty_queue_input */
r = amdgpu_gfx_reset_mes_compute(adev, NULL, NULL, NULL,
queue, NULL, NULL);
Quoted 153 lines
Quoted 128 lines
Quoted 128 lines
It's harder to read the caller locations with NULL, NULL....
Thanks,
LijoQuoted 123 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8
-0struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg(adev->dev, "Suspend all succeeds. xcc_id %d\n",
xcc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2503,7 +2512,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_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-Quoted 1 line
gfx.mec.mes_hung_db_array,
xcc_id);if (r) { dev_dbg(adev->dev, "MES fails on detecting hung queues\n"); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r = amdgpu_amdkfd_reset_mes_queue(adev, 0, queue_type, pipe, queue, + r = amdgpu_amdkfd_reset_mes_queue(adev, xcp_id, queue_type, pipe, queue,adev->gfx.mec.mes_hung_db_array[i]); if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, out:/* resume all will enable the non-hung queues */ - amdgpu_mes_resume(adev, 0); +amdgpu_mes_resume (adev ,xcc_id );/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue. drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0
drm/amd/amdgpu/amdgpu_gfx.h
index5939e1fb3b24..26bbec8f92e8100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence,struct
amdgpu_usermode_queue*uq,drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drm/amd/amdgpu/amdgpu_userq.c
index1a2aa85c504e..7dfe6e83f8ce100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0
amd/amdgpu/gfx_v11_0.c
index315dfd806d56..fdc0620ca67f100644drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print(struct
amdgpu_ip_block*ip_block,
structdrm_printer*p)drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0
amd/amdgpu/gfx_v12_0.c
indexd334fb805020..ec5ec1fd8b9d100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void
gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)(quoted diff) renamed from drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int reset_queues_mes(struct · line 508
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cindexce67e56efa8c..0eb4081a5740100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;This one is also sending the
xcc_idin queue input. This is the master xcc for the kfd node.Thanks,
LijoQuoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd = kfd_get_process_device_data(q->device, q->process);
Re: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
Quoted 60 lines · Amber
AMD General
Regards,
AmberQuoted 51 lines · Lijo
Quoted 41 lines · Amber
AMD General
Regards,
AmberQuoted 21 lines · Lijo
Quoted 18 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that supports compute partitioning, we can identify the partition's node ID and
its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 ++++++++++++ +---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct · line 2473
Quoted 10 lines
drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drm/amd/amdgpu/amdgpu_gfx.c
index0c1c8ae822d4..ef34f7b02d0e100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,Ring carries
xcp_id. It's better to make use of the same (whenxcp_mgris also present).Quoted 6 lines
I need
xcp_id(for KFD) and masterxcc_id. When KFD calls this function, passing "structamdgpu_xcp" can get both data. ring is non- NULL only when this function is called by KCQ (and I don't find any function to retrieve masterxcc_idusingxcp_id). When KFD or gfx user queue calls this function, ring is NULL.Quoted 3 lines
There is a queue input argument carrying
xcc_id(end of this patch). The same may be used for mes suspend etc. However, that doesn't cover xcp id.
Quoted 8 lines
Thank you Lijo for your review and feedback. True, the
*faulty_queue_inputargument used by KFD has thexcc_idinfo (lack ofxcp_idso will still need to add "intxcp_id" argument), but I'm planning on code cleanup next, which will remove*faulty_queue_inputargument.Due to the fact this function is created to coordinate KFD, KCQ, and gfx user queue when each of them having their own data structure, we can't avoid those NULLs though I agree it's not easy to read from the caller. I tried to avoid adding more argument, but after looking into available data structures on KFD side and KGD side, I do believe adding xcp structure is the most generic approach to support KFD now and flexible if we need to support KCQ/gfx user queues in a multi-compute partition ASIC in the future. One thing I can improve would be adding one line comment in each caller like this (this is when the caller is gfx user queue):
/* adev, *xcp, *ring,*guilty_fence, *uq,*hung_queue_count,*faulty_queue_input*/
r = amdgpu_gfx_reset_mes_compute(adev, NULL, NULL, NULL,queue, NULL, NULL);
Thanks for the details. I don't have any other comments.
If they are many arguments, in your cleanup phase, passing them as a struct (like reset_input) is better; easier to read what params are filled in.
Thanks,
Lijo
Quoted 153 lines
Quoted 153 lines
Quoted 128 lines
Quoted 128 lines
It's harder to read the caller locations with NULL, NULL....
Thanks,
LijoQuoted 123 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8
-0struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg(adev->dev, "Suspend all succeeds. xcc_id %d\n",
xcc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2503,7 +2512,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_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-Quoted 1 line
gfx.mec.mes_hung_db_array,
xcc_id);if (r) { dev_dbg(adev->dev, "MES fails on detecting hung queues\n"); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r = amdgpu_amdkfd_reset_mes_queue(adev, 0, queue_type, pipe, queue, + r = amdgpu_amdkfd_reset_mes_queue(adev, xcp_id, queue_type, pipe, queue,adev->gfx.mec.mes_hung_db_array[i]); if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, out:/* resume all will enable the non-hung queues */ - amdgpu_mes_resume(adev, 0); +amdgpu_mes_resume (adev ,xcc_id );/* Now CP is running again — replay backed-up commands and ring * doorbells on each reset queue. drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0
drm/amd/amdgpu/amdgpu_gfx.h
index5939e1fb3b24..26bbec8f92e8100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);int amdgpu_gfx_sysfs_init (struct amdgpu_device *adev);void amdgpu_gfx_sysfs_fini (struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence,struct
amdgpu_usermode_queue*uq,drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drm/amd/amdgpu/amdgpu_userq.c
index1a2aa85c504e..7dfe6e83f8ce100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0
amd/amdgpu/gfx_v11_0.c
index315dfd806d56..fdc0620ca67f100644drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print(struct
amdgpu_ip_block*ip_block,
structdrm_printer*p)drivers/gpu/drm/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0
amd/amdgpu/gfx_v12_0.c
indexd334fb805020..ec5ec1fd8b9d100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void
gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)(quoted diff) renamed from drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int reset_queues_mes(struct · line 508
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cindexce67e56efa8c..0eb4081a5740100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;This one is also sending the
xcc_idin queue input. This is the master xcc for the kfd node.Thanks,
LijoQuoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r =amdgpu_gfx_reset_mes_compute (adev, dqm->dev->xcp,NULL ,NULL ,NULL , &num_hung, &queue_input);if (r) goto fail; pdd = kfd_get_process_device_data(q->device, q->process);
RE: [PATCH v2 2/4] drm/amdgpu: Add xcp to reset_mes_compute function
AMD General
Regards,
Amber
Quoted 88 lines · Lijo
Quoted 82 lines · Amber
AMD General
Regards,
AmberQuoted 53 lines · Lijo
Quoted 43 lines · Amber
AMD General
Regards,
AmberQuoted 23 lines · Lijo
Quoted 20 lines · Amber Lin
Add xcp parameter to
amdgpu_gfx_reset_mes_compute()so on an ASIC that
supports compute partitioning, we can identify the partition's node ID
and
its master XCC. Pass this master XCC ID to MES when calling MES for suspend, detecting hung queues, and resume.Signed-off-by Amber Lin <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 17 ++++++++++++ +---- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_reset_mes_kcq(struct · line 2473
Quoted 10 lines
drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drm/amd/amdgpu/amdgpu_gfx.c
index0c1c8ae822d4..ef34f7b02d0e100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -2470,6 +2470,7 @@ static int amdgpu_gfx_reset_mes_kcq(struct amdgpu_device *adev, } int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, + struct amdgpu_xcp *xcp,Ring carries
xcp_id. It's better to make use of the same (whenxcp_mgris also present).Quoted 6 lines
I need
xcp_id(for KFD) and masterxcc_id. When KFD calls this function, passing "structamdgpu_xcp" can get both data. ring is non- NULL only when this function is called by KCQ (and I don't find any function to retrieve masterxcc_idusingxcp_id). When KFD or gfx user queue calls this function, ring is NULL.Quoted 4 lines
There is a queue input argument carrying
xcc_id(end of this patch). The same may be used for mes suspend etc. However, that doesn't cover xcp id.Thank you Lijo for your review and feedback. True, the
*faulty_queue_inputargument used by KFD has thexcc_idinfo (lack ofxcp_idso will still need to add "intxcp_id" argument), but I'm planning on code cleanup next, which will remove*faulty_queue_inputargument.Due to the fact this function is created to coordinate KFD, KCQ, and gfx user queue when each of them having their own data structure, we can't avoid those NULLs though I agree it's not easy to read from the caller. I tried to avoid adding more argument, but after looking into available data structures on KFD side and KGD side, I do believe adding xcp structure is the most generic approach to support KFD now and flexible if we need to support KCQ/gfx user queues in a multi- compute partition ASIC in the future.
One thing I can improve would be adding one line comment in each caller like this (this is when the caller is gfx user queue):
/* adev, *xcp, *ring,*guilty_fence, *uq,*hung_queue_count,*faulty_queue_input*/
r = amdgpu_gfx_reset_mes_compute(adev, NULL, NULL, NULL,Quoted 2 lines
queue, NULL, NULL);
Quoted 6 lines
Thanks for the details. I don't have any other comments.
If they are many arguments, in your cleanup phase, passing them as a struct (like
reset_input) is better; easier to read what params are filled in.
Good idea. I'll do that. Thank you for the suggestion.
Quoted 163 lines
Thanks,
LijoQuoted 159 lines
Quoted 159 lines
Quoted 133 lines
Quoted 133 lines
It's harder to read the caller locations with NULL, NULL....
Thanks,
LijoQuoted 128 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8
-0struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,@@ -2486,6 +2487,14 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, struct amdgpu_gfx_deferred_entry deferred_end[AMDGPU_MAX_COMPUTE_RINGS +1 ];int n_deferred =0 ;int ring_err; +uint32_t xcc_mask, xcc_id =0 , xcp_id =0 ; + +if (xcp) { +amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , &xcc_mask); +/* master xcc in the partition */ + xcc_id =ffs (xcc_mask) -1 ; + xcp_id = xcp->id; + }guard (mutex)(&adev->gfx.mec.reset_mutex);/* stop the drm schedulers for all compute queues */drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2493,7 +2502,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev,/* suspend all will determine which queues are hung. * reset detect will return the array of bad queue doorbells */ - r =amdgpu_mes_suspend (adev,0 ); + r =amdgpu_mes_suspend (adev, xcc_id);/* if suspend all success, it should no hang queue */ if (!r) {dev_dbg(adev->dev, "Suspend all succeeds. xcc_id %d\n",
xcc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2503,7 +2512,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_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-Quoted 1 line
gfx.mec.mes_hung_db_array,
xcc_id);if (r) { dev_dbg(adev->dev, "MES fails on detecting hung queues\n"); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2551,7 +2560,7 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, n_deferred++; }/* reset any KFD queues */ - r = amdgpu_amdkfd_reset_mes_queue(adev, 0, queue_type, pipe, queue, + r = amdgpu_amdkfd_reset_mes_queue(adev, xcp_id, queue_type, pipe, queue,adev->gfx.mec.mes_hung_db_array[i]); if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -2582,7 +2591,7 @@ int amdgpu_gfx_reset_mes_compute(structamdgpu_device *adev, out:/* resume all will enable the non-hung queues */ - amdgpu_mes_resume(adev, 0); +amdgpu_mes_resume (adev ,xcc_id );/* Now CP is running again — replay backed-up commands and ring
* doorbells on each reset queue.drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0
drm/amd/amdgpu/amdgpu_gfx.h
index5939e1fb3b24..26bbec8f92e8100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0@@ -664,6 +664,7 @@ bool amdgpu_gfx_is_master_xcc(struct
amdgpu_device*adev, int xcc_id); int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev); void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev); int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0+struct amdgpu_xcp *xcp, struct amdgpu_ring *ring, struct amdgpu_fence *guilty_fence, struct amdgpu_usermode_queue *uq,drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drm/amd/amdgpu/amdgpu_userq.c
index1a2aa85c504e..7dfe6e83f8ce100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -153,7 +153,7 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work)int r;if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , + r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue);drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0drm/
amd/amdgpu/gfx_v11_0.c
index315dfd806d56..fdc0620ca67f100644drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -6932,7 +6932,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void gfx_v11_ip_print(struct
amdgpu_ip_block*ip_block,
structdrm_printer*p)drivers/gpu/ renamed from drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0drm/
amd/amdgpu/gfx_v12_0.c
indexd334fb805020..ec5ec1fd8b9d100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -5254,7 +5254,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev; -return amdgpu_gfx_reset_mes_compute (adev, ring, timedout_fence, NULL, NULL, NULL); +return amdgpu_gfx_reset_mes_compute (adev,NULL , ring, timedout_fence,NULL ,NULL ,NULL ); }static void
gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)(quoted diff) renamed from drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int reset_queues_mes(struct · line 508
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cindexce67e56efa8c..0eb4081a5740100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -506,7 +506,7 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;This one is also sending the
xcc_idin queue input. This is the master xcc for the kfd node.Thanks,
LijoQuoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1/* pass the known bad queue info to the reset function */ - r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); + r = amdgpu_gfx_reset_mes_compute(adev, dqm->dev->xcp, NULL, NULL,NULL, &num_hung, &queue_input); if (r) goto fail; pdd = kfd_get_process_device_data(q->device, q->process);
PATCH v2 3/4 drm/amdgpu: No need of mutiple hung_queue_db_array
In reply to Amber LinAll queue resets (KCQ, user compute queue, and gfx user queue) are coordinated in amdgpu_reset_mes_compute function. The guard guarantees only one XCC can execute hung queues detection and reset at one time, so we don't need the number of XCCs copies of hung queue doorbell array.
Only MES pipe 0 performs the hung queue detection, so we also don't need to allocate multiple pipe copies of hung queue doorbell array.
One hung queue doorbell array is sufficient.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 43 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 6 ++-- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +21 -22
@@ -241,18 +241,16 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }if (adev->mes.hung_queue_db_array_size) { -for (i =0 ; i <AMDGPU_MAX_MES_PIPES * num_xcc; i++) { - r =amdgpu_bo_create_kernel (adev, - adev->mes.hung_queue_db_array_size *sizeof (u32), -PAGE_SIZE , -AMDGPU_GEM_DOMAIN_GTT , - &adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]); -if (r) { -dev_warn (adev->dev,"failed to create MES hung db array buffer (%d)" , r); - goto error_doorbell; - } + r =amdgpu_bo_create_kernel (adev, + adev->mes.hung_queue_db_array_size *sizeof (u32), +PAGE_SIZE , +AMDGPU_GEM_DOMAIN_GTT , + &adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr); +if (r) { +dev_warn (adev->dev,"failed to create MES hung db array buffer (%d)" , r); + goto error_doorbell; } adev->gfx.mec.mes_hung_db_array =
@@ -276,11 +274,11 @@ int amdgpu_mes_init(struct amdgpu_device *adev)if (adev->mes.query_status_fence_ptr[i])amdgpu_wb_free (adev, adev->mes.query_status_fence_offs[i]); -if (adev->mes.hung_queue_db_array_gpu_obj[i]) -amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]); } +if (adev->mes.hung_queue_db_array_gpu_obj) +amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr);ida_destroy (&adev->mes.doorbell_ida);mutex_destroy (&adev->mes.mutex_hidden);
@@ -300,11 +298,12 @@ void amdgpu_mes_fini(struct amdgpu_device *adev) &adev->mes.event_log_gpu_addr, &adev->mes.event_log_cpu_addr); +if (adev->mes.hung_queue_db_array_gpu_obj) +amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr); +for (i =0 ; i <AMDGPU_MAX_MES_PIPES * num_xcc; i++) { -if (adev->mes.hung_queue_db_array_gpu_obj[i]) -amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]);if (adev->mes.sch_ctx_ptr[i])amdgpu_wb_free (adev, adev->mes.sch_ctx_offs[i]);if (adev->mes.query_status_fence_ptr[i])
@@ -526,7 +525,7 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, uint32_t xcc_id) {struct mes_detect_and_reset_queue_input input; -u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr[xcc_id]; +u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr;int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i;if (!hung_db_num || !hung_db_array)
@@ -538,7 +537,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[xcc_id],AMDGPU_MES_INVALID_DB_OFFSET , +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;
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +3 -3
@@ -190,9 +190,9 @@ struct amdgpu_mes {int hung_queue_db_array_size;int hung_queue_hqd_info_offset; -struct amdgpu_bo *hung_queue_db_array_gpu_obj[AMDGPU_MAX_MES_INST_PIPES ]; -uint64_t hung_queue_db_array_gpu_addr[AMDGPU_MAX_MES_INST_PIPES ]; -void *hung_queue_db_array_cpu_addr[AMDGPU_MAX_MES_INST_PIPES ]; +struct amdgpu_bo *hung_queue_db_array_gpu_obj; +uint64_t hung_queue_db_array_gpu_addr; +void *hung_queue_db_array_cpu_addr;/* cooperative dispatch */ bool enable_coop_mode;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
@@ -1235,7 +1235,7 @@ static int mes_v11_0_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
@@ -1260,7 +1260,7 @@ static int mes_v12_0_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +1 -1
@@ -901,7 +901,7 @@ static int mes_v12_1_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;
Signature · 1 line
2.43.0
Re: [PATCH v2 3/4] drm/amdgpu: No need of mutiple hung_queue_db_array
ping
Quoted 159 lines · Amber Lin
All queue resets (KCQ, user compute queue, and gfx user queue) are coordinated in
amdgpu_reset_mes_computefunction. The guard guarantees only one XCC can execute hung queues detection and reset at one time, so we don't need the number of XCCs copies of hung queue doorbell array.Only MES pipe 0 performs the hung queue detection, so we also don't need to allocate multiple pipe copies of hung queue doorbell array.
One hung queue doorbell array is sufficient.
Signed-off-by Amber Lin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 43 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 6 ++-- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +21
-22@@ -241,18 +241,16 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }if (adev->mes.hung_queue_db_array_size) { -for (i =0 ; i <AMDGPU_MAX_MES_PIPES * num_xcc; i++) { - r =amdgpu_bo_create_kernel (adev, - adev->mes.hung_queue_db_array_size *sizeof (u32), -PAGE_SIZE , -AMDGPU_GEM_DOMAIN_GTT , - &adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]); -if (r) { -dev_warn (adev->dev,"failed to create MES hung db array buffer (%d)" , r); - goto error_doorbell; - } + r =amdgpu_bo_create_kernel (adev, + adev->mes.hung_queue_db_array_size *sizeof (u32), +PAGE_SIZE , +AMDGPU_GEM_DOMAIN_GTT , + &adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr); +if (r) { +dev_warn (adev->dev,"failed to create MES hung db array buffer (%d)" , r); + goto error_doorbell; } adev->gfx.mec.mes_hung_db_array =@@ -276,11 +274,11 @@ int amdgpu_mes_init(struct amdgpu_device *adev)if (adev->mes.query_status_fence_ptr[i])amdgpu_wb_free (adev, adev->mes.query_status_fence_offs[i]); -if (adev->mes.hung_queue_db_array_gpu_obj[i]) -amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]); } +if (adev->mes.hung_queue_db_array_gpu_obj) +amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr);ida_destroy (&adev->mes.doorbell_ida);mutex_destroy (&adev->mes.mutex_hidden);@@ -300,11 +298,12 @@ void amdgpu_mes_fini(struct amdgpu_device *adev) &adev->mes.event_log_gpu_addr, &adev->mes.event_log_cpu_addr); +if (adev->mes.hung_queue_db_array_gpu_obj) +amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj, + &adev->mes.hung_queue_db_array_gpu_addr, + &adev->mes.hung_queue_db_array_cpu_addr); +for (i =0 ; i <AMDGPU_MAX_MES_PIPES * num_xcc; i++) { -if (adev->mes.hung_queue_db_array_gpu_obj[i]) -amdgpu_bo_free_kernel (&adev->mes.hung_queue_db_array_gpu_obj[i], - &adev->mes.hung_queue_db_array_gpu_addr[i], - &adev->mes.hung_queue_db_array_cpu_addr[i]);if (adev->mes.sch_ctx_ptr[i])amdgpu_wb_free (adev, adev->mes.sch_ctx_offs[i]);if (adev->mes.query_status_fence_ptr[i])@@ -526,7 +525,7 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, uint32_t xcc_id) {struct mes_detect_and_reset_queue_input input; -u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr[xcc_id]; +u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr;int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i;if (!hung_db_num || !hung_db_array)@@ -538,7 +537,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[xcc_id],AMDGPU_MES_INVALID_DB_OFFSET , +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;drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +3
-3@@ -190,9 +190,9 @@ struct amdgpu_mes {int hung_queue_db_array_size;int hung_queue_hqd_info_offset; -struct amdgpu_bo *hung_queue_db_array_gpu_obj[AMDGPU_MAX_MES_INST_PIPES ]; -uint64_t hung_queue_db_array_gpu_addr[AMDGPU_MAX_MES_INST_PIPES ]; -void *hung_queue_db_array_cpu_addr[AMDGPU_MAX_MES_INST_PIPES ]; +struct amdgpu_bo *hung_queue_db_array_gpu_obj; +uint64_t hung_queue_db_array_gpu_addr; +void *hung_queue_db_array_cpu_addr;/* cooperative dispatch */ bool enable_coop_mode;drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1
-1@@ -1235,7 +1235,7 @@ static int mes_v11_0_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1
-1@@ -1260,7 +1260,7 @@ static int mes_v12_0_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +1
-1@@ -901,7 +901,7 @@ static int mes_v12_1_detect_and_reset_hung_queues(struct amdgpu_mes *mes, mes_reset_queue_pkt.queue_type =convert_to_mes_queue_type (input->queue_type); mes_reset_queue_pkt.doorbell_offset_addr = - mes->hung_queue_db_array_gpu_addr[0 ]; + mes->hung_queue_db_array_gpu_addr;if (input->detect_only) mes_reset_queue_pkt.hang_detect_only =1 ;
PATCH v2 4/4 drm/amdgpu: Correct hung queue number for reset
In reply to Amber LinIn an ASIC supporting multi-compute partitions, the number of queues varies with the compute partition mode. We need to adjust the hqd_info offset to get the correct hung queues doorbell offset and hqd_info.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +35 -14
@@ -108,6 +108,24 @@ static inline u32 amdgpu_mes_get_hqd_mask(u32 num_pipe,static void amdgpu_mes_userq_notify_unmap_work_handler (struct work_struct *work); +static int get_num_queues_per_xcp (struct amdgpu_device *adev,int num_xcps) +{ +int i, num_xcc = adev->gfx.xcc_mask ?NUM_XCC (adev->gfx.xcc_mask) :1 ; +u32 num_queues =0 ; + +for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) + num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); + +for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) + num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); + + num_xcc /= num_xcps; +for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) + num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + +return num_queues; +} +int amdgpu_mes_init (struct amdgpu_device *adev) {int i, r, num_pipes, num_queues =0 ;
@@ -222,21 +240,19 @@ int amdgpu_mes_init(struct amdgpu_device *adev) goto error_doorbell;if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 )) { -/* When queue/pipe reset is done in MES instead of in the -* driver, MES passes hung queues information to the driver in -* hung_queue_hqd_info. Calculate required space to store this -* information. +/* When queue/pipe reset is handled by MES instead of by the +* driver, driver provides the buffer for MES to store the hung +* queues information. Calculate required buffer size, which is +* the number of maximum queues. This number varies with compute +* partition mode. We allocate the biggest size, which is SPX, +* num_xcps = 1. */ -for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) - num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) - num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) - num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + num_queues =get_num_queues_per_xcp (adev,1 ); adev->mes.hung_queue_hqd_info_offset = num_queues; +/* Double num_queues. The first half is to store doorbell offset +* and the second half is to store hqd_info. +*/ adev->mes.hung_queue_db_array_size = num_queues *2 ; }
@@ -526,7 +542,8 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, {struct mes_detect_and_reset_queue_input input;u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr; -int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i; +int hqd_info_offset, r, i; +int num_xcps =1 ;if (!hung_db_num || !hung_db_array)return -EINVAL ;
@@ -551,9 +568,13 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,return r; } +if (adev->xcp_mgr) + num_xcps = adev->xcp_mgr->num_xcps; + hqd_info_offset =get_num_queues_per_xcp (adev, num_xcps); + *hung_db_num =0 ;/* MES passes hung queues' doorbell to driver */ -for (i =0 ; i < adev->mes.hung_queue_hqd_info_offset; i++) { +for (i =0 ; i < hqd_info_offset; i++) {/* Finding hung queues where db_array[i] is a valid doorbell */ if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) {dev_dbg (adev->dev,"MES: hung queue doorbell 0x%x\n" , db_array[i]);
Signature · 1 line
2.43.0
Re: [PATCH v2 4/4] drm/amdgpu: Correct hung queue number for reset
ping
Quoted 95 lines · Amber Lin
In an ASIC supporting multi-compute partitions, the number of queues varies with the compute partition mode. We need to adjust the
hqd_infooffset to get the correct hung queues doorbell offset andhqd_info.Signed-off-by Amber Lin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +35
-14@@ -108,6 +108,24 @@ static inline u32 amdgpu_mes_get_hqd_mask(u32 num_pipe,static void amdgpu_mes_userq_notify_unmap_work_handler (struct work_struct *work); +static int get_num_queues_per_xcp (struct amdgpu_device *adev,int num_xcps) +{ +int i, num_xcc = adev->gfx.xcc_mask ?NUM_XCC (adev->gfx.xcc_mask) :1 ; +u32 num_queues =0 ; + +for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) + num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); + +for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) + num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); + + num_xcc /= num_xcps; +for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) + num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + +return num_queues; +} +int amdgpu_mes_init (struct amdgpu_device *adev) {int i, r, num_pipes, num_queues =0 ;@@ -222,21 +240,19 @@ int amdgpu_mes_init(struct amdgpu_device *adev) goto error_doorbell;if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 )) { -/* When queue/pipe reset is done in MES instead of in the -* driver, MES passes hung queues information to the driver in -* hung_queue_hqd_info. Calculate required space to store this -* information. +/* When queue/pipe reset is handled by MES instead of by the +* driver, driver provides the buffer for MES to store the hung +* queues information. Calculate required buffer size, which is +* the number of maximum queues. This number varies with compute +* partition mode. We allocate the biggest size, which is SPX, +* num_xcps = 1. */ -for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) - num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) - num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) - num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + num_queues =get_num_queues_per_xcp (adev,1 ); adev->mes.hung_queue_hqd_info_offset = num_queues; +/* Double num_queues. The first half is to store doorbell offset +* and the second half is to store hqd_info. +*/ adev->mes.hung_queue_db_array_size = num_queues *2 ; }@@ -526,7 +542,8 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, {struct mes_detect_and_reset_queue_input input;u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr; -int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i; +int hqd_info_offset, r, i; +int num_xcps =1 ;if (!hung_db_num || !hung_db_array)return -EINVAL ;@@ -551,9 +568,13 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,return r; } +if (adev->xcp_mgr) + num_xcps = adev->xcp_mgr->num_xcps; + hqd_info_offset =get_num_queues_per_xcp (adev, num_xcps); + *hung_db_num =0 ;/* MES passes hung queues' doorbell to driver */ -for (i =0 ; i < adev->mes.hung_queue_hqd_info_offset; i++) { +for (i =0 ; i < hqd_info_offset; i++) {/* Finding hung queues where db_array[i] is a valid doorbell */ if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) {dev_dbg (adev->dev,"MES: hung queue doorbell 0x%x\n" , db_array[i]);
Re: [PATCH v2 4/4] drm/amdgpu: Correct hung queue number for reset
In reply to Amber LinQuoted 6 lines · Amber Lin
In an ASIC supporting multi-compute partitions, the number of queues varies with the compute partition mode. We need to adjust the
hqd_infooffset to get the correct hung queues doorbell offset andhqd_info.Signed-off-by Amber Lin <[email protected]>
Series is:
Quoted 93 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +35
-15@@ -108,6 +108,24 @@ static inline u32 amdgpu_mes_get_hqd_mask(u32 num_pipe,static void amdgpu_mes_userq_notify_unmap_work_handler (struct work_struct *work); +static int get_num_queues_per_xcp (struct amdgpu_device *adev,int num_xcps) +{ +int i, num_xcc = adev->gfx.xcc_mask ?NUM_XCC (adev->gfx.xcc_mask) :1 ; +u32 num_queues =0 ; + +for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) + num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); + +for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) + num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); + + num_xcc /= num_xcps; +for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) + num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + +return num_queues; +} +int amdgpu_mes_init (struct amdgpu_device *adev) {int i, r, num_pipes, num_queues =0 ;@@ -222,21 +240,19 @@ int amdgpu_mes_init(struct amdgpu_device *adev) goto error_doorbell;if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (11 ,0 ,0 )) { -/* When queue/pipe reset is done in MES instead of in the -* driver, MES passes hung queues information to the driver in -* hung_queue_hqd_info. Calculate required space to store this -* information. +/* When queue/pipe reset is handled by MES instead of by the +* driver, driver provides the buffer for MES to store the hung +* queues information. Calculate required buffer size, which is +* the number of maximum queues. This number varies with compute +* partition mode. We allocate the biggest size, which is SPX, +* num_xcps = 1. */ -for (i =0 ; i <AMDGPU_MES_MAX_GFX_PIPES ; i++) - num_queues +=hweight32 (adev->mes.gfx_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) - num_queues +=hweight32 (adev->mes.compute_hqd_mask[i]); - -for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) - num_queues +=hweight32 (adev->mes.sdma_hqd_mask[i]) * num_xcc; + num_queues =get_num_queues_per_xcp (adev,1 ); adev->mes.hung_queue_hqd_info_offset = num_queues; +/* Double num_queues. The first half is to store doorbell offset +* and the second half is to store hqd_info. +*/ adev->mes.hung_queue_db_array_size = num_queues *2 ; }@@ -526,7 +542,8 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev, {struct mes_detect_and_reset_queue_input input;u32 *db_array = adev->mes.hung_queue_db_array_cpu_addr; -int hqd_info_offset = adev->mes.hung_queue_hqd_info_offset, r, i; +int hqd_info_offset, r, i; +int num_xcps =1 ;if (!hung_db_num || !hung_db_array)return -EINVAL ;@@ -551,9 +568,13 @@ int amdgpu_mes_detect_and_reset_hung_queues(struct amdgpu_device *adev,return r; } +if (adev->xcp_mgr) + num_xcps = adev->xcp_mgr->num_xcps; + hqd_info_offset =get_num_queues_per_xcp (adev, num_xcps); + *hung_db_num =0 ;/* MES passes hung queues' doorbell to driver */ -for (i =0 ; i < adev->mes.hung_queue_hqd_info_offset; i++) { +for (i =0 ; i < hqd_info_offset; i++) {/* Finding hung queues where db_array[i] is a valid doorbell */ if (db_array[i] !=AMDGPU_MES_INVALID_DB_OFFSET ) {dev_dbg (adev->dev,"MES: hung queue doorbell 0x%x\n" , db_array[i]); --2.43.0