drm/amdgpu: add variable to record gpu reset reason
Subsystems (3)
PATCH 1/3 drm/amdgpu: add variable to record gpu reset reason
Add variable to record gpu reset reason.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 3 +++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +3 -0
@@ -385,6 +385,9 @@ struct amdgpu_ras {/* Indicates smu whether need update bad channel info */ bool update_channel_flag; + +/* gpu reset caused by gfx poison */ +bool reset_by_gfx_poison; };struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c +5 -1
@@ -84,8 +84,12 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,/* Workaround: when vmid and pasid are both zero, trigger gpu reset in KGD. */ if (entry && (entry->client_id ==SOC21_IH_CLIENTID_GFX ) && (entry->src_id ==GFX_11_0_0__SRCID__RLC_GC_FED_INTERRUPT ) && - !entry->vmid && !entry->pasid) + !entry->vmid && !entry->pasid) { +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); + + ras->reset_by_gfx_poison = true;amdgpu_ras_reset_gpu (adev); + }return 0 ; }
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu: don't output mes error message when gfx hang during gpu reset
This patch is to clear the invalid mes error message when gfx ras poison consumption causes gpu reset on gfx v11_0_3.
[Why]:
Gfx ras poison consumption will cause gfx hang, and gfx hang will cause mes to fail to run, and gfx can not be recovered until gpu reset complete. So the mes error message before the gpu reset completes is invalid. Since the gpu reset has already started, these mes error messages are easily misinterpreted.
[How]:
Since mes depends on gfx, when mes fails to submit a packet during gpu reset, it will first check the gfx status to decide whether to output an error message. This check is only used during gpu reset.
MES error message during gpu reset:
[ 389.803015] amdgpu 0000:63:00.0: amdgpu: GPU reset begin! [ 389.913909] [drm:mes_v11_0_submit_pkt_and_poll_completion.constprop.0 [amdgpu]] *ERROR* MES failed to response msg=3 [ 389.914104] amdgpu: failed to remove hardware queue from MES, doorbell=0x1000 [ 389.914117] amdgpu: MES might be in unrecoverable state, issue a GPU reset [ 389.914128] amdgpu: Failed to evict queue 0 [ 389.914136] amdgpu: Failed to evict process queues [ 389.914145] amdgpu: Failed to suspend process 0x8001 [ 390.922077] amdgpu 0000:63:00.0: amdgpu: IP block:gfx_v11_0 is hung! [ 390.923519] [drm] kiq ring mec 3 pipe 1 q 0 [ 390.924573] amdkcl: cancel_work function is not supported [ 390.931057] amdgpu 0000:63:00.0: amdgpu: recover vram bo from shadow start [ 390.931060] amdgpu 0000:63:00.0: amdgpu: recover vram bo from shadow done [ 390.931067] amdgpu 0000:63:00.0: amdgpu: GPU reset(1) succeeded!
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 3 +++ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 13 ++++++++----- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 7 +++++-- 6 files changed, 29 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1434,6 +1434,8 @@ int amdgpu_device_set_cg_state(struct amdgpu_device *adev,int amdgpu_device_set_pg_state (struct amdgpu_device *adev,enum amd_powergating_state state); +bool amdgpu_device_check_gfx_status_in_reset (struct amdgpu_device *adev); +static inline bool amdgpu_device_has_timeouts_enabled (struct amdgpu_device *adev) { return amdgpu_gpu_recovery != 0 &&
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -0
@@ -6059,3 +6059,13 @@ bool amdgpu_device_has_display_hardware(struct amdgpu_device *adev)return true; } } + +bool amdgpu_device_check_gfx_status_in_reset (struct amdgpu_device *adev) +{ +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); + +if (!amdgpu_in_reset (adev)) +return false; + +return ras->reset_by_gfx_poison ? true : false; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -1
@@ -818,7 +818,7 @@ int amdgpu_mes_unmap_legacy_queue(struct amdgpu_device *adev, queue_input.trail_fence_data = seq; r = adev->mes.funcs->unmap_legacy_queue (&adev->mes, &queue_input); -if (r) +if (r && (r != -EREMOTEIO ))DRM_ERROR ("failed to unmap legacy queue\n" );return r;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +3 -0
@@ -129,6 +129,9 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, r =amdgpu_fence_wait_polling (ring, ring->fence_drv.sync_seq, timeout);if (r <1 ) { +if (amdgpu_device_check_gfx_status_in_reset (adev)) +return -EREMOTEIO ; +DRM_ERROR ("MES failed to response msg=%d\n" , x_pkt->header.opcode);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +8 -5
@@ -257,9 +257,11 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q,amdgpu_mes_unlock (&adev->mes);if (r) { -pr_err ("failed to remove hardware queue from MES, doorbell=0x%x\n" , - q->properties.doorbell_off); -pr_err ("MES might be in unrecoverable state, issue a GPU reset\n" ); +if (r != -EREMOTEIO ) { +pr_err ("failed to remove hardware queue from MES, doorbell=0x%x\n" , + q->properties.doorbell_off); +pr_err ("MES might be in unrecoverable state, issue a GPU reset\n" ); + }kfd_hws_hang (dqm); }
@@ -996,8 +998,9 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,if (dqm->dev->shared_resources.enable_mes) { retval =remove_queue_mes (dqm, q, qpd);if (retval) { -pr_err ("Failed to evict queue %d\n" , - q->properties.queue_id); +if (retval != -EREMOTEIO ) +pr_err ("Failed to evict queue %d\n" , + q->properties.queue_id); goto out; } }
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5 -2
@@ -1821,7 +1821,8 @@ int kfd_process_evict_queues(struct kfd_process *p, uint32_t trigger)* them been add back since they actually not be saved right now. */ if (r && r != -EIO ) { -pr_err ("Failed to evict process queues\n" ); +if (r != -EREMOTEIO ) +pr_err ("Failed to evict process queues\n" ); goto fail; } n_evicted++;
@@ -1984,13 +1985,15 @@ void kfd_suspend_all_processes(void)struct kfd_process *p;unsigned int temp;int idx =srcu_read_lock (&kfd_processes_srcu); +int ret =0 ;WARN (debug_evictions,"Evicting all processes" );hash_for_each_rcu (kfd_processes_table, temp, p, kfd_processes) {cancel_delayed_work_sync (&p->eviction_work);cancel_delayed_work_sync (&p->restore_work); -if (kfd_process_evict_queues (p,KFD_QUEUE_EVICTION_TRIGGER_SUSPEND )) + ret =kfd_process_evict_queues (p,KFD_QUEUE_EVICTION_TRIGGER_SUSPEND ); +if (ret && (ret != -EREMOTEIO ))pr_err ("Failed to suspend process 0x%x\n" , p->pasid);dma_fence_signal (p->ef);dma_fence_put (p->ef);
Signature · 1 line
2.34.1
PATCH 3/3 drm/amdgpu: adjust gpu reset sequence for gfx v11_0_3
In reply to YiPeng ChaiWhen gfx ras poison consumption causes gpu reset on gfx v11_0_3, the sequence of gpu reset is "soft reset -> mode2 reset -> mode1 reset". If the previous reset fails, fall back to the next reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 40 ++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +30 -10
@@ -4770,13 +4770,6 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,if (job && job->vm)drm_sched_increase_karma (&job->base); - r =amdgpu_reset_prepare_hwcontext (adev, reset_context); -/* If reset handler not implemented, continue; otherwise return */ -if (r == -ENOSYS ) - r =0 ; -else -return r; -/* Don't suspend on bare metal if we are not going to HW reset the ASIC */ if (!amdgpu_sriov_vf (adev)) {
@@ -4789,12 +4782,23 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, r =amdgpu_device_ip_soft_reset (adev);amdgpu_device_ip_post_soft_reset (adev);if (r ||amdgpu_device_ip_check_soft_reset (adev)) { -dev_info (adev->dev,"soft reset failed, will fallback to full reset!\n" ); +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); + +if (ras->reset_by_gfx_poison) { + reset_context->method =AMD_RESET_METHOD_MODE2 ; +dev_info (adev->dev,"soft reset failed, will fallback to mode2 reset!\n" ); + }else { +dev_info (adev->dev,"soft reset failed, will fallback to full reset!\n" ); + } need_full_reset = true; } } -if (need_full_reset) +/* IP suspend will affect mode2 reset, so ip suspend is skipped +* when mode2 reset is enabled. +*/ +if (need_full_reset && + (reset_context->method !=AMD_RESET_METHOD_MODE2 )) r =amdgpu_device_ip_suspend (adev);if (need_full_reset)set_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags);
@@ -4803,6 +4807,11 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, &reset_context->flags); } + r =amdgpu_reset_prepare_hwcontext (adev, reset_context); +/* If reset handler not implemented, continue; otherwise return */ +if (r == -ENOSYS ) + r =0 ; +return r; }
@@ -4892,7 +4901,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,/* If reset handler not implemented, continue; otherwise return */ if (r == -ENOSYS ) r =0 ; -else +else if (!r)/* Mode2 reset successful, return */ return r;/* Reset handler not implemented, use the default method */
@@ -4904,6 +4913,17 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,test_bit (AMDGPU_RESET_FOR_DEVICE_REMOVE , &reset_context->flags) &&test_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags); +/* If mode2 reset is enabled, ip suspend is skipped in previous +* amdgpu_device_pre_asic_reset function. but for mode1 reset, +* ip suspend must be called. +*/ +if (need_full_reset && + (reset_context->method ==AMD_RESET_METHOD_MODE2 )) { +list_for_each_entry (tmp_adev, device_list_handle, reset_list) { +amdgpu_device_ip_suspend (tmp_adev); + } + } +/* * ASIC reset has to be done on all XGMI hive nodes ASAP * to allow proper links negotiation in FW (within 1 sec)
Signature · 1 line
2.34.1