drm/amdgpu: clear RB_OVERFLOW bit if detected when enabling interrupts
Subsystems (2)
PATCH 1/1 drm/amdgpu: clear RB_OVERFLOW bit if detected when enabling interrupts
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.
--- drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +23 -0
@@ -135,6 +135,29 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, tmp =RREG32 (ih_regs->ih_rb_cntl); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,RB_ENABLE , (enable ?1 :0 )); + +if (enable &®_GET_FIELD (RREG32_NO_KIQ (ih_regs->ih_rb_wptr),IH_RB_WPTR ,RB_OVERFLOW )) { +/* Clear RB_OVERFLOW bit if detected */ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 ); +if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + +/* Unset the CLEAR_OVERFLOW bit immediately so new overflows +* can be detected. +*/ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,0 ); +if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + } +/* enable_intr field is only valid in ring0 */ if (ih == &adev->irq.ih) tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,ENABLE_INTR , (enable ?1 :0 ));
Signature · 1 line
2.34.1
Am 24.06.24 um 08:58 schrieb Danijel Slivka:
Quoted 20 lines
Why:
SettingIH_RB_WPTRregister to 0 will not clear theRB_OVERFLOWbit ifRB_ENABLEis not set.How to fix:
SetWPTR_OVERFLOW_CLEARbit afterRB_ENABLEbit is set. TheRB_ENABLEbit is required to be set, together withWPTR_OVERFLOW_ENABLEbit so that settingWPTR_OVERFLOW_CLEARbit would clear theRB_OVERFLOW.Signed-off-by Danijel Slivka <[email protected]>--- drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, · line 139
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +2
-0@@ -135,6 +135,29 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, tmp =RREG32 (ih_regs->ih_rb_cntl); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,RB_ENABLE , (enable ?1 :0 )); + +if (enable &®_GET_FIELD (RREG32_NO_KIQ (ih_regs->ih_rb_wptr),IH_RB_WPTR ,RB_OVERFLOW )) {
Please completely drop that extra read of the WPTR and just always try to clear the overflow bit.
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, · line 141
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +2
-0+/* Clear RB_OVERFLOW bit if detected */ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 );
I think we should have a sequence which writes 0, then 1 and then 0 again.
Apart from that looks good to me.
Regards,
Christian.
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +19
-0+if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + +/* Unset the CLEAR_OVERFLOW bit immediately so new overflows +* can be detected. +*/ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,0 ); +if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + } +/* enable_intr field is only valid in ring0 */ if (ih == &adev->irq.ih) tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,ENABLE_INTR , (enable ?1 :0 ));
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 33 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, June 24, 2024 11:31 AM
To: Slivka, Danijel <[email protected]>; [email protected]; Prica, Nikola <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: clearRB_OVERFLOWbit if detected when enabling interruptsAm 24.06.24 um 08:58 schrieb Danijel Slivka:
Quoted 8 lines
Why:
SettingIH_RB_WPTRregister to 0 will not clear theRB_OVERFLOWbit ifRB_ENABLEis not set.How to fix:
SetWPTR_OVERFLOW_CLEARbit afterRB_ENABLEbit is set. TheRB_ENABLEbit is required to be set, together withWPTR_OVERFLOW_ENABLEbit so that settingWPTR_OVERFLOW_CLEARbitwould
Quoted 15 lines
clear the
RB_OVERFLOW.Signed-off-by Danijel Slivka <[email protected]>--- drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +0
-0@@ -135,6 +135,29 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +3
-0tmp =RREG32 (ih_regs->ih_rb_cntl); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,RB_ENABLE , (enable ?1 :0 )); + +if (enable &®_GET_FIELD (RREG32_NO_KIQ (ih_regs->ih_rb_wptr), +IH_RB_WPTR ,RB_OVERFLOW )) {Please completely drop that extra read of the WPTR and just always try to clear the overflow bit.
Done and changed the commit message accordingly. Sent out new patch.
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct · line 143
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +2
-0+/* Clear RB_OVERFLOW bit if detected */ + tmp = REG_SET_FIELD(tmp, IH_RB_CNTL,
WPTR_OVERFLOW_CLEAR, 1);I think we should have a sequence which writes 0, then 1 and then 0 again.
Done.
Quoted 33 lines
Apart from that looks good to me.
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct · line 144
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +1
-0+ if (amdgpu_sriov_vf(adev) &&
amdgpu_sriov_reg_indirect_ih(adev)) {drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct · line 145
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +1
-0+ if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id,tmp))
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +6
-0+return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + +/* Unset the CLEAR_OVERFLOW bit immediately so new overflows
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +3
-0+* can be detected. +*/ + tmp = REG_SET_FIELD(tmp, IH_RB_CNTL,
WPTR_OVERFLOW_CLEAR, 0);drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct · line 155
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +1
-0+ if (amdgpu_sriov_vf(adev) &&
amdgpu_sriov_reg_indirect_ih(adev)) {drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct · line 156
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +1
-0+ if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id,tmp))
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +6
-0+return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + } +/* enable_intr field is only valid in ring0 */ if (ih == &adev->irq.ih) tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, ENABLE_INTR, (enable
Quoted 2 lines
? 1 :
Quoted 1 line
0));
BR,
Danijel Slivka