diff mbox

[1/6] drm/radeon: take a fence reference in the sync code

Message ID 1418055073-2211-1-git-send-email-deathsimple@vodafone.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christian König Dec. 8, 2014, 4:11 p.m. UTC
From: Christian König <christian.koenig@amd.com>

Just to be sure that fences we sync to won't be released while accessed.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/radeon/radeon_sync.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_sync.c b/drivers/gpu/drm/radeon/radeon_sync.c
index 02ac8a1..6fccaaf 100644
--- a/drivers/gpu/drm/radeon/radeon_sync.c
+++ b/drivers/gpu/drm/radeon/radeon_sync.c
@@ -69,11 +69,15 @@  void radeon_sync_fence(struct radeon_sync *sync,
 		return;
 
 	other = sync->sync_to[fence->ring];
-	sync->sync_to[fence->ring] = radeon_fence_later(fence, other);
+	sync->sync_to[fence->ring] = radeon_fence_ref(
+		radeon_fence_later(fence, other));
+	radeon_fence_unref(&other);
 
 	if (fence->is_vm_update) {
 		other = sync->last_vm_update;
-		sync->last_vm_update = radeon_fence_later(fence, other);
+		sync->last_vm_update = radeon_fence_ref(
+			radeon_fence_later(fence, other));
+		radeon_fence_unref(&other);
 	}
 }
 
@@ -217,4 +221,9 @@  void radeon_sync_free(struct radeon_device *rdev,
 
 	for (i = 0; i < RADEON_NUM_SYNCS; ++i)
 		radeon_semaphore_free(rdev, &sync->semaphores[i], fence);
+
+	for (i = 0; i < RADEON_NUM_RINGS; ++i)
+		radeon_fence_unref(&sync->sync_to[i]);
+
+	radeon_fence_unref(&sync->last_vm_update);
 }