Skip to content

Commit 95ba893

Browse files
dma-buf: fix check in dma_resv_add_fence
It's valid to add the same fence multiple times to a dma-resv object and we shouldn't need one extra slot for each. Signed-off-by: Christian König <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Fixes: a3f7c10 ("dma-buf/dma-resv: check if the new fence is really later") Cc: [email protected] # v5.19+ Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1d5e8f4 commit 95ba893

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/dma-buf/dma-resv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void dma_resv_add_fence(struct dma_resv *obj, struct dma_fence *fence,
301301

302302
dma_resv_list_entry(fobj, i, obj, &old, &old_usage);
303303
if ((old->context == fence->context && old_usage >= usage &&
304-
dma_fence_is_later(fence, old)) ||
304+
dma_fence_is_later_or_same(fence, old)) ||
305305
dma_fence_is_signaled(old)) {
306306
dma_resv_list_set(fobj, i, fence, usage);
307307
dma_fence_put(old);

include/linux/dma-fence.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,21 @@ static inline bool dma_fence_is_later(struct dma_fence *f1,
498498
return __dma_fence_is_later(f1->seqno, f2->seqno, f1->ops);
499499
}
500500

501+
/**
502+
* dma_fence_is_later_or_same - return true if f1 is later or same as f2
503+
* @f1: the first fence from the same context
504+
* @f2: the second fence from the same context
505+
*
506+
* Returns true if f1 is chronologically later than f2 or the same fence. Both
507+
* fences must be from the same context, since a seqno is not re-used across
508+
* contexts.
509+
*/
510+
static inline bool dma_fence_is_later_or_same(struct dma_fence *f1,
511+
struct dma_fence *f2)
512+
{
513+
return f1 == f2 || dma_fence_is_later(f1, f2);
514+
}
515+
501516
/**
502517
* dma_fence_later - return the chronologically later fence
503518
* @f1: the first fence from the same context

0 commit comments

Comments
 (0)