Skip to content

Commit 4cca2e6

Browse files
dma-buf: fix dma-fence-chain out of order test
There was probably a misunderstand on how the dma-fence-chain is supposed to work or what dma_fence_chain_find_seqno() is supposed to return. dma_fence_chain_find_seqno() is here to give us the fence to wait upon for a particular point in the timeline. The timeline progresses only when all the points prior to a given number have completed. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Fixes: dc2f7e6 ("dma-buf: Exercise dma-fence-chain under selftests") Link: https://patchwork.freedesktop.org/patch/372960/ Signed-off-by: Christian König <christian.koenig@amd.com>
1 parent 91fac86 commit 4cca2e6

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

‎drivers/dma-buf/st-dma-fence-chain.c‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,16 @@ static int find_out_of_order(void *arg)
318318
goto err;
319319
}
320320

321-
if (fence && fence != fc.chains[1]) {
321+
/*
322+
* We signaled the middle fence (2) of the 1-2-3 chain. The behavior
323+
* of the dma-fence-chain is to make us wait for all the fences up to
324+
* the point we want. Since fence 1 is still not signaled, this what
325+
* we should get as fence to wait upon (fence 2 being garbage
326+
* collected during the traversal of the chain).
327+
*/
328+
if (fence != fc.chains[0]) {
322329
pr_err("Incorrect chain-fence.seqno:%lld reported for completed seqno:2\n",
323-
fence->seqno);
324-
325-
dma_fence_get(fence);
326-
err = dma_fence_chain_find_seqno(&fence, 2);
327-
dma_fence_put(fence);
328-
if (err)
329-
pr_err("Reported %d for finding self!\n", err);
330+
fence ? fence->seqno : 0);
330331

331332
err = -EINVAL;
332333
}
@@ -415,20 +416,18 @@ static int __find_race(void *arg)
415416
if (!fence)
416417
goto signal;
417418

418-
err = dma_fence_chain_find_seqno(&fence, seqno);
419-
if (err) {
420-
pr_err("Reported an invalid fence for find-self:%d\n",
421-
seqno);
422-
dma_fence_put(fence);
423-
break;
424-
}
425-
426-
if (fence->seqno < seqno) {
427-
pr_err("Reported an earlier fence.seqno:%lld for seqno:%d\n",
428-
fence->seqno, seqno);
429-
err = -EINVAL;
430-
dma_fence_put(fence);
431-
break;
419+
/*
420+
* We can only find ourselves if we are on fence we were
421+
* looking for.
422+
*/
423+
if (fence->seqno == seqno) {
424+
err = dma_fence_chain_find_seqno(&fence, seqno);
425+
if (err) {
426+
pr_err("Reported an invalid fence for find-self:%d\n",
427+
seqno);
428+
dma_fence_put(fence);
429+
break;
430+
}
432431
}
433432

434433
dma_fence_put(fence);

0 commit comments

Comments
 (0)