aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2018-05-03 10:25:52 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2018-07-03 07:12:57 -0400
commit418cc6ca06071e7b7d75c0d525d80a6f49a763d6 (patch)
tree12a8b278e184d4b5350248a47ce2f5208ea8a100
parent070473bcf703366e9acb14e172d5b6563cc07a26 (diff)
dma-fence: Make ->wait callback optional
Almost everyone uses dma_fence_default_wait. v2: Also remove the BUG_ON(!ops->wait) (Chris). Reviewed-by: Christian König <christian.koenig@amd.com> (v1) Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> 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/20180503142603.28513-5-daniel.vetter@ffwll.ch
-rw-r--r--drivers/dma-buf/dma-fence-array.c1
-rw-r--r--drivers/dma-buf/dma-fence.c8
-rw-r--r--drivers/dma-buf/sw_sync.c1
-rw-r--r--include/linux/dma-fence.h13
4 files changed, 13 insertions, 10 deletions
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index dd1edfb27b61..a8c254497251 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -104,7 +104,6 @@ const struct dma_fence_ops dma_fence_array_ops = {
104 .get_timeline_name = dma_fence_array_get_timeline_name, 104 .get_timeline_name = dma_fence_array_get_timeline_name,
105 .enable_signaling = dma_fence_array_enable_signaling, 105 .enable_signaling = dma_fence_array_enable_signaling,
106 .signaled = dma_fence_array_signaled, 106 .signaled = dma_fence_array_signaled,
107 .wait = dma_fence_default_wait,
108 .release = dma_fence_array_release, 107 .release = dma_fence_array_release,
109}; 108};
110EXPORT_SYMBOL(dma_fence_array_ops); 109EXPORT_SYMBOL(dma_fence_array_ops);
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index ea343f992112..7a92f85a4cec 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -158,7 +158,10 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
158 return -EINVAL; 158 return -EINVAL;
159 159
160 trace_dma_fence_wait_start(fence); 160 trace_dma_fence_wait_start(fence);
161 ret = fence->ops->wait(fence, intr, timeout); 161 if (fence->ops->wait)
162 ret = fence->ops->wait(fence, intr, timeout);
163 else
164 ret = dma_fence_default_wait(fence, intr, timeout);
162 trace_dma_fence_wait_end(fence); 165 trace_dma_fence_wait_end(fence);
163 return ret; 166 return ret;
164} 167}
@@ -556,8 +559,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
556 spinlock_t *lock, u64 context, unsigned seqno) 559 spinlock_t *lock, u64 context, unsigned seqno)
557{ 560{
558 BUG_ON(!lock); 561 BUG_ON(!lock);
559 BUG_ON(!ops || !ops->wait || 562 BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
560 !ops->get_driver_name || !ops->get_timeline_name);
561 563
562 kref_init(&fence->refcount); 564 kref_init(&fence->refcount);
563 fence->ops = ops; 565 fence->ops = ops;
diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
index 3d78ca89a605..53c1d6d36a64 100644
--- a/drivers/dma-buf/sw_sync.c
+++ b/drivers/dma-buf/sw_sync.c
@@ -188,7 +188,6 @@ static const struct dma_fence_ops timeline_fence_ops = {
188 .get_timeline_name = timeline_fence_get_timeline_name, 188 .get_timeline_name = timeline_fence_get_timeline_name,
189 .enable_signaling = timeline_fence_enable_signaling, 189 .enable_signaling = timeline_fence_enable_signaling,
190 .signaled = timeline_fence_signaled, 190 .signaled = timeline_fence_signaled,
191 .wait = dma_fence_default_wait,
192 .release = timeline_fence_release, 191 .release = timeline_fence_release,
193 .fence_value_str = timeline_fence_value_str, 192 .fence_value_str = timeline_fence_value_str,
194 .timeline_value_str = timeline_fence_timeline_value_str, 193 .timeline_value_str = timeline_fence_timeline_value_str,
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index c053d19e1e24..02dba8cd033d 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -191,11 +191,14 @@ struct dma_fence_ops {
191 /** 191 /**
192 * @wait: 192 * @wait:
193 * 193 *
194 * Custom wait implementation, or dma_fence_default_wait. 194 * Custom wait implementation, defaults to dma_fence_default_wait() if
195 * not set.
195 * 196 *
196 * Must not be NULL, set to dma_fence_default_wait for default implementation. 197 * The dma_fence_default_wait implementation should work for any fence, as long
197 * the dma_fence_default_wait implementation should work for any fence, as long 198 * as @enable_signaling works correctly. This hook allows drivers to
198 * as enable_signaling works correctly. 199 * have an optimized version for the case where a process context is
200 * already available, e.g. if @enable_signaling for the general case
201 * needs to set up a worker thread.
199 * 202 *
200 * Must return -ERESTARTSYS if the wait is intr = true and the wait was 203 * Must return -ERESTARTSYS if the wait is intr = true and the wait was
201 * interrupted, and remaining jiffies if fence has signaled, or 0 if wait 204 * interrupted, and remaining jiffies if fence has signaled, or 0 if wait
@@ -203,7 +206,7 @@ struct dma_fence_ops {
203 * which should be treated as if the fence is signaled. For example a hardware 206 * which should be treated as if the fence is signaled. For example a hardware
204 * lockup could be reported like that. 207 * lockup could be reported like that.
205 * 208 *
206 * This callback is mandatory. 209 * This callback is optional.
207 */ 210 */
208 signed long (*wait)(struct dma_fence *fence, 211 signed long (*wait)(struct dma_fence *fence,
209 bool intr, signed long timeout); 212 bool intr, signed long timeout);