Skip to contentSkip to conversation

drm/amdgpu: Don't use kiq in gpu reset

PATCH In review Emily Deng 2 participants 6 messages Aug 22, 2018 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/3 drm/amdgpu: Don't use kiq in gpu reset

When in gpu reset, don't use kiq, it will generate more TDR.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +4 -11
index eec991f..fcdbacb 100644
@@ -331,15 +331,8 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct amdgpu_device *adev,
 
 	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 
-	/* don't wait anymore for gpu reset case because this way may
-	 * block gpu_recover() routine forever, e.g. this virt_kiq_rreg
-	 * is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
-	 * never return if we keep waiting in virt_kiq_rreg, which cause
-	 * gpu_recover() hang there.
-	 *
-	 * also don't wait anymore for IRQ context
-	 * */
-	if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+	/* don't wait anymore for IRQ context */
+	if (r < 1 && in_interrupt())
 		goto failed_kiq;
 
 	might_sleep();
@@ -387,8 +380,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
 		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
 		if (adev->gfx.kiq.ring.ready &&
-		    (amdgpu_sriov_runtime(adev) ||
-		     !amdgpu_sriov_vf(adev))) {
+		    (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) &&
+		    !adev->in_gpu_reset) {
 			r = amdgpu_kiq_reg_write_reg_wait(adev, hub->vm_inv_eng0_req + eng,
 				hub->vm_inv_eng0_ack + eng, tmp, 1 << vmid);
 			if (!r)
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): 1534912762-30235-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/3 drm/amdgpu: Don't use kiq in interrupt

Don't use kiq interrupt, as it might sleep.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -7
index fcdbacb..f49f5f3 100644
@@ -331,12 +331,6 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct amdgpu_device *adev,
 
 	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 
-	/* don't wait anymore for IRQ context */
-	if (r < 1 && in_interrupt())
-		goto failed_kiq;
-
-	might_sleep();
-
 	while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
 		msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
 		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
@@ -381,7 +375,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
 
 		if (adev->gfx.kiq.ring.ready &&
 		    (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) &&
-		    !adev->in_gpu_reset) {
+		    !adev->in_gpu_reset &&
+		    !in_interrupt()) {
 			r = amdgpu_kiq_reg_write_reg_wait(adev, hub->vm_inv_eng0_req + eng,
 				hub->vm_inv_eng0_ack + eng, tmp, 1 << vmid);
 			if (!r)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 3/3 drm/amdgpu: Use warn to replace error report

In reply to a message not in the archive

When kiq flush fail, it could fallback to mmio flush, so don't report an error, just a warning.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
index f49f5f3..6214ad3 100644
@@ -342,7 +342,7 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct amdgpu_device *adev,
 	return 0;
 
 failed_kiq:
-	pr_err("failed to invalidate tlb with kiq\n");
+	pr_warn("failed to invalidate tlb with kiq\n");
 	return r;
 }
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw
In reply to a message not in the archive

Ping......

Quoted 53 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Emily Deng
Sent: Wednesday, August 22, 2018 12:39 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Don't use kiq in gpu reset

When in gpu reset, don't use kiq, it will generate more TDR.

---
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 15 ++++-----------

1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -9
index eec991f..fcdbacb 100644
@@ -331,15 +331,8 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct
 amdgpu_device *adev,
 
 	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 
-	/* don't wait anymore for gpu reset case because this way may
-	 * block gpu_recover() routine forever, e.g. this virt_kiq_rreg
-	 * is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
-	 * never return if we keep waiting in virt_kiq_rreg, which cause
-	 * gpu_recover() hang there.
-	 *
-	 * also don't wait anymore for IRQ context
-	 * */
-	if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+	/* don't wait anymore for IRQ context */
+	if (r < 1 && in_interrupt())
 		goto failed_kiq;
 
	might_sleep();
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -2
@@ -387,8 +380,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct
 amdgpu_device *adev,
 		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
 		if (adev->gfx.kiq.ring.ready &&
-		    (amdgpu_sriov_runtime(adev) ||
-		     !amdgpu_sriov_vf(adev))) {
+		    (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev))

&&

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
+		    !adev->in_gpu_reset) {

r = amdgpu_kiq_reg_write_reg_wait(adev, hub-

Quoted 1 line

vm_inv_eng0_req + eng,

				hub->vm_inv_eng0_ack + eng, tmp, 1 << vmid);
			if (!r)
Quoted 7 lines

--
2.7.4

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

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

#5 lore raw
In reply to a message not in the archive

Am 22.08.2018 um 06:39 schrieb Emily Deng:

Quoted 3 lines

When in gpu reset, don't use kiq, it will generate more TDR.

Patch #1 is Reviewed-by: Christian König <[email protected]>.

Patch #2 actually not necessary since we should never flush the tlb from interrupt context.

Patch #3: I would actually rather keep that an error message cause it still means that something went wrong.

Christian.

Quoted 27 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 15 ++++-----------
  1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -9
index eec991f..fcdbacb 100644
@@ -331,15 +331,8 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct amdgpu_device *adev,
 
  	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 
-	/* don't wait anymore for gpu reset case because this way may
-	 * block gpu_recover() routine forever, e.g. this virt_kiq_rreg
-	 * is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
-	 * never return if we keep waiting in virt_kiq_rreg, which cause
-	 * gpu_recover() hang there.
-	 *
-	 * also don't wait anymore for IRQ context
-	 * */
-	if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+	/* don't wait anymore for IRQ context */
+	if (r < 1 && in_interrupt())
  		goto failed_kiq;
 
  	might_sleep();

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -2
@@ -387,8 +380,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
  		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
  		if (adev->gfx.kiq.ring.ready &&
-		    (amdgpu_sriov_runtime(adev) ||
-		     !amdgpu_sriov_vf(adev))) {
+		    (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) &&
+		    !adev->in_gpu_reset) {
  			r = amdgpu_kiq_reg_write_reg_wait(adev, hub->vm_inv_eng0_req + eng,
  				hub->vm_inv_eng0_ack + eng, tmp, 1 << vmid);
  			if (!r)

_______________________________________________
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): fb256e36-59ca-14f2-09ba-bc7c1d9eb478-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#7 lore raw
Quoted 7 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, August 22, 2018 8:24 PM
To: Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH 1/3] drm/amdgpu: Don't use kiq in gpu reset

Am 22.08.2018 um 06:39 schrieb Emily Deng:

Quoted 8 lines
Quoted 3 lines

When in gpu reset, don't use kiq, it will generate more TDR.

Patch #1 is Reviewed-by: Christian König <[email protected]>.

Patch #2 actually not necessary since we should never flush the tlb from interrupt context.

Ok, if have the constraint, then ignore the patch.

Quoted 3 lines

Patch #3: I would actually rather keep that an error message cause it still means that something went wrong.

Ok, then ignore the patch.

Quoted 39 lines

Christian.

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static void gmc_v9_0_flush_gpu_tlb(struct

Quoted 29 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 15 ++++-----------
  1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -9
index eec991f..fcdbacb 100644
@@ -331,15 +331,8 @@ signed long  amdgpu_kiq_reg_write_reg_wait(struct
 amdgpu_device *adev,
 
  	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 
-	/* don't wait anymore for gpu reset case because this way may
-	 * block gpu_recover() routine forever, e.g. this virt_kiq_rreg
-	 * is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
-	 * never return if we keep waiting in virt_kiq_rreg, which cause
-	 * gpu_recover() hang there.
-	 *
-	 * also don't wait anymore for IRQ context
-	 * */
-	if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+	/* don't wait anymore for IRQ context */
+	if (r < 1 && in_interrupt())
  		goto failed_kiq;
 
  	might_sleep();
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
@@ -387,8 +380,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct

amdgpu_device *adev,

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -2
  		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
  		if (adev->gfx.kiq.ring.ready &&
-		    (amdgpu_sriov_runtime(adev) ||
-		     !amdgpu_sriov_vf(adev))) {
+		    (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev))

&&

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
+		    !adev->in_gpu_reset) {
  			r = amdgpu_kiq_reg_write_reg_wait(adev, hub-
 vm_inv_eng0_req + eng,
  				hub->vm_inv_eng0_ack + eng, tmp, 1 << vmid);

if (!r)

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