[Intel-gfx] [PATCH] dma-fence: Use non-atomic bitops while under the lock

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu Oct 3 10:12:47 UTC 2019


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

We do not have to use atomic bitops when already under the spinlock.

Saves on a handful of lock instruction prefixes, on x86 at least.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: dri-devel at lists.freedesktop.org
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/dma-buf/dma-fence.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 2c136aee3e79..f0b480042e2f 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -133,15 +133,15 @@ int dma_fence_signal_locked(struct dma_fence *fence)
 
 	lockdep_assert_held(fence->lock);
 
-	if (unlikely(test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
-				      &fence->flags)))
+	if (unlikely(__test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
+					&fence->flags)))
 		return -EINVAL;
 
 	/* Stash the cb_list before replacing it with the timestamp */
 	list_replace(&fence->cb_list, &cb_list);
 
 	fence->timestamp = ktime_get();
-	set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
+	__set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
 	trace_dma_fence_signaled(fence);
 
 	list_for_each_entry_safe(cur, tmp, &cb_list, node) {
@@ -343,8 +343,8 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
 
 	spin_lock_irqsave(fence->lock, flags);
 
-	was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
-				   &fence->flags);
+	was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+				     &fence->flags);
 
 	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
 		ret = -ENOENT;
@@ -473,8 +473,8 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
 		goto out;
 	}
 
-	was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
-				   &fence->flags);
+	was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+				     &fence->flags);
 
 	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
 		goto out;
-- 
2.20.1



More information about the Intel-gfx mailing list