Skip to contentSkip to conversation

drm/amdgpu: Clear overflow for SRIOV

PATCH In review Emily Deng 2 participants 3 messages Apr 15, 2025

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: Clear overflow for SRIOV

For VF, it doesn't have the permission to clear overflow, clear the bit by reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 15 +++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h |  1 +
 drivers/gpu/drm/amd/amdgpu/ih_v6_0.c   |  6 +++++-
 drivers/gpu/drm/amd/amdgpu/vega20_ih.c |  6 +++++-
 4 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +13 -2
index 901f8b12c672..30f16968b578 100644
@@ -25,6 +25,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ih.h"
+#include "amdgpu_reset.h"
 
 /**
  * amdgpu_ih_ring_init - initialize the IH state
@@ -227,13 +228,23 @@ int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih)
 		ih->rptr &= ih->ptr_mask;
 	}
 
-	amdgpu_ih_set_rptr(adev, ih);
+	if (!ih->overflow)
+		amdgpu_ih_set_rptr(adev, ih);
+
 	wake_up_all(&ih->wait_process);
 
 	/* make sure wptr hasn't changed while processing */
 	wptr = amdgpu_ih_get_wptr(adev, ih);
 	if (wptr != ih->rptr)
-		goto restart_ih;
+		if (!ih->overflow)
+			goto restart_ih;
+
+	if (ih->overflow)
+		if (amdgpu_sriov_runtime(adev))
+			WARN_ONCE(!amdgpu_reset_domain_schedule(adev->reset_domain,
+				   &adev->virt.flr_work),
+				  "Failed to queue work! at %s",
+				  __func__);
 
 	return IRQ_HANDLED;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +1 -0
index b0a88f92cd82..7f7ea046e209 100644
@@ -72,6 +72,7 @@ struct amdgpu_ih_ring {
 	/* For waiting on IH processing at checkpoint. */
 	wait_queue_head_t wait_process;
 	uint64_t		processed_timestamp;
+	bool overflow;
 };
 
 /* return true if time stamp t2 is after t1 with 48bit wrap around */
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +5 -1
index f8a485164437..8d3ae88b96a4 100644
@@ -349,6 +349,7 @@ static int ih_v6_0_irq_init(struct amdgpu_device *adev)
 			if (ret)
 				return ret;
 		}
+		ih[i]->overflow = false;
 	}
 
 	/* update doorbell range for ih ring 0 */
@@ -446,7 +447,10 @@ static u32 ih_v6_0_get_wptr(struct amdgpu_device *adev,
 	wptr = RREG32_NO_KIQ(ih_regs->ih_rb_wptr);
 	if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
 		goto out;
-	wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+	if (!amdgpu_sriov_vf(adev))
+		wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+	else
+		ih->overflow = true;
 
 	/* When a ring buffer overflow happen start parsing interrupt
 	 * from the last not overwritten vector (wptr + 32). Hopefully
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -1
index e9e3b2ed4b7b..2ad209406d17 100644
@@ -350,6 +350,7 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
 			if (ret)
 				return ret;
 		}
+		ih[i]->overflow = false;
 	}
 
 	if (!amdgpu_sriov_vf(adev))
@@ -437,7 +438,10 @@ static u32 vega20_ih_get_wptr(struct amdgpu_device *adev,
 	if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
 		goto out;
 
-	wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+	if (!amdgpu_sriov_vf(adev))
+		wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+	else
+		ih->overflow = true;
 
 	/* When a ring buffer overflow happen start parsing interrupt
 	 * from the last not overwritten vector (wptr + 32). Hopefully
Signature · 1 line
2.34.1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 122 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Tuesday, April 15, 2025 9:33 AM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Clear overflow for SRIOV

For VF, it doesn't have the permission to clear overflow, clear the bit by reset.

---

drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 15 +++++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h |  1 +
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c   |  6 +++++-
drivers/gpu/drm/amd/amdgpu/vega20_ih.c |  6 +++++-
4 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +1 -0
index 901f8b12c672..30f16968b578 100644
@@ -25,6 +25,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ih.h"
+#include "amdgpu_reset.h"
 
 /**
 * amdgpu_ih_ring_init - initialize the IH state @@ -227,13 +228,23 @@ int

amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih)

              ih->rptr &= ih->ptr_mask;
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +9 -2
-      amdgpu_ih_set_rptr(adev, ih);
+      if (!ih->overflow)
+              amdgpu_ih_set_rptr(adev, ih);
+
      wake_up_all(&ih->wait_process);
 
      /* make sure wptr hasn't changed while processing */
      wptr = amdgpu_ih_get_wptr(adev, ih);
      if (wptr != ih->rptr)
-              goto restart_ih;
+              if (!ih->overflow)
+                      goto restart_ih;
+
+      if (ih->overflow)
+              if (amdgpu_sriov_runtime(adev))
+                      WARN_ONCE(!amdgpu_reset_domain_schedule(adev-
Quoted 1 line

reset_domain,

drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +3 -0
+                                 &adev->virt.flr_work),
+                                "Failed to queue work! at %s",
+                                __func__);
 
      return IRQ_HANDLED;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +1 -0
index b0a88f92cd82..7f7ea046e209 100644
@@ -72,6 +72,7 @@ struct amdgpu_ih_ring {
      /* For waiting on IH processing at checkpoint. */
      wait_queue_head_t wait_process;
      uint64_t                processed_timestamp;
+      bool overflow;
 };
 
 /* return true if time stamp t2 is after t1 with 48bit wrap around */ diff --git

a/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c b/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c index f8a485164437..8d3ae88b96a4 100644

drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +1 -0
@@ -349,6 +349,7 @@ static int ih_v6_0_irq_init(struct amdgpu_device *adev)
                      if (ret)
                              return ret;
              }
+              ih[i]->overflow = false;
      }
 
      /* update doorbell range for ih ring 0 */ @@ -446,7 +447,10 @@ static u32

ih_v6_0_get_wptr(struct amdgpu_device *adev,

      wptr = RREG32_NO_KIQ(ih_regs->ih_rb_wptr);
      if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
              goto out;
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +4 -1
-      wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+      if (!amdgpu_sriov_vf(adev))
+              wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+      else
+              ih->overflow = true;
 
      /* When a ring buffer overflow happen start parsing interrupt
       * from the last not overwritten vector (wptr + 32). Hopefully diff --git

a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
index e9e3b2ed4b7b..2ad209406d17 100644

drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -1
@@ -350,6 +350,7 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
                      if (ret)
                              return ret;
              }
+              ih[i]->overflow = false;
      }
 
      if (!amdgpu_sriov_vf(adev))
@@ -437,7 +438,10 @@ static u32 vega20_ih_get_wptr(struct amdgpu_device
 *adev,
      if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
              goto out;
 
-      wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+      if (!amdgpu_sriov_vf(adev))
+              wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+      else
+              ih->overflow = true;
 
      /* When a ring buffer overflow happen start parsing interrupt

* from the last not overwritten vector (wptr + 32). Hopefully
--
2.34.1

Acked-by on v2 1/1
#2 lore raw
In reply to Emily Deng
Quoted 5 lines · Emily Deng

For VF, it doesn't have the permission to clear overflow, clear the bit by reset.

Quoted 108 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 15 +++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h |  1 +
 drivers/gpu/drm/amd/amdgpu/ih_v6_0.c   |  6 +++++-
 drivers/gpu/drm/amd/amdgpu/vega20_ih.c |  6 +++++-
 4 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +13 -2
index 901f8b12c672..30f16968b578 100644
@@ -25,6 +25,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_ih.h"
+#include "amdgpu_reset.h"
 
 /**
  * amdgpu_ih_ring_init - initialize the IH state
@@ -227,13 +228,23 @@ int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih)
                ih->rptr &= ih->ptr_mask;
        }
 
-       amdgpu_ih_set_rptr(adev, ih);
+       if (!ih->overflow)
+               amdgpu_ih_set_rptr(adev, ih);
+
        wake_up_all(&ih->wait_process);
 
        /* make sure wptr hasn't changed while processing */
        wptr = amdgpu_ih_get_wptr(adev, ih);
        if (wptr != ih->rptr)
-               goto restart_ih;
+               if (!ih->overflow)
+                       goto restart_ih;
+
+       if (ih->overflow)
+               if (amdgpu_sriov_runtime(adev))
+                       WARN_ONCE(!amdgpu_reset_domain_schedule(adev->reset_domain,
+                                  &adev->virt.flr_work),
+                                 "Failed to queue work! at %s",
+                                 __func__);
 
        return IRQ_HANDLED;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +1 -0
index b0a88f92cd82..7f7ea046e209 100644
@@ -72,6 +72,7 @@ struct amdgpu_ih_ring {
        /* For waiting on IH processing at checkpoint. */
        wait_queue_head_t wait_process;
        uint64_t                processed_timestamp;
+       bool overflow;
 };
 
 /* return true if time stamp t2 is after t1 with 48bit wrap around */
drivers/gpu/drm/amd/amdgpu/ih_v6_0.c +5 -1
index f8a485164437..8d3ae88b96a4 100644
@@ -349,6 +349,7 @@ static int ih_v6_0_irq_init(struct amdgpu_device *adev)
                        if (ret)
                                return ret;
                }
+               ih[i]->overflow = false;
        }
 
        /* update doorbell range for ih ring 0 */
@@ -446,7 +447,10 @@ static u32 ih_v6_0_get_wptr(struct amdgpu_device *adev,
        wptr = RREG32_NO_KIQ(ih_regs->ih_rb_wptr);
        if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
                goto out;
-       wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+       if (!amdgpu_sriov_vf(adev))
+               wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+       else
+               ih->overflow = true;
 
        /* When a ring buffer overflow happen start parsing interrupt
         * from the last not overwritten vector (wptr + 32). Hopefully
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -2
index e9e3b2ed4b7b..2ad209406d17 100644
@@ -350,6 +350,7 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
                        if (ret)
                                return ret;
                }
+               ih[i]->overflow = false;
        }
 
        if (!amdgpu_sriov_vf(adev))
@@ -437,7 +438,10 @@ static u32 vega20_ih_get_wptr(struct amdgpu_device *adev,
        if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW))
                goto out;
 
-       wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+       if (!amdgpu_sriov_vf(adev))
+               wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0);
+       else
+               ih->overflow = true;
 
        /* When a ring buffer overflow happen start parsing interrupt
         * from the last not overwritten vector (wptr + 32). Hopefully
--

2.34.1