[PATCH 051/109] drm/amd/ras: Add gpu rma exception handling
Alex Deucher <[email protected]>
| Newsgroups | org.freedesktop.lists.amd-gfx |
|---|---|
| Message-ID | <[email protected]> |
From: YiPeng Chai <[email protected]> Add gpu rma exception handling. Signed-off-by: YiPeng Chai <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]> --- drivers/gpu/drm/amd/ras/core/core.c | 3 +++ drivers/gpu/drm/amd/ras/core/ras_process.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/ras/core/core.c b/drivers/gpu/drm/amd/ras/core/core.c index 8a8f5134fdac7..f093f29635888 100644 --- a/drivers/gpu/drm/amd/ras/core/core.c +++ b/drivers/gpu/drm/amd/ras/core/core.c @@ -287,6 +287,9 @@ static int ras_core_eeprom_recovery(struct ras_core_context *ras_core) return ret; } + if (ras_eeprom_mgr_get_gpu_op_status(ras_core) == RAS_GPU_OP_STATUS_RMA) + return -EPERM; + return ret; } diff --git a/drivers/gpu/drm/amd/ras/core/ras_process.c b/drivers/gpu/drm/amd/ras/core/ras_process.c index dd4a4c5673bdd..e7f95a82fb901 100644 --- a/drivers/gpu/drm/amd/ras/core/ras_process.c +++ b/drivers/gpu/drm/amd/ras/core/ras_process.c @@ -173,6 +173,14 @@ int ras_process_handle_ras_event(struct ras_core_context *ras_core) if (ras_eeprom_mgr_fw_record_enabled(ras_core)) ras_umc_dump_fw_records(ras_core); + if (ras_eeprom_mgr_get_gpu_op_status(ras_core) == RAS_GPU_OP_STATUS_RMA) { + uint32_t rma_reset = GPU_RESET_CAUSE_RMA; + + RAS_DEV_ERR(ras_core->dev, "Device is RMA, stop gpu work!\n"); + ras_core_event_notify(ras_core, RAS_EVENT_ID__RESET_GPU, &rma_reset); + return -ERESTART; + } + do { umc_event_count = atomic_read(&ras_proc->umc_interrupt_count); ret = ras_process_umc_event(ras_core, umc_event_count); @@ -210,6 +218,7 @@ static int ras_process_thread(void *context) { struct ras_core_context *ras_core = (struct ras_core_context *)context; struct ras_process *ras_proc = &ras_core->ras_proc; + int ret; while (!kthread_should_stop()) { ras_wait_event_interruptible_timeout(&ras_proc->ras_process_wq, @@ -228,9 +237,13 @@ static int ras_process_thread(void *context) continue; if (ras_core->sys_fn && ras_core->sys_fn->async_handle_ras_event) - ras_core->sys_fn->async_handle_ras_event(ras_core, NULL); + ret = ras_core->sys_fn->async_handle_ras_event(ras_core, NULL); else - ras_process_handle_ras_event(ras_core); + ret = ras_process_handle_ras_event(ras_core); + + /* GPU Device is RMA */ + if (ret == -ERESTART) + break; } return 0; -- 2.55.0