]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amdgpu: overwrite signaled fence in amdgpu_sync
authorChristian König <christian.koenig@amd.com>
Thu, 23 Jan 2025 13:59:01 +0000 (14:59 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 21 Mar 2025 16:15:08 +0000 (12:15 -0400)
This allows using amdgpu_sync even without peeking into the fences for a
long time.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c

index 86c17a8946f5dfedb521802fa40e88d146480d13..bfe12164d27da7546844afa8bdb30671c57becab 100644 (file)
@@ -135,11 +135,16 @@ static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f)
        struct amdgpu_sync_entry *e;
 
        hash_for_each_possible(sync->fences, e, node, f->context) {
-               if (unlikely(e->fence->context != f->context))
-                       continue;
+               if (dma_fence_is_signaled(e->fence)) {
+                       dma_fence_put(e->fence);
+                       e->fence = dma_fence_get(f);
+                       return true;
+               }
 
-               amdgpu_sync_keep_later(&e->fence, f);
-               return true;
+               if (likely(e->fence->context == f->context)) {
+                       amdgpu_sync_keep_later(&e->fence, f);
+                       return true;
+               }
        }
        return false;
 }