Skip to content

Commit 8b22f04

Browse files
victorlu-amdalexdeucher
authored andcommitted
drm/amdgpu: clear RB_OVERFLOW bit when enabling interrupts for vega20_ih
Port this change to vega20_ih.c: commit afbf795 ("drm/amdgpu: clear RB_OVERFLOW bit when enabling interrupts") Original commit message: "Why: Setting IH_RB_WPTR register to 0 will not clear the RB_OVERFLOW bit if RB_ENABLE is not set. How to fix: Set WPTR_OVERFLOW_CLEAR bit after RB_ENABLE bit is set. The RB_ENABLE bit is required to be set, together with WPTR_OVERFLOW_ENABLE bit so that setting WPTR_OVERFLOW_CLEAR bit would clear the RB_OVERFLOW." Signed-off-by: Victor Lu <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 0016e87 commit 8b22f04

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/gpu/drm/amd/amdgpu/vega20_ih.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,33 @@ static int vega20_ih_toggle_ring_interrupts(struct amdgpu_device *adev,
114114
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, RB_ENABLE, (enable ? 1 : 0));
115115
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, RB_GPU_TS_ENABLE, 1);
116116

117+
if (enable) {
118+
/* Unset the CLEAR_OVERFLOW bit to make sure the next step
119+
* is switching the bit from 0 to 1
120+
*/
121+
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0);
122+
if (amdgpu_sriov_vf(adev) && amdgpu_sriov_reg_indirect_ih(adev)) {
123+
if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp))
124+
return -ETIMEDOUT;
125+
} else {
126+
WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp);
127+
}
128+
129+
/* Clear RB_OVERFLOW bit */
130+
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1);
131+
if (amdgpu_sriov_vf(adev) && amdgpu_sriov_reg_indirect_ih(adev)) {
132+
if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp))
133+
return -ETIMEDOUT;
134+
} else {
135+
WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp);
136+
}
137+
138+
/* Unset the CLEAR_OVERFLOW bit immediately so new overflows
139+
* can be detected.
140+
*/
141+
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0);
142+
}
143+
117144
/* enable_intr field is only valid in ring0 */
118145
if (ih == &adev->irq.ih)
119146
tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, ENABLE_INTR, (enable ? 1 : 0));

0 commit comments

Comments
 (0)