All of lore.kernel.org
 help / color / mirror / Atom feed
From: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 11/11] drm/amdgpu:fix kiq_resume routine (V2)
Date: Wed, 8 Feb 2017 17:26:59 +0800	[thread overview]
Message-ID: <1486546019-31045-11-git-send-email-Monk.Liu@amd.com> (raw)
In-Reply-To: <1486546019-31045-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>

v2:
use in_rest to fix compute ring test failure issue
which occured after FLR/gpu_reset.

we need backup a clean status of MQD which was created in drv load
stage, and use it in resume stage, otherwise KCQ and KIQ all may
faild in ring/ib test.

Change-Id: I41be940454a6638e9a8a05f096601eaa1fbebaab
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      | 44 ++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5215fc5..afcae15 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2410,6 +2410,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
 
 	mutex_lock(&adev->virt.lock_reset);
 	atomic_inc(&adev->gpu_reset_counter);
+	adev->gfx.in_reset = true;
 
 	/* block TTM */
 	resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
@@ -2494,6 +2495,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
 		dev_info(adev->dev, "GPU reset failed\n");
 	}
 
+	adev->gfx.in_reset = false;
 	mutex_unlock(&adev->virt.lock_reset);
 	return r;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 6584173..1822420 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -4877,24 +4877,46 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring,
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 	uint64_t eop_gpu_addr;
 	bool is_kiq = (ring->funcs->type == AMDGPU_RING_TYPE_KIQ);
+	int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS;
 
 	if (is_kiq) {
 		eop_gpu_addr = kiq->eop_gpu_addr;
 		gfx_v8_0_kiq_setting(&kiq->ring);
-	} else
+	} else {
 		eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr +
 					ring->queue * MEC_HPD_SIZE;
+		mqd_idx = ring - &adev->gfx.compute_ring[0];
+	}
 
-	mutex_lock(&adev->srbm_mutex);
-	vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+	if (!adev->gfx.in_reset) {
+		memset((void *)mqd, 0, sizeof(*mqd));
+		mutex_lock(&adev->srbm_mutex);
+		vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+		gfx_v8_0_mqd_init(adev, mqd, mqd_gpu_addr, eop_gpu_addr, ring);
+		if (is_kiq)
+			gfx_v8_0_kiq_init_register(adev, mqd, ring);
+		vi_srbm_select(adev, 0, 0, 0, 0);
+		mutex_unlock(&adev->srbm_mutex);
 
-	gfx_v8_0_mqd_init(adev, mqd, mqd_gpu_addr, eop_gpu_addr, ring);
+		if (adev->gfx.mec.mqd_backup[mqd_idx])
+			memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(*mqd));
+	} else { /* for GPU_RESET case */
+		/* reset MQD to a clean status */
+		if (adev->gfx.mec.mqd_backup[mqd_idx])
+			memcpy(mqd, adev->gfx.mec.mqd_backup[mqd_idx], sizeof(*mqd));
 
-	if (is_kiq)
-		gfx_v8_0_kiq_init_register(adev, mqd, ring);
-
-	vi_srbm_select(adev, 0, 0, 0, 0);
-	mutex_unlock(&adev->srbm_mutex);
+		/* reset ring buffer */
+		ring->wptr = 0;
+		amdgpu_ring_clear_ring(ring);
+
+		if (is_kiq) {
+		    mutex_lock(&adev->srbm_mutex);
+		    vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+		    gfx_v8_0_kiq_init_register(adev, mqd, ring);
+		    vi_srbm_select(adev, 0, 0, 0, 0);
+		    mutex_unlock(&adev->srbm_mutex);
+		}
+	}
 
 	if (is_kiq)
 		gfx_v8_0_kiq_enable(ring);
@@ -4913,9 +4935,9 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
 
 	ring = &adev->gfx.kiq.ring;
 	if (!amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr)) {
-		memset((void *)ring->mqd_ptr, 0, sizeof(struct vi_mqd));
 		r = gfx_v8_0_kiq_init_queue(ring, ring->mqd_ptr, ring->mqd_gpu_addr);
 		amdgpu_bo_kunmap(ring->mqd_obj);
+		ring->mqd_ptr = NULL;
 		if (r)
 			return r;
 	} else {
@@ -4925,9 +4947,9 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
 	for (i = 0; i < adev->gfx.num_compute_rings; i++) {
 		ring = &adev->gfx.compute_ring[i];
 		if (!amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr)) {
-			memset((void *)ring->mqd_ptr, 0, sizeof(struct vi_mqd));
 			r = gfx_v8_0_kiq_init_queue(ring, ring->mqd_ptr, ring->mqd_gpu_addr);
 			amdgpu_bo_kunmap(ring->mqd_obj);
+			ring->mqd_ptr = NULL;
 			if (r)
 			return r;
 		} else {
-- 
2.7.4

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

  parent reply	other threads:[~2017-02-08  9:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08  9:26 [PATCH 01/11] drm/amdgpu:use MACRO like other places Monk Liu
     [not found] ` <1486546019-31045-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08  9:26   ` [PATCH 02/11] drm/amdgpu:impl RREG32 no kiq version Monk Liu
     [not found]     ` <1486546019-31045-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:37       ` Deucher, Alexander
2017-02-09  1:49       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 03/11] drm/amdgpu:Refine handshake of mailbox Monk Liu
     [not found]     ` <1486546019-31045-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-09  1:49       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 04/11] drm/amdgpu:no kiq for mailbox registers access Monk Liu
     [not found]     ` <1486546019-31045-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-09  1:50       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 05/11] drm/amdgpu:use work instead of delay-work Monk Liu
     [not found]     ` <1486546019-31045-5-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:38       ` Deucher, Alexander
2017-02-09  1:46       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 06/11] drm/amdgpu:RUNTIME flag should clr later Monk Liu
     [not found]     ` <1486546019-31045-6-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:39       ` Deucher, Alexander
2017-02-09  1:47       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 07/11] drm/amdgpu:new field in_resete introduced for gfx Monk Liu
     [not found]     ` <1486546019-31045-7-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:42       ` Deucher, Alexander
2017-02-08  9:26   ` [PATCH 08/11] drm/amdgpu:alloc mqd backup Monk Liu
     [not found]     ` <1486546019-31045-8-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:42       ` Deucher, Alexander
2017-02-09  1:51       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 09/11] drm/amdgpu:imple ring clear Monk Liu
     [not found]     ` <1486546019-31045-9-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:40       ` Deucher, Alexander
2017-02-08  9:26   ` [PATCH 10/11] drm/amdgpu:use clear_ring to clr RB Monk Liu
     [not found]     ` <1486546019-31045-10-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:41       ` Deucher, Alexander
2017-02-08  9:26   ` Monk Liu [this message]
     [not found]     ` <1486546019-31045-11-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:43       ` [PATCH 11/11] drm/amdgpu:fix kiq_resume routine (V2) Deucher, Alexander
2017-02-09  1:51       ` Yu, Xiangliang
2017-02-08  9:34   ` [PATCH 01/11] drm/amdgpu:use MACRO like other places Michel Dänzer
2017-02-08 16:35   ` Deucher, Alexander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486546019-31045-11-git-send-email-Monk.Liu@amd.com \
    --to=monk.liu-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.