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

Christian König deathsimple at vodafone.de
Mon Dec 8 08:11:08 PST 2014


From: Christian König <christian.koenig at 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 at amd.com>
---
 drivers/gpu/drm/radeon/radeon_sync.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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);
 }
-- 
1.9.1



More information about the dri-devel mailing list