Re: [PATCH 01/22] dma-fence: Serialise signal enabling (dma_fence_enable_sw_signaling)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 03/10/2019 14:09, Chris Wilson wrote:
Quoting Chris Wilson (2019-10-03 10:36:18)
Make dma_fence_enable_sw_signaling() behave like its
dma_fence_add_callback() and dma_fence_default_wait() counterparts and
perform the test to enable signaling under the fence->lock, along with
the action to do so. This ensure that should an implementation be trying
to flush the cb_list (by signaling) on retirement before freeing the
fence, it can do so in a race-free manner.

See also 0fc89b6802ba ("dma-fence: Simply wrap dma_fence_signal_locked
with dma_fence_signal").

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
  drivers/dma-buf/dma-fence.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 2c136aee3e79..587727089134 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -285,19 +285,18 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence)
  {
         unsigned long flags;
+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
+               return;
+
+       spin_lock_irqsave(fence->lock, flags);
         if (!test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
                               &fence->flags) &&
-           !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) &&

Staring at this in discussion with Tvrtko, we can't drop this check
either. After which this looks almost identical with the other
enable_signaling callers.

Ah yes true, DMA_FENCE_FLAG_SIGNALED_BIT has to be reliably checked before the enable_signalling callback. I retract my previous r-b. :)

Regards,

Tvrtko


             fence->ops->enable_signaling) {
                 trace_dma_fence_enable_signal(fence);
-
-               spin_lock_irqsave(fence->lock, flags);
-
                 if (!fence->ops->enable_signaling(fence))
                         dma_fence_signal_locked(fence);
-
-               spin_unlock_irqrestore(fence->lock, flags);
         }
+       spin_unlock_irqrestore(fence->lock, flags);
  }
  EXPORT_SYMBOL(dma_fence_enable_sw_signaling);
--
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux