Skip to content

Commit 82813ba

Browse files
icklerodrigovivi
authored andcommitted
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] (cherry picked from commit fa73055) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent e8cd714 commit 82813ba

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
@@ -434,20 +434,28 @@ i915_gem_object_wait_reservation(struct reservation_object *resv,
434434
dma_fence_put(shared[i]);
435435
kfree(shared);
436436

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

442-
if (excl && timeout >= 0) {
451+
if (excl && timeout >= 0)
443452
timeout = i915_gem_object_wait_fence(excl, flags, timeout,
444453
rps_client);
445-
prune_fences = timeout >= 0;
446-
}
447454

448455
dma_fence_put(excl);
449456

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

0 commit comments

Comments
 (0)