Skip to contentSkip to conversation

drm/amdgpu: read back register after written for VCN v4.0.5

PATCH Superseded David (Ming Qiang) Wu 2 participants 4 messages May 13, 2025

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 drm/amdgpu: read back register after written for VCN v4.0.5

V2: not to add extra read-back in vcn_v4_0_5_start as there is a
read-back already. New comment for better understanding.

On VCN v4.0.5 there is a race condition where the WPTR is not updated after starting from idle when doorbell is used. The read-back of regVCN_RB1_DB_CTRL register after written is to ensure the doorbell_index is updated before it can work properly.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +4 -0
index ed00d35039c1..e55b76d71367 100644
@@ -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;
 }
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/3 drm/amdgpu: read back register after written for VCN v4.0.0

V3: patch for VCN v4.0.0 only

Similar to the previous changes made for VCN v4.0.5, the addition of register read-back support in VCN v4.0.0 is intended to prevent potential race conditions, even though such issues have not been observed yet. This change ensures consistency across different VCN variants and helps avoid similar issues on newer or closely related GPUs. The overhead introduced by this read-back is negligible.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +4 -0
index 8fff470bce87..070a2a8cdf6f 100644
@@ -1122,6 +1122,10 @@ static int vcn_v4_0_start_dpg_mode(struct amdgpu_vcn_inst *vinst, bool indirect)
 			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;
 }
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 3/3 drm/amdgpu: read back register after written for VCN v5.0.0

In reply to David (Ming Qiang) Wu

V3: patch for VCN v5.0.0 only

Similar to the previous changes made for VCN v4.0.5, the addition of register read-back support in VCN v5.0.0 is intended to prevent potential race conditions, even though such issues have not been observed yet. This change ensures consistency across different VCN variants and helps avoid similar issues on newer or closely related GPUs. The overhead introduced by this read-back is negligible.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c +4 -0
index 27dcc6f37a73..77c27a317e4c 100644
@@ -794,6 +794,10 @@ static int vcn_v5_0_0_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;
 }
 
Signature · 1 line
2.34.1
Reviewed-by Reviewed-by Mario Limonciello on v3 3/3
#3 lore raw

RE: [PATCH v3 3/3] drm/amdgpu: read back register after written for VCN v5.0.0

[AMD Official Use Only - AMD Internal Distribution Only]

The series is

-----Original Message-----
From: Wu, David <[email protected]>
Sent: Tuesday, May 13, 2025 3:22 PM
To: [email protected]; Koenig, Christian <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Liu, Leo <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH v3 3/3] drm/amdgpu: read back register after written for VCN v5.0.0

V3: patch for VCN v5.0.0 only

Similar to the previous changes made for VCN v4.0.5, the addition of register read-back support in VCN v5.0.0 is intended to prevent potential race conditions, even though such issues have not been observed yet. This change ensures consistency across different VCN variants and helps avoid similar issues on newer or closely related GPUs. The overhead introduced by this read-back is negligible.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c +4 -0
index 27dcc6f37a73..77c27a317e4c 100644
@@ -794,6 +794,10 @@ static int vcn_v5_0_0_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;
 }
 

--
2.34.1