Skip to contentSkip to conversation

drm/amdgpu/gmc9: give more chance for tlb flush if failed(v2)

PATCH In review Emily Deng 2 participants 2 messages Apr 4, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/1 drm/amdgpu/gmc9: give more chance for tlb flush if failed(v2)

under SR-IOV sometimes CPU based tlb flush would timeout within the given 100ms period, instead let it fail and continue we can give it more chance to repeat the tlb flush on the failed VMHUB

this could fix the massive "Timeout waiting for VM flush ACK" error during vk_encoder test.

v2:refine the code

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 50 ++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +28 -22
index 503070f..44602d4 100644
@@ -328,7 +328,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
 {
 	/* Use register 17 for GART */
 	const unsigned eng = 17;
-	unsigned i, j;
+	unsigned retry = 3;
+	unsigned i, j, k;
 
 	spin_lock(&adev->gmc.invalidate_lock);
 
@@ -336,31 +337,36 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
 		struct amdgpu_vmhub *hub = &adev->vmhub[i];
 		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
-		WREG32_NO_KIQ(hub->vm_inv_eng0_req + eng, tmp);
+		for (k = 0; k < retry; ++k) {
 
-		/* Busy wait for ACK.*/
-		for (j = 0; j < 100; j++) {
-			tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
-			tmp &= 1 << vmid;
-			if (tmp)
+			WREG32_NO_KIQ(hub->vm_inv_eng0_req + eng, tmp);
+
+			/* Busy wait for ACK.*/
+			for (j = 0; j < 100; j++) {
+				tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
+				tmp &= 1 << vmid;
+				if (tmp)
+					break;
+				cpu_relax();
+			}
+			if (j < 100)
 				break;
-			cpu_relax();
-		}
-		if (j < 100)
-			continue;
-
-		/* Wait for ACK with a delay.*/
-		for (j = 0; j < adev->usec_timeout; j++) {
-			tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
-			tmp &= 1 << vmid;
-			if (tmp)
+
+			/* Wait for ACK with a delay.*/
+			for (j = 0; j < adev->usec_timeout; j++) {
+				tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
+				tmp &= 1 << vmid;
+				if (tmp)
+					break;
+				udelay(1);
+			}
+			if (j < adev->usec_timeout)
 				break;
-			udelay(1);
+			if (k == retry)
+				DRM_ERROR("Timeout waiting for VM flush ACK!\n");
+			else
+				DRM_ERROR("Need one more try to write the VMHUB flush request!");
 		}
-		if (j < adev->usec_timeout)
-			continue;
-
-		DRM_ERROR("Timeout waiting for VM flush ACK!\n");
 	}
 
 	spin_unlock(&adev->gmc.invalidate_lock);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1522818115-20328-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 04.04.2018 um 07:01 schrieb Emily Deng:

Quoted 11 lines

under SR-IOV sometimes CPU based tlb flush would timeout within the given 100ms period, instead let it fail and continue we can give it more chance to repeat the tlb flush on the failed VMHUB

this could fix the massive "Timeout waiting for VM flush ACK" error during vk_encoder test.

v2:refine the code

But that is still a rather ugly workaround, we should probably not upstream that and wait for the RLC fix instead.

Christian.

Quoted 66 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 50 ++++++++++++++++++++---------------
  1 file changed, 28 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +26 -18
index 503070f..44602d4 100644
@@ -328,7 +328,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
  {
  	/* Use register 17 for GART */
  	const unsigned eng = 17;
-	unsigned i, j;
+	unsigned retry = 3;
+	unsigned i, j, k;
 
  	spin_lock(&adev->gmc.invalidate_lock);
 
@@ -336,31 +337,36 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
  		struct amdgpu_vmhub *hub = &adev->vmhub[i];
  		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
-		WREG32_NO_KIQ(hub->vm_inv_eng0_req + eng, tmp);
+		for (k = 0; k < retry; ++k) {
 
-		/* Busy wait for ACK.*/
-		for (j = 0; j < 100; j++) {
-			tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
-			tmp &= 1 << vmid;
-			if (tmp)
+			WREG32_NO_KIQ(hub->vm_inv_eng0_req + eng, tmp);
+
+			/* Busy wait for ACK.*/
+			for (j = 0; j < 100; j++) {
+				tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
+				tmp &= 1 << vmid;
+				if (tmp)
+					break;
+				cpu_relax();
+			}
+			if (j < 100)
  				break;
-			cpu_relax();
-		}
-		if (j < 100)
-			continue;
-
-		/* Wait for ACK with a delay.*/
-		for (j = 0; j < adev->usec_timeout; j++) {
-			tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
-			tmp &= 1 << vmid;
-			if (tmp)
+
+			/* Wait for ACK with a delay.*/
+			for (j = 0; j < adev->usec_timeout; j++) {
+				tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack + eng);
+				tmp &= 1 << vmid;
+				if (tmp)
+					break;
+				udelay(1);
+			}
+			if (j < adev->usec_timeout)
  				break;
-			udelay(1);
+			if (k == retry)
+				DRM_ERROR("Timeout waiting for VM flush ACK!\n");

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, · line 372

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -4
+			else
+				DRM_ERROR("Need one more try to write the VMHUB flush request!");
  		}
-		if (j < adev->usec_timeout)
-			continue;
-
-		DRM_ERROR("Timeout waiting for VM flush ACK!\n");
  	}
 
  	spin_unlock(&adev->gmc.invalidate_lock);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx