drm/amd/ras: add device lost check to early exit psp cmd wait loop
Subsystems (2)
PATCH 1/1 drm/amd/ras: add device lost check to early exit psp cmd wait loop
Add device lost status check in PSP fence wait loop to exit polling early when GPU device lost
Signed-off-by Ce Sun <[email protected]>
--- drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c | 3 +++ drivers/gpu/drm/amd/ras/rascore/ras.h | 2 ++ drivers/gpu/drm/amd/ras/rascore/ras_core.c | 14 ++++++++++++++ drivers/gpu/drm/amd/ras/rascore/ras_psp.c | 3 +++ 4 files changed, 22 insertions(+)
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c +3 -0
@@ -171,6 +171,9 @@ static int amdgpu_ras_sys_check_gpu_status(struct ras_core_context *ras_core,if (amdgpu_in_reset (adev) ||amdgpu_ras_in_recovery (adev)) gpu_status |=RAS_GPU_STATUS__IN_RESET ; +if (amdgpu_device_bus_status_check (adev)) + gpu_status |=RAS_GPU_STATUS__DEVICE_LOST ; +if (amdgpu_sriov_vf (adev)) gpu_status |=RAS_GPU_STATUS__IS_VF ;
drivers/gpu/drm/amd/ras/rascore/ras.h +2 -0
@@ -137,6 +137,7 @@ enum ras_gpu_status {RAS_GPU_STATUS__IN_RESET =0x2 ,RAS_GPU_STATUS__IS_RMA =0x4 ,RAS_GPU_STATUS__IS_VF =0x8 , + RAS_GPU_STATUS__DEVICE_LOST = 0x10, }; enum ras_fw_eeprom_cmd {
@@ -371,6 +372,7 @@ int ras_core_query_block_ecc_data(struct ras_core_context *ras_core,bool ras_core_gpu_in_reset (struct ras_core_context *ras_core);bool ras_core_gpu_is_rma (struct ras_core_context *ras_core);bool ras_core_gpu_is_vf (struct ras_core_context *ras_core); +bool ras_core_gpu_device_lost (struct ras_core_context *ras_core);bool ras_core_handle_nbio_irq (struct ras_core_context *ras_core,void *data);int ras_core_handle_fatal_error (struct ras_core_context *ras_core);
drivers/gpu/drm/amd/ras/rascore/ras_core.c +14 -0
@@ -143,6 +143,20 @@ bool ras_core_gpu_is_vf(struct ras_core_context *ras_core)return (status &RAS_GPU_STATUS__IS_VF ) ? true : false; } +bool ras_core_gpu_device_lost (struct ras_core_context *ras_core) +{ +uint32_t status =0 ; + +if (!ras_core) +return false; + +if (ras_core->sys_fn && + ras_core->sys_fn->check_gpu_status) + ras_core->sys_fn->check_gpu_status (ras_core, &status); + +return (status &RAS_GPU_STATUS__DEVICE_LOST ) ? true : false; +} +bool ras_core_gpu_is_rma (struct ras_core_context *ras_core) {if (!ras_core)
drivers/gpu/drm/amd/ras/rascore/ras_psp.c +3 -0
@@ -294,6 +294,9 @@ static int send_psp_cmd(struct ras_core_context *ras_core, psp_ctx->in_fence_value) {if (--timeout ==0 )break ; + +if (ras_core_gpu_device_lost (ras_core)) +break ;/* * Shouldn't wait for timeout when err_event_athub occurs, * because gpu reset thread triggered and lock resource should
Signature · 1 line
2.34.1
Quoted 3 lines · Ce Sun
Add device lost status check in PSP fence wait loop to exit polling early when GPU device lost
You may add a bit more context like -
'During some error injection scenarios through ras ta, device could be lost from bus due to DPC. Add device lost status check in PSP fence wait loop to exit polling early.'
Quoted 1 line
Signed-off-by Ce Sun <[email protected]>
Reviewed-by Lijo Lazar <[email protected]>
Thanks,
Lijo
Quoted 80 lines
--- drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c | 3 +++ drivers/gpu/drm/amd/ras/rascore/ras.h | 2 ++ drivers/gpu/drm/amd/ras/rascore/ras_core.c | 14 ++++++++++++++ drivers/gpu/drm/amd/ras/rascore/ras_psp.c | 3 +++ 4 files changed, 22 insertions(+)drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c +3
-0@@ -171,6 +171,9 @@ static int amdgpu_ras_sys_check_gpu_status(struct ras_core_context *ras_core,if (amdgpu_in_reset (adev) ||amdgpu_ras_in_recovery (adev)) gpu_status |=RAS_GPU_STATUS__IN_RESET ; +if (amdgpu_device_bus_status_check (adev)) + gpu_status |=RAS_GPU_STATUS__DEVICE_LOST ; +if (amdgpu_sriov_vf (adev)) gpu_status |=RAS_GPU_STATUS__IS_VF ;drivers/gpu/drm/amd/ras/rascore/ras.h +2
-0@@ -137,6 +137,7 @@ enum ras_gpu_status {RAS_GPU_STATUS__IN_RESET =0x2 ,RAS_GPU_STATUS__IS_RMA =0x4 ,RAS_GPU_STATUS__IS_VF =0x8 , + RAS_GPU_STATUS__DEVICE_LOST = 0x10, }; enum ras_fw_eeprom_cmd {@@ -371,6 +372,7 @@ int ras_core_query_block_ecc_data(struct ras_core_context *ras_core,bool ras_core_gpu_in_reset (struct ras_core_context *ras_core);bool ras_core_gpu_is_rma (struct ras_core_context *ras_core);bool ras_core_gpu_is_vf (struct ras_core_context *ras_core); +bool ras_core_gpu_device_lost (struct ras_core_context *ras_core);bool ras_core_handle_nbio_irq (struct ras_core_context *ras_core,void *data);int ras_core_handle_fatal_error (struct ras_core_context *ras_core);drivers/gpu/drm/amd/ras/rascore/ras_core.c +14
-0@@ -143,6 +143,20 @@ bool ras_core_gpu_is_vf(struct ras_core_context *ras_core)return (status &RAS_GPU_STATUS__IS_VF ) ? true : false; } +bool ras_core_gpu_device_lost (struct ras_core_context *ras_core) +{ +uint32_t status =0 ; + +if (!ras_core) +return false; + +if (ras_core->sys_fn && + ras_core->sys_fn->check_gpu_status) + ras_core->sys_fn->check_gpu_status (ras_core, &status); + +return (status &RAS_GPU_STATUS__DEVICE_LOST ) ? true : false; +} +bool ras_core_gpu_is_rma (struct ras_core_context *ras_core) {if (!ras_core)drivers/gpu/drm/amd/ras/rascore/ras_psp.c +3
-0@@ -294,6 +294,9 @@ static int send_psp_cmd(struct ras_core_context *ras_core, psp_ctx->in_fence_value) {if (--timeout ==0 )break ; + +if (ras_core_gpu_device_lost (ras_core)) +break ;/* * Shouldn't wait for timeout when err_event_athub occurs, * because gpu reset thread triggered and lock resource should