aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_uvd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_uvd.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index cd630287cf0a..6edcb5485092 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -204,28 +204,32 @@ void radeon_uvd_fini(struct radeon_device *rdev)
204 204
205int radeon_uvd_suspend(struct radeon_device *rdev) 205int radeon_uvd_suspend(struct radeon_device *rdev)
206{ 206{
207 unsigned size; 207 int i, r;
208 void *ptr;
209 int i;
210 208
211 if (rdev->uvd.vcpu_bo == NULL) 209 if (rdev->uvd.vcpu_bo == NULL)
212 return 0; 210 return 0;
213 211
214 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) 212 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
215 if (atomic_read(&rdev->uvd.handles[i])) 213 uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
216 break; 214 if (handle != 0) {
215 struct radeon_fence *fence;
217 216
218 if (i == RADEON_MAX_UVD_HANDLES) 217 radeon_uvd_note_usage(rdev);
219 return 0;
220 218
221 size = radeon_bo_size(rdev->uvd.vcpu_bo); 219 r = radeon_uvd_get_destroy_msg(rdev,
222 size -= rdev->uvd_fw->size; 220 R600_RING_TYPE_UVD_INDEX, handle, &fence);
221 if (r) {
222 DRM_ERROR("Error destroying UVD (%d)!\n", r);
223 continue;
224 }
223 225
224 ptr = rdev->uvd.cpu_addr; 226 radeon_fence_wait(fence, false);
225 ptr += rdev->uvd_fw->size; 227 radeon_fence_unref(&fence);
226 228
227 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); 229 rdev->uvd.filp[i] = NULL;
228 memcpy(rdev->uvd.saved_bo, ptr, size); 230 atomic_set(&rdev->uvd.handles[i], 0);
231 }
232 }
229 233
230 return 0; 234 return 0;
231} 235}
@@ -246,12 +250,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)
246 ptr = rdev->uvd.cpu_addr; 250 ptr = rdev->uvd.cpu_addr;
247 ptr += rdev->uvd_fw->size; 251 ptr += rdev->uvd_fw->size;
248 252
249 if (rdev->uvd.saved_bo != NULL) { 253 memset(ptr, 0, size);
250 memcpy(ptr, rdev->uvd.saved_bo, size);
251 kfree(rdev->uvd.saved_bo);
252 rdev->uvd.saved_bo = NULL;
253 } else
254 memset(ptr, 0, size);
255 254
256 return 0; 255 return 0;
257} 256}