Commit c701317a authored by Daniel Vetter's avatar Daniel Vetter

dma-fence: Make ->enable_signaling optional

Many drivers have a trivial implementation for ->enable_signaling.
Let's make it optional by assuming that signalling is already
available when the callback isn't present.

v2: Don't do the trick to set the ENABLE_SIGNAL_BIT
unconditionally, it results in an expensive spinlock take for
everyone. Instead just check if the callback is present. Suggested by
Maarten.

Also move misplaced kerneldoc hunk to the right patch.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com> (v1)
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Link: https://patchwork.freedesktop.org/patch/msgid/20180504141034.27727-1-daniel.vetter@ffwll.ch
parent 1b48b720
...@@ -200,7 +200,8 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence) ...@@ -200,7 +200,8 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence)
if (!test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, if (!test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
&fence->flags) && &fence->flags) &&
!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) &&
fence->ops->enable_signaling) {
trace_dma_fence_enable_signal(fence); trace_dma_fence_enable_signal(fence);
spin_lock_irqsave(fence->lock, flags); spin_lock_irqsave(fence->lock, flags);
...@@ -260,7 +261,7 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, ...@@ -260,7 +261,7 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
ret = -ENOENT; ret = -ENOENT;
else if (!was_set) { else if (!was_set && fence->ops->enable_signaling) {
trace_dma_fence_enable_signal(fence); trace_dma_fence_enable_signal(fence);
if (!fence->ops->enable_signaling(fence)) { if (!fence->ops->enable_signaling(fence)) {
...@@ -388,7 +389,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) ...@@ -388,7 +389,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
goto out; goto out;
if (!was_set) { if (!was_set && fence->ops->enable_signaling) {
trace_dma_fence_enable_signal(fence); trace_dma_fence_enable_signal(fence);
if (!fence->ops->enable_signaling(fence)) { if (!fence->ops->enable_signaling(fence)) {
...@@ -560,7 +561,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, ...@@ -560,7 +561,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
spinlock_t *lock, u64 context, unsigned seqno) spinlock_t *lock, u64 context, unsigned seqno)
{ {
BUG_ON(!lock); BUG_ON(!lock);
BUG_ON(!ops || !ops->wait || !ops->enable_signaling || BUG_ON(!ops || !ops->wait ||
!ops->get_driver_name || !ops->get_timeline_name); !ops->get_driver_name || !ops->get_timeline_name);
kref_init(&fence->refcount); kref_init(&fence->refcount);
......
...@@ -166,7 +166,8 @@ struct dma_fence_ops { ...@@ -166,7 +166,8 @@ struct dma_fence_ops {
* released when the fence is signalled (through e.g. the interrupt * released when the fence is signalled (through e.g. the interrupt
* handler). * handler).
* *
* This callback is mandatory. * This callback is optional. If this callback is not present, then the
* driver must always have signaling enabled.
*/ */
bool (*enable_signaling)(struct dma_fence *fence); bool (*enable_signaling)(struct dma_fence *fence);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment