From: Christian König Date: Thu, 23 Jan 2025 13:59:01 +0000 (+0100) Subject: drm/amdgpu: overwrite signaled fence in amdgpu_sync X-Git-Tag: v6.15-rc1~120^2~1^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f11c59e0700721c849b81e565bf56a7d8ceaa2d;p=thirdparty%2Fkernel%2Flinux.git drm/amdgpu: overwrite signaled fence in amdgpu_sync This allows using amdgpu_sync even without peeking into the fences for a long time. Signed-off-by: Christian König Acked-by: Srinivasan Shanmugam Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index 86c17a8946f5d..bfe12164d27da 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c @@ -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; }