Skip to contentSkip to conversation

drm/amdgpu: clear IH_RB_W/RPTR during enabling interrupts in sriov case

PATCH In review Danijel Slivka 3 participants 3 messages Jun 20, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: clear IH_RB_W/RPTR during enabling interrupts in sriov case

Clearing the IH_RB_W/RPTR during interrupts disable is not clearing the RB_OVERFLOW bit.
Adding workaround to clear the wptr when enabling interrupts in case RB_OVERFLOW bit is set.

---
 drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +6 -0
index 3cb64c8f7175..d6212a98ca99 100644
@@ -147,6 +147,12 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
 	}
 
 	if (enable) {
+		if (amdgpu_sriov_vf(adev) &&
+		    REG_GET_FIELD(RREG32(ih_regs->ih_rb_wptr), IH_RB_WPTR, RB_OVERFLOW)) {
+			/* clear rptr, wptr*/
+			WREG32(ih_regs->ih_rb_rptr, 0);
+			WREG32(ih_regs->ih_rb_wptr, 0);
+		}
 		ih->enabled = true;
 	} else {
 		/* set rptr, wptr to 0 */
Signature · 1 line
2.34.1
maintainer
#1 lore raw

Am 20.06.24 um 15:55 schrieb Danijel Slivka:

Quoted 15 lines

Clearing the IH_RB_W/RPTR during interrupts disable is not clearing the RB_OVERFLOW bit.
Adding workaround to clear the wptr when enabling interrupts in case RB_OVERFLOW bit is set.

---
  drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +0 -0
index 3cb64c8f7175..d6212a98ca99 100644

drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, · line 155

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +6 -0
@@ -147,6 +147,12 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
  	}
 
  	if (enable) {
+		if (amdgpu_sriov_vf(adev) &&
+		    REG_GET_FIELD(RREG32(ih_regs->ih_rb_wptr), IH_RB_WPTR, RB_OVERFLOW)) {
+			/* clear rptr, wptr*/
+			WREG32(ih_regs->ih_rb_rptr, 0);
+			WREG32(ih_regs->ih_rb_wptr, 0);
+		}

Well that change doesn't really make much sense. We disable the IH ring before we do any initialisation, see ih_v6_0_irq_init().

That in turn sets RPTR and WPTR to 0:

                /* set rptr, wptr to 0 */
                WREG32(ih_regs->ih_rb_rptr, 0);
                WREG32(ih_regs->ih_rb_wptr, 0);
                ih->enabled = false;

So why should this be needed here?

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +0 -0
  		ih->enabled = true;
  	} else {
  		/* set rptr, wptr to 0 */
#2 lore raw
In reply to Danijel Slivka
Quoted 18 lines · Danijel Slivka

Clearing the IH_RB_W/RPTR during interrupts disable is not clearing the RB_OVERFLOW bit.
Adding workaround to clear the wptr when enabling interrupts in case RB_OVERFLOW bit is set.

---
 drivers/gpu/drm/amd/amdgpu/ih_v6_0.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +0 -0
index 3cb64c8f7175..d6212a98ca99 100644
@@ -147,6 +147,12 @@ static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev,
        }
 

drivers/gpu/drm/amd/amdgpu/ih_v6_0.c static int ih_v6_0_toggle_ring_interrupts(struct amdgpu_device *adev, · line 158

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +6 -0
        if (enable) {
+               if (amdgpu_sriov_vf(adev) &&
+                   REG_GET_FIELD(RREG32(ih_regs->ih_rb_wptr), IH_RB_WPTR, RB_OVERFLOW)) {
+                       /* clear rptr, wptr*/
+                       WREG32(ih_regs->ih_rb_rptr, 0);
+                       WREG32(ih_regs->ih_rb_wptr, 0);
+               }
                ih->enabled = true;
        } else {
                /* set rptr, wptr to 0 */

These already get cleared in the else case and this function gets called at the start of ih_v6_0_irq_init() so these should already be cleared by the time we get here.

Alex