[PATCH 30/38] dma-fence: Always execute signal callbacks

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 8 21:04:33 UTC 2019


Allow for some users to surreptiously insert lazy signal callbacks that
do not depend on enabling the signaling mechanism around every fence.
This means that we may have a cb_list even if the signaling bit is not
enabled, so always notify the callbacks.

The cost is that dma_fence_signal() must always acquire the spinlock to
ensure that the cb_list is flushed.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/dma-buf/dma-fence.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 027a6a894abd..db70073458f8 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -75,7 +75,7 @@ static const struct dma_fence_ops dma_fence_stub_ops = {
  */
 struct dma_fence *dma_fence_get_stub(void)
 {
-	spin_lock(&dma_fence_stub_lock);
+	spin_lock_irq(&dma_fence_stub_lock);
 	if (!dma_fence_stub.ops) {
 		dma_fence_init(&dma_fence_stub,
 			       &dma_fence_stub_ops,
@@ -83,7 +83,7 @@ struct dma_fence *dma_fence_get_stub(void)
 			       0, 0);
 		dma_fence_signal_locked(&dma_fence_stub);
 	}
-	spin_unlock(&dma_fence_stub_lock);
+	spin_unlock_irq(&dma_fence_stub_lock);
 
 	return dma_fence_get(&dma_fence_stub);
 }
@@ -170,11 +170,9 @@ int dma_fence_signal(struct dma_fence *fence)
 
 	__dma_fence_signal__timestamp(fence, ktime_get());
 
-	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags)) {
-		spin_lock_irqsave(fence->lock, flags);
-		__dma_fence_signal__notify(fence);
-		spin_unlock_irqrestore(fence->lock, flags);
-	}
+	spin_lock_irqsave(fence->lock, flags);
+	__dma_fence_signal__notify(fence);
+	spin_unlock_irqrestore(fence->lock, flags);
 	return 0;
 }
 EXPORT_SYMBOL(dma_fence_signal);
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list