All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: try again kiq access if not in IRQ(v2)
@ 2018-02-28  7:27 Monk Liu
       [not found] ` <1519802862-9513-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 18+ messages in thread
From: Monk Liu @ 2018-02-28  7:27 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Monk Liu

sometimes GPU is switched to other VFs and won't swich
back soon, so the kiq reg access will not signal within
a short period, instead of busy waiting a long time(MAX_KEQ_REG_WAIT)
and returning TMO we can istead sleep 5ms and try again
later (non irq context)

And since the waiting in kiq_r/weg is busy wait, so MAX_KIQ_REG_WAIT
shouldn't set to a long time, set it to 10ms is more appropriate.

if gpu already in reset state, don't retry the KIQ reg access
otherwise it would always hang because KIQ was already die usually.

v2:
replace schedule() with msleep() for the wait

Change-Id: I8fc807ce85a8d30d2b50153f3f3a6eda344ef994
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index b832651..1672f5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -22,7 +22,7 @@
  */
 
 #include "amdgpu.h"
-#define MAX_KIQ_REG_WAIT	100000000 /* in usecs */
+#define MAX_KIQ_REG_WAIT	10000 /* in usecs, 10ms */
 
 uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)
 {
@@ -152,9 +152,14 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 	amdgpu_ring_commit(ring);
 	spin_unlock_irqrestore(&kiq->ring_lock, flags);
 
+retry_read:
 	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	if (r < 1) {
 		DRM_ERROR("wait for kiq fence error: %ld\n", r);
+		if (!in_interrupt() && !adev->in_gpu_reset) {
+			msleep(5);
+			goto retry_read;
+		}
 		return ~0;
 	}
 	val = adev->wb.wb[adev->virt.reg_val_offs];
@@ -179,9 +184,15 @@ void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
 	amdgpu_ring_commit(ring);
 	spin_unlock_irqrestore(&kiq->ring_lock, flags);
 
+retry_write:
 	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
-	if (r < 1)
+	if (r < 1) {
 		DRM_ERROR("wait for kiq fence error: %ld\n", r);
+		if (!in_interrupt() && !adev->in_gpu_reset) {
+			msleep(5);
+			goto retry_write;
+		}
+	}
 }
 
 /**
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-03-05 11:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28  7:27 [PATCH] drm/amdgpu: try again kiq access if not in IRQ(v2) Monk Liu
     [not found] ` <1519802862-9513-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-03-01  5:52   ` Liu, Monk
     [not found]     ` <BLUPR12MB0449438D2E411F534071ED3684C60-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-01  8:12       ` Christian König
     [not found]         ` <6362f78f-7b22-2fc1-5ce3-805190c4ffb0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-01  8:21           ` Liu, Monk
     [not found]             ` <BLUPR12MB0449EAA8B40EDA5D6BC762E284C60-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-01  8:40               ` Ding, Pixel
     [not found]                 ` <7624B23B-CE3F-4608-B9BF-F01DB29C8503-5C7GfCeVMHo@public.gmane.org>
2018-03-01  8:42                   ` Christian König
2018-03-01 15:50   ` Felix Kuehling
     [not found]     ` <3d12195d-44d3-d9b1-82cd-482f49534ec5-5C7GfCeVMHo@public.gmane.org>
2018-03-02  9:29       ` Liu, Monk
     [not found]         ` <BLUPR12MB04498B47E0BAFFF2A80A4CE684C50-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-02 20:47           ` Felix Kuehling
     [not found]             ` <e8a28819-c7fa-5b64-6b5b-723299d517f4-5C7GfCeVMHo@public.gmane.org>
2018-03-03 13:38               ` Christian König
     [not found]                 ` <ecccef01-fdab-0810-030a-cc0f0f0ee814-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-05  3:47                   ` Liu, Monk
2018-03-05  4:20                   ` Liu, Monk
     [not found]                     ` <BLUPR12MB0449708DD427D1E744992FB584DA0-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-05  7:57                       ` Christian König
     [not found]                         ` <1df4fa9f-1a5c-f005-cfa8-e4346d7892c1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-05  8:08                           ` Liu, Monk
     [not found]                             ` <BLUPR12MB0449FFE3490C8EA3394D41DD84DA0-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-05 11:20                               ` Christian König
     [not found]                                 ` <48b49b85-495f-c5bc-7d8b-447537a94c8f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-05 11:27                                   ` Liu, Monk
     [not found]                                     ` <BLUPR12MB0449F42E6D448FA2C5A7BD2F84DA0-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-03-05 11:30                                       ` Christian König
2018-03-05  4:03       ` Liu, Monk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.