drm/amdgpu: clear UVD VCPU buffer when err_event_athub generated
authorLe Ma <le.ma@amd.com>
Fri, 25 Oct 2019 08:50:53 +0000 (16:50 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 30 Oct 2019 15:06:51 +0000 (11:06 -0400)
The err_event_athub error will mess up the buffer and cause UVD resume hang.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Hawking Zhang <hawking.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

index b2c364b8695f9a9f0d31ed645acb6ab1b059c8a6..b4dd89af6f09cf6b1345daacfd6f3d615f4032a2 100644 (file)
@@ -39,6 +39,8 @@
 #include "cikd.h"
 #include "uvd/uvd_4_2_d.h"
 
+#include "amdgpu_ras.h"
+
 /* 1 second timeout */
 #define UVD_IDLE_TIMEOUT       msecs_to_jiffies(1000)
 
@@ -372,7 +374,13 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
                if (!adev->uvd.inst[j].saved_bo)
                        return -ENOMEM;
 
-               memcpy_fromio(adev->uvd.inst[j].saved_bo, ptr, size);
+               /* re-write 0 since err_event_athub will corrupt VCPU buffer */
+               if (amdgpu_ras_intr_triggered()) {
+                       DRM_WARN("UVD VCPU state may lost due to RAS ERREVENT_ATHUB_INTERRUPT\n");
+                       memset(adev->uvd.inst[j].saved_bo, 0, size);
+               } else {
+                       memcpy_fromio(adev->uvd.inst[j].saved_bo, ptr, size);
+               }
        }
        return 0;
 }