Skip to content

Commit fa73055

Browse files
committed
drm/i915: Only prune fences after wait-for-all
Currently, we only allow ourselves to prune the fences so long as all the waits completed (i.e. all the fences we checked were signaled), and that the reservation snapshot did not change across the wait. However, if we only waited for a subset of the reservation object, i.e. just waiting for the last writer to complete as opposed to all readers as well, then we would erroneously conclude we could prune the fences as indeed although all of our waits were successful, they did not represent the totality of the reservation object. v2: We only need to check the shared fences due to construction (i.e. all of the shared fences will be later than the exclusive fence, if any). Fixes: e54ca97 ("drm/i915: Remove completed fences after a wait") Signed-off-by: Chris Wilson <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Matthew Auld <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent cf07a60 commit fa73055

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,20 +433,28 @@ i915_gem_object_wait_reservation(struct reservation_object *resv,
433433
dma_fence_put(shared[i]);
434434
kfree(shared);
435435

436+
/*
437+
* If both shared fences and an exclusive fence exist,
438+
* then by construction the shared fences must be later
439+
* than the exclusive fence. If we successfully wait for
440+
* all the shared fences, we know that the exclusive fence
441+
* must all be signaled. If all the shared fences are
442+
* signaled, we can prune the array and recover the
443+
* floating references on the fences/requests.
444+
*/
436445
prune_fences = count && timeout >= 0;
437446
} else {
438447
excl = reservation_object_get_excl_rcu(resv);
439448
}
440449

441-
if (excl && timeout >= 0) {
450+
if (excl && timeout >= 0)
442451
timeout = i915_gem_object_wait_fence(excl, flags, timeout,
443452
rps_client);
444-
prune_fences = timeout >= 0;
445-
}
446453

447454
dma_fence_put(excl);
448455

449-
/* Oportunistically prune the fences iff we know they have *all* been
456+
/*
457+
* Opportunistically prune the fences iff we know they have *all* been
450458
* signaled and that the reservation object has not been changed (i.e.
451459
* no new fences have been added).
452460
*/

0 commit comments

Comments
 (0)