Skip to contentSkip to conversation

drm/amdgpu: Increase tlb flush timeout for sriov

PATCH Superseded Dusica Milinkovic 3 participants 3 messages Aug 10, 2022

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: Increase tlb flush timeout for sriov

[Why]
During multi-vf executing benchmark (Luxmark) observed kiq error timeout. It happenes because all of VFs do the tlb invalidation at the same time. Although each VF has the invalidate register set, from hardware side the invalidate requests are queue to execute.

[How]
In case of 12 VF increase timeout on 12*100ms

---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +5 -1
index 9ae8cdaa033e..5743975efea5 100644
@@ -419,6 +419,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 	uint32_t seq;
 	uint16_t queried_pasid;
 	bool ret;
+	uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */
 	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -437,7 +438,10 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
 		amdgpu_ring_commit(ring);
 		spin_unlock(&adev->gfx.kiq.ring_lock);
-		r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+		if (amdgpu_sriov_vf(adev))
+			r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+		else
+			r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
 		if (r < 1) {
 			dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
 			return -ETIME;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -1
index ab89d91975ab..bab26982b3f9 100644
@@ -896,6 +896,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 	uint32_t seq;
 	uint16_t queried_pasid;
 	bool ret;
+	uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */
 	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -935,7 +936,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
 		amdgpu_ring_commit(ring);
 		spin_unlock(&adev->gfx.kiq.ring_lock);
-		r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+		if (amdgpu_sriov_vf(adev))
+			r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+		else
+			r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
 		if (r < 1) {
 			dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
 			up_read(&adev->reset_domain->sem);
Signature · 1 line
2.25.1
#1 lore raw

Am 10.08.22 um 10:50 schrieb Dusica Milinkovic:

Quoted 20 lines

[Why]
During multi-vf executing benchmark (Luxmark) observed kiq error timeout. It happenes because all of VFs do the tlb invalidation at the same time. Although each VF has the invalidate register set, from hardware side the invalidate requests are queue to execute.

[How]
In case of 12 VF increase timeout on 12*100ms

---
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 6 +++++-
  2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 9ae8cdaa033e..5743975efea5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 422

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -0
@@ -419,6 +419,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
  	uint32_t seq;
  	uint16_t queried_pasid;
  	bool ret;
+	uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */

Please put that as a define into some header and never ever write comments at the same line after a define.

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 444

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -1
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -437,7 +438,10 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
  		amdgpu_ring_commit(ring);
  		spin_unlock(&adev->gfx.kiq.ring_lock);
-		r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+		if (amdgpu_sriov_vf(adev))
+			r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+		else
+			r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);

Don't duplicate the whole call, just change the parameter.

Regards,
Christian.

Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
  		if (r < 1) {
  			dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
  			return -ETIME;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -1
index ab89d91975ab..bab26982b3f9 100644
@@ -896,6 +896,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
  	uint32_t seq;
  	uint16_t queried_pasid;
  	bool ret;
+	uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -935,7 +936,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
  		amdgpu_ring_commit(ring);
  		spin_unlock(&adev->gfx.kiq.ring_lock);
-		r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+		if (amdgpu_sriov_vf(adev))
+			r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+		else
+			r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
  		if (r < 1) {
  			dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
  			up_read(&adev->reset_domain->sem);
#2 lore raw
Quoted 39 lines · Christian König

Am 10.08.22 um 10:50 schrieb Dusica Milinkovic:

Quoted 20 lines

[Why]
During multi-vf executing benchmark (Luxmark) observed kiq error timeout. It happenes because all of VFs do the tlb invalidation at the same time. Although each VF has the invalidate register set, from hardware side the invalidate requests are queue to execute.

[How]
In case of 12 VF increase timeout on 12*100ms

---
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 6 +++++-
  2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 9ae8cdaa033e..5743975efea5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 422

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -0
@@ -419,6 +419,7 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
      uint32_t seq;
      uint16_t queried_pasid;
      bool ret;
+     uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */

Please put that as a define into some header and never ever write comments at the same line after a define.

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
      struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
      struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -437,7 +438,10 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 444

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -1
              amdgpu_ring_commit(ring);
              spin_unlock(&adev->gfx.kiq.ring_lock);
-             r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+             if (amdgpu_sriov_vf(adev))
+                     r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+             else
+                     r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);

Don't duplicate the whole call, just change the parameter.

Per this, see my comment in the previous version of this patch.

Alex

Quoted 32 lines

Regards,
Christian.

Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
              if (r < 1) {
                      dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
                      return -ETIME;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -1
index ab89d91975ab..bab26982b3f9 100644
@@ -896,6 +896,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
      uint32_t seq;
      uint16_t queried_pasid;
      bool ret;
+     uint32_t sriov_usec_timeout = 1200000;  /* wait for 12 * 100ms for SRIOV */
      struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
      struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 
@@ -935,7 +936,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
 
              amdgpu_ring_commit(ring);
              spin_unlock(&adev->gfx.kiq.ring_lock);
-             r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
+             if (amdgpu_sriov_vf(adev))
+                     r = amdgpu_fence_wait_polling(ring, seq, sriov_usec_timeout);
+             else
+                     r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout);
              if (r < 1) {
                      dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r);
                      up_read(&adev->reset_domain->sem);