drm/amdgpu: fix ring0 failed on pro card
authorChunming Zhou <David1.Zhou@amd.com>
Fri, 5 May 2017 02:33:33 +0000 (10:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 May 2017 21:40:32 +0000 (17:40 -0400)
the root cause is vram content is lost completely after pci reset.

Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Roger.He <Hongbo.He@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index e4d9aa470278c77bfe100afdfe32d459fb43700a..3c95e1858aa2ad5ba4a5dff48a6b68614a1620c7 100644 (file)
@@ -1872,13 +1872,40 @@ static int amdgpu_sriov_reinit_late(struct amdgpu_device *adev)
        return 0;
 }
 
-static int amdgpu_resume(struct amdgpu_device *adev)
+static int amdgpu_resume_phase1(struct amdgpu_device *adev)
 {
        int i, r;
 
        for (i = 0; i < adev->num_ip_blocks; i++) {
                if (!adev->ip_blocks[i].status.valid)
                        continue;
+               if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON ||
+                               adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC ||
+                               adev->ip_blocks[i].version->type ==
+                               AMD_IP_BLOCK_TYPE_IH) {
+                       r = adev->ip_blocks[i].version->funcs->resume(adev);
+                       if (r) {
+                               DRM_ERROR("resume of IP block <%s> failed %d\n",
+                                         adev->ip_blocks[i].version->funcs->name, r);
+                               return r;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+static int amdgpu_resume_phase2(struct amdgpu_device *adev)
+{
+       int i, r;
+
+       for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_blocks[i].status.valid)
+                       continue;
+               if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON ||
+                               adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC ||
+                               adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH )
+                       continue;
                r = adev->ip_blocks[i].version->funcs->resume(adev);
                if (r) {
                        DRM_ERROR("resume of IP block <%s> failed %d\n",
@@ -1890,6 +1917,18 @@ static int amdgpu_resume(struct amdgpu_device *adev)
        return 0;
 }
 
+static int amdgpu_resume(struct amdgpu_device *adev)
+{
+       int r;
+
+       r = amdgpu_resume_phase1(adev);
+       if (r)
+               return r;
+       r = amdgpu_resume_phase2(adev);
+
+       return r;
+}
+
 static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev)
 {
        if (adev->is_atom_fw) {
@@ -2753,16 +2792,20 @@ retry:
 
                if (!r) {
                        dev_info(adev->dev, "GPU reset succeeded, trying to resume\n");
-                       r = amdgpu_resume(adev);
+                       r = amdgpu_resume_phase1(adev);
+                       if (r)
+                               goto out;
+                       r = amdgpu_ttm_recover_gart(adev);
+                       if (r)
+                               goto out;
+                       r = amdgpu_resume_phase2(adev);
+                       if (r)
+                               goto out;
                }
        }
+out:
        if (!r) {
                amdgpu_irq_gpu_reset_resume_helper(adev);
-               if (need_full_reset && amdgpu_need_backup(adev)) {
-                       r = amdgpu_ttm_recover_gart(adev);
-                       if (r)
-                               DRM_ERROR("gart recovery failed!!!\n");
-               }
                r = amdgpu_ib_ring_tests(adev);
                if (r) {
                        dev_err(adev->dev, "ib ring test failed (%d).\n", r);