drm/amdgpu: read back register after written for VCN v4.0.5
Subsystems (3)
PATCH v4 1/1 drm/amdgpu: read back register after written for VCN v4.0.5
V4: add read-back for non-DPG case. This is for protection
purpose as it is not used for producton.
On VCN v4.0.5 there is a race condition where the WPTR is not updated after starting from idle when doorbell is used. Adding register read-back after written at function end is to ensure all register writes are done before they can be used.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +8 -0
@@ -1034,6 +1034,10 @@ static int vcn_v4_0_5_start_dpg_mode(struct amdgpu_vcn_inst *vinst, ring->doorbell_index <<VCN_RB1_DB_CTRL__OFFSET__SHIFT | VCN_RB1_DB_CTRL__EN_MASK); +/* Keeping one read-back to ensure all register writes are done, otherwise +* it may introduce race conditions */ +RREG32_SOC15 (VCN , inst_idx, regVCN_RB1_DB_CTRL); +return 0 ; }
@@ -1216,6 +1220,10 @@ static int vcn_v4_0_5_start(struct amdgpu_vcn_inst *vinst)WREG32_SOC15 (VCN , i, regVCN_RB_ENABLE, tmp); fw_shared->sq.queue_mode &= ~(FW_QUEUE_RING_RESET |FW_QUEUE_DPG_HOLD_OFF ); +/* Keeping one read-back to ensure all register writes are done, otherwise +* it may introduce race conditions */ +RREG32_SOC15 (VCN , i, regVCN_RB_ENABLE); +return 0 ; }
Signature · 1 line
2.34.1
Deucher, Alexander
maintainer Reviewed-by Reviewed-by Mario Limonciello Tested-by Mario Limonciello on v4 1/1[Public]
________________________________
From: Wu, David <[email protected]>
Sent: Tuesday, May 13, 2025 6:12 PM
To: [email protected] <[email protected]>; Koenig, Christian <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Liu, Leo <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; [email protected] <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH v4] drm/amdgpu: read back register after written for VCN v4.0.5
V4: add read-back for non-DPG case. This is for protection
purpose as it is not used for producton.
On VCN v4.0.5 there is a race condition where the WPTR is not updated after starting from idle when doorbell is used. Adding register read-back after written at function end is to ensure all register writes are done before they can be used.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +8 -0
@@ -1034,6 +1034,10 @@ static int vcn_v4_0_5_start_dpg_mode(struct amdgpu_vcn_inst *vinst, ring->doorbell_index <<VCN_RB1_DB_CTRL__OFFSET__SHIFT | VCN_RB1_DB_CTRL__EN_MASK); +/* Keeping one read-back to ensure all register writes are done, otherwise +* it may introduce race conditions */ +RREG32_SOC15 (VCN , inst_idx, regVCN_RB1_DB_CTRL); +return 0 ; }
@@ -1216,6 +1220,10 @@ static int vcn_v4_0_5_start(struct amdgpu_vcn_inst *vinst)WREG32_SOC15 (VCN , i, regVCN_RB_ENABLE, tmp); fw_shared->sq.queue_mode &= ~(FW_QUEUE_RING_RESET |FW_QUEUE_DPG_HOLD_OFF ); +/* Keeping one read-back to ensure all register writes are done, otherwise +* it may introduce race conditions */ +RREG32_SOC15 (VCN , i, regVCN_RB_ENABLE); +return 0 ; }
--
2.34.1