Skip to content

Commit 1b5bdf0

Browse files
drm/i915: use the new iterator in i915_sw_fence_await_reservation v3
Simplifying the code a bit. v2: use dma_resv_for_each_fence instead, according to Tvrtko the lock is held here anyway. v3: back to using dma_resv_for_each_fence_unlocked. Signed-off-by: Christian König <[email protected]> Acked-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7349520 commit 1b5bdf0

File tree

1 file changed

+11
-42
lines changed

1 file changed

+11
-42
lines changed

drivers/gpu/drm/i915/i915_sw_fence.c

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -572,56 +572,25 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence,
572572
unsigned long timeout,
573573
gfp_t gfp)
574574
{
575-
struct dma_fence *excl;
575+
struct dma_resv_iter cursor;
576+
struct dma_fence *f;
576577
int ret = 0, pending;
577578

578579
debug_fence_assert(fence);
579580
might_sleep_if(gfpflags_allow_blocking(gfp));
580581

581-
if (write) {
582-
struct dma_fence **shared;
583-
unsigned int count, i;
584-
585-
ret = dma_resv_get_fences(resv, &excl, &count, &shared);
586-
if (ret)
587-
return ret;
588-
589-
for (i = 0; i < count; i++) {
590-
if (shared[i]->ops == exclude)
591-
continue;
592-
593-
pending = i915_sw_fence_await_dma_fence(fence,
594-
shared[i],
595-
timeout,
596-
gfp);
597-
if (pending < 0) {
598-
ret = pending;
599-
break;
600-
}
601-
602-
ret |= pending;
603-
}
604-
605-
for (i = 0; i < count; i++)
606-
dma_fence_put(shared[i]);
607-
kfree(shared);
608-
} else {
609-
excl = dma_resv_get_excl_unlocked(resv);
610-
}
611-
612-
if (ret >= 0 && excl && excl->ops != exclude) {
613-
pending = i915_sw_fence_await_dma_fence(fence,
614-
excl,
615-
timeout,
582+
dma_resv_iter_begin(&cursor, resv, write);
583+
dma_resv_for_each_fence_unlocked(&cursor, f) {
584+
pending = i915_sw_fence_await_dma_fence(fence, f, timeout,
616585
gfp);
617-
if (pending < 0)
586+
if (pending < 0) {
618587
ret = pending;
619-
else
620-
ret |= pending;
621-
}
622-
623-
dma_fence_put(excl);
588+
break;
589+
}
624590

591+
ret |= pending;
592+
}
593+
dma_resv_iter_end(&cursor);
625594
return ret;
626595
}
627596

0 commit comments

Comments
 (0)