Commit 51f170a5 authored by Daniel Vetter's avatar Daniel Vetter

Revert 190c462d..bf3012ad"

I shouldn't have pushed this, CI was right - I failed to remove the
BUG_ON(!ops->wait);
Reported-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Acked-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
parent bf3012ad
...@@ -104,6 +104,7 @@ const struct dma_fence_ops dma_fence_array_ops = { ...@@ -104,6 +104,7 @@ const struct dma_fence_ops dma_fence_array_ops = {
.get_timeline_name = dma_fence_array_get_timeline_name, .get_timeline_name = dma_fence_array_get_timeline_name,
.enable_signaling = dma_fence_array_enable_signaling, .enable_signaling = dma_fence_array_enable_signaling,
.signaled = dma_fence_array_signaled, .signaled = dma_fence_array_signaled,
.wait = dma_fence_default_wait,
.release = dma_fence_array_release, .release = dma_fence_array_release,
}; };
EXPORT_SYMBOL(dma_fence_array_ops); EXPORT_SYMBOL(dma_fence_array_ops);
......
...@@ -158,10 +158,7 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout) ...@@ -158,10 +158,7 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
return -EINVAL; return -EINVAL;
trace_dma_fence_wait_start(fence); trace_dma_fence_wait_start(fence);
if (fence->ops->wait)
ret = fence->ops->wait(fence, intr, timeout); ret = fence->ops->wait(fence, intr, timeout);
else
ret = dma_fence_default_wait(fence, intr, timeout);
trace_dma_fence_wait_end(fence); trace_dma_fence_wait_end(fence);
return ret; return ret;
} }
...@@ -184,13 +181,6 @@ void dma_fence_release(struct kref *kref) ...@@ -184,13 +181,6 @@ void dma_fence_release(struct kref *kref)
} }
EXPORT_SYMBOL(dma_fence_release); EXPORT_SYMBOL(dma_fence_release);
/**
* dma_fence_free - default release function for &dma_fence.
* @fence: fence to release
*
* This is the default implementation for &dma_fence_ops.release. It calls
* kfree_rcu() on @fence.
*/
void dma_fence_free(struct dma_fence *fence) void dma_fence_free(struct dma_fence *fence)
{ {
kfree_rcu(fence, rcu); kfree_rcu(fence, rcu);
...@@ -506,6 +496,11 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count, ...@@ -506,6 +496,11 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count,
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
struct dma_fence *fence = fences[i]; struct dma_fence *fence = fences[i];
if (fence->ops->wait != dma_fence_default_wait) {
ret = -EINVAL;
goto fence_rm_cb;
}
cb[i].task = current; cb[i].task = current;
if (dma_fence_add_callback(fence, &cb[i].base, if (dma_fence_add_callback(fence, &cb[i].base,
dma_fence_default_wait_cb)) { dma_fence_default_wait_cb)) {
...@@ -565,7 +560,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, ...@@ -565,7 +560,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 || BUG_ON(!ops || !ops->wait || !ops->enable_signaling ||
!ops->get_driver_name || !ops->get_timeline_name); !ops->get_driver_name || !ops->get_timeline_name);
kref_init(&fence->refcount); kref_init(&fence->refcount);
...@@ -577,10 +572,6 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, ...@@ -577,10 +572,6 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
fence->flags = 0UL; fence->flags = 0UL;
fence->error = 0; fence->error = 0;
if (!ops->enable_signaling)
set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
&fence->flags);
trace_dma_fence_init(fence); trace_dma_fence_init(fence);
} }
EXPORT_SYMBOL(dma_fence_init); EXPORT_SYMBOL(dma_fence_init);
...@@ -188,6 +188,7 @@ static const struct dma_fence_ops timeline_fence_ops = { ...@@ -188,6 +188,7 @@ static const struct dma_fence_ops timeline_fence_ops = {
.get_timeline_name = timeline_fence_get_timeline_name, .get_timeline_name = timeline_fence_get_timeline_name,
.enable_signaling = timeline_fence_enable_signaling, .enable_signaling = timeline_fence_enable_signaling,
.signaled = timeline_fence_signaled, .signaled = timeline_fence_signaled,
.wait = dma_fence_default_wait,
.release = timeline_fence_release, .release = timeline_fence_release,
.fence_value_str = timeline_fence_value_str, .fence_value_str = timeline_fence_value_str,
.timeline_value_str = timeline_fence_timeline_value_str, .timeline_value_str = timeline_fence_timeline_value_str,
......
...@@ -225,9 +225,16 @@ static const char *drm_crtc_fence_get_timeline_name(struct dma_fence *fence) ...@@ -225,9 +225,16 @@ static const char *drm_crtc_fence_get_timeline_name(struct dma_fence *fence)
return crtc->timeline_name; return crtc->timeline_name;
} }
static bool drm_crtc_fence_enable_signaling(struct dma_fence *fence)
{
return true;
}
static const struct dma_fence_ops drm_crtc_fence_ops = { static const struct dma_fence_ops drm_crtc_fence_ops = {
.get_driver_name = drm_crtc_fence_get_driver_name, .get_driver_name = drm_crtc_fence_get_driver_name,
.get_timeline_name = drm_crtc_fence_get_timeline_name, .get_timeline_name = drm_crtc_fence_get_timeline_name,
.enable_signaling = drm_crtc_fence_enable_signaling,
.wait = dma_fence_default_wait,
}; };
struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
......
...@@ -207,6 +207,7 @@ static const struct dma_fence_ops drm_syncobj_null_fence_ops = { ...@@ -207,6 +207,7 @@ static const struct dma_fence_ops drm_syncobj_null_fence_ops = {
.get_driver_name = drm_syncobj_null_fence_get_name, .get_driver_name = drm_syncobj_null_fence_get_name,
.get_timeline_name = drm_syncobj_null_fence_get_name, .get_timeline_name = drm_syncobj_null_fence_get_name,
.enable_signaling = drm_syncobj_null_fence_enable_signaling, .enable_signaling = drm_syncobj_null_fence_enable_signaling,
.wait = dma_fence_default_wait,
.release = NULL, .release = NULL,
}; };
......
...@@ -50,6 +50,12 @@ static const char *qxl_get_timeline_name(struct dma_fence *fence) ...@@ -50,6 +50,12 @@ static const char *qxl_get_timeline_name(struct dma_fence *fence)
return "release"; return "release";
} }
static bool qxl_nop_signaling(struct dma_fence *fence)
{
/* fences are always automatically signaled, so just pretend we did this.. */
return true;
}
static long qxl_fence_wait(struct dma_fence *fence, bool intr, static long qxl_fence_wait(struct dma_fence *fence, bool intr,
signed long timeout) signed long timeout)
{ {
...@@ -113,6 +119,7 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr, ...@@ -113,6 +119,7 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr,
static const struct dma_fence_ops qxl_fence_ops = { static const struct dma_fence_ops qxl_fence_ops = {
.get_driver_name = qxl_get_driver_name, .get_driver_name = qxl_get_driver_name,
.get_timeline_name = qxl_get_timeline_name, .get_timeline_name = qxl_get_timeline_name,
.enable_signaling = qxl_nop_signaling,
.wait = qxl_fence_wait, .wait = qxl_fence_wait,
}; };
......
...@@ -81,6 +81,11 @@ static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f) ...@@ -81,6 +81,11 @@ static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f)
return (const char *)fence->sched->name; return (const char *)fence->sched->name;
} }
static bool drm_sched_fence_enable_signaling(struct dma_fence *f)
{
return true;
}
/** /**
* amd_sched_fence_free - free up the fence memory * amd_sched_fence_free - free up the fence memory
* *
...@@ -129,12 +134,18 @@ static void drm_sched_fence_release_finished(struct dma_fence *f) ...@@ -129,12 +134,18 @@ static void drm_sched_fence_release_finished(struct dma_fence *f)
const struct dma_fence_ops drm_sched_fence_ops_scheduled = { const struct dma_fence_ops drm_sched_fence_ops_scheduled = {
.get_driver_name = drm_sched_fence_get_driver_name, .get_driver_name = drm_sched_fence_get_driver_name,
.get_timeline_name = drm_sched_fence_get_timeline_name, .get_timeline_name = drm_sched_fence_get_timeline_name,
.enable_signaling = drm_sched_fence_enable_signaling,
.signaled = NULL,
.wait = dma_fence_default_wait,
.release = drm_sched_fence_release_scheduled, .release = drm_sched_fence_release_scheduled,
}; };
const struct dma_fence_ops drm_sched_fence_ops_finished = { const struct dma_fence_ops drm_sched_fence_ops_finished = {
.get_driver_name = drm_sched_fence_get_driver_name, .get_driver_name = drm_sched_fence_get_driver_name,
.get_timeline_name = drm_sched_fence_get_timeline_name, .get_timeline_name = drm_sched_fence_get_timeline_name,
.enable_signaling = drm_sched_fence_enable_signaling,
.signaled = NULL,
.wait = dma_fence_default_wait,
.release = drm_sched_fence_release_finished, .release = drm_sched_fence_release_finished,
}; };
......
...@@ -166,8 +166,7 @@ struct dma_fence_ops { ...@@ -166,8 +166,7 @@ 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 optional. If this callback is not present, then the * This callback is mandatory.
* driver must always have signaling enabled.
*/ */
bool (*enable_signaling)(struct dma_fence *fence); bool (*enable_signaling)(struct dma_fence *fence);
...@@ -191,14 +190,11 @@ struct dma_fence_ops { ...@@ -191,14 +190,11 @@ struct dma_fence_ops {
/** /**
* @wait: * @wait:
* *
* Custom wait implementation, defaults to dma_fence_default_wait() if * Custom wait implementation, or dma_fence_default_wait.
* not set.
* *
* The dma_fence_default_wait implementation should work for any fence, as long * Must not be NULL, set to dma_fence_default_wait for default implementation.
* as @enable_signaling works correctly. This hook allows drivers to * the dma_fence_default_wait implementation should work for any fence, as long
* have an optimized version for the case where a process context is * as enable_signaling works correctly.
* already available, e.g. if @enable_signaling for the general case
* needs to set up a worker thread.
* *
* Must return -ERESTARTSYS if the wait is intr = true and the wait was * Must return -ERESTARTSYS if the wait is intr = true and the wait was
* interrupted, and remaining jiffies if fence has signaled, or 0 if wait * interrupted, and remaining jiffies if fence has signaled, or 0 if wait
...@@ -206,7 +202,7 @@ struct dma_fence_ops { ...@@ -206,7 +202,7 @@ struct dma_fence_ops {
* which should be treated as if the fence is signaled. For example a hardware * which should be treated as if the fence is signaled. For example a hardware
* lockup could be reported like that. * lockup could be reported like that.
* *
* This callback is optional. * This callback is mandatory.
*/ */
signed long (*wait)(struct dma_fence *fence, signed long (*wait)(struct dma_fence *fence,
bool intr, signed long timeout); bool intr, signed long timeout);
...@@ -221,6 +217,17 @@ struct dma_fence_ops { ...@@ -221,6 +217,17 @@ struct dma_fence_ops {
*/ */
void (*release)(struct dma_fence *fence); void (*release)(struct dma_fence *fence);
/**
* @fill_driver_data:
*
* Callback to fill in free-form debug info.
*
* Returns amount of bytes filled, or negative error on failure.
*
* This callback is optional.
*/
int (*fill_driver_data)(struct dma_fence *fence, void *data, int size);
/** /**
* @fence_value_str: * @fence_value_str:
* *
...@@ -235,9 +242,8 @@ struct dma_fence_ops { ...@@ -235,9 +242,8 @@ struct dma_fence_ops {
* @timeline_value_str: * @timeline_value_str:
* *
* Fills in the current value of the timeline as a string, like the * Fills in the current value of the timeline as a string, like the
* sequence number. Note that the specific fence passed to this function * sequence number. This should match what @fill_driver_data prints for
* should not matter, drivers should only use it to look up the * the most recently signalled fence (assuming no delayed signalling).
* corresponding timeline structures.
*/ */
void (*timeline_value_str)(struct dma_fence *fence, void (*timeline_value_str)(struct dma_fence *fence,
char *str, int size); char *str, int size);
......
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