[PATCH 06/10] drm/amdgpu: add gpu soft reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check gpu status first, if MC/VMC/DISPLAY hang, directly triger full reset.
If engine hangs, then triger engine soft reset, if soft reset fails, will
fallback to full reset.

Change-Id: I2d8a2c1ae72cbb1aefa4db2b216903664ed27876
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 9a7e574..f825311 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1963,6 +1963,17 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
 	struct drm_atomic_state *state = NULL;
 	int i, r;
 	int resched;
+	u32 reset_mask;
+	bool need_full_reset = false;
+
+	reset_mask = amdgpu_asic_check_soft_reset(adev);
+	/* ? VCE always busy ?*/
+	reset_mask &= ~AMDGPU_RESET_VCE;
+	if (!reset_mask) {
+		DRM_INFO("No hardware hang detected. Did some blocks stall?\n");
+		return 0;
+	}
+	DRM_INFO("reset mask: 0x%x\n", reset_mask);
 
 	atomic_inc(&adev->gpu_reset_counter);
 
@@ -1980,9 +1991,28 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
 	}
 	/* after all hw jobs are reset, hw fence is meaningless, so force_completion */
 	amdgpu_fence_driver_force_completion(adev);
+
+	if (reset_mask &
+	    (AMDGPU_RESET_MC | AMDGPU_RESET_VMC | AMDGPU_RESET_DISPLAY))
+		need_full_reset = true;
+	if (!need_full_reset) {
+		amdgpu_gpu_soft_reset(adev, reset_mask);
+		reset_mask = amdgpu_asic_check_soft_reset(adev);
+		/* ? VCE always busy ?*/
+		if (reset_mask & ~AMDGPU_RESET_VCE) {
+			need_full_reset = true;
+			DRM_INFO("Couldn't recover, still busy: 0x%x\n",
+				 reset_mask);
+		}
+	}
+
 	/* store modesetting */
 	if (amdgpu_device_has_dal_support(adev))
 		state = drm_atomic_helper_suspend(adev->ddev);
+	if(!need_full_reset) {
+		r = 0;
+		goto out;
+	}
 
 	/* save scratch */
 	amdgpu_atombios_scratch_regs_save(adev);
@@ -2005,6 +2035,7 @@ retry:
 	}
 	/* restore scratch */
 	amdgpu_atombios_scratch_regs_restore(adev);
+out:
 	if (!r) {
 		r = amdgpu_ib_ring_tests(adev);
 		if (r) {
-- 
1.9.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux