[2/3] dma-buf: Report signaled links inside dma-fence-chain
diff mbox series

Message ID 20191020164343.11233-2-chris@chris-wilson.co.uk
State New
Headers show
  • [1/3] dma-buf: Prettify typecasts for dma-fence-chain
Related show

Commit Message

Chris Wilson Oct. 20, 2019, 4:43 p.m. UTC
Whenever we walk along the dma-fence-chain, we prune signaled links to
keep the chain nice and tidy. This leads to situations where we can
prune a link and report the earlier fence as the target seqno --
violating our own consistency checks that the seqno is not more advanced
than the last element in a dma-fence-chain.

Report a NULL fence and success if the seqno has already been signaled.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
 drivers/dma-buf/dma-fence-chain.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff mbox series

diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
index 3d123502ff12..5dd4e9a6dded 100644
--- a/drivers/dma-buf/dma-fence-chain.c
+++ b/drivers/dma-buf/dma-fence-chain.c
@@ -99,6 +99,12 @@  int dma_fence_chain_find_seqno(struct dma_fence **pfence, uint64_t seqno)
 		return -EINVAL;
 	dma_fence_chain_for_each(*pfence, &chain->base) {
+		if ((*pfence)->seqno < seqno) { /* already signaled */
+			dma_fence_put(*pfence);
+			*pfence = NULL;
+			break;
+		}
 		if ((*pfence)->context != chain->base.context ||
 		    to_dma_fence_chain(*pfence)->prev_seqno < seqno)