mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
dma-fence: Wrap querying the fence->status
The fence->status is an optional field that is only valid once the fence has been signaled. (Driver may fill the fence->status with an error code prior to calling dma_fence_signal().) Given the restriction upon its validity, wrap querying of the fence->status into a helper dma_fence_get_status(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Link: http://patchwork.freedesktop.org/patch/msgid/20170104141222.6992-2-chris@chris-wilson.co.uk
This commit is contained in:
parent
83dd1376fd
commit
d6c99f4bf0
4 changed files with 59 additions and 13 deletions
|
@ -281,6 +281,31 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(dma_fence_add_callback);
|
EXPORT_SYMBOL(dma_fence_add_callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dma_fence_get_status - returns the status upon completion
|
||||||
|
* @fence: [in] the dma_fence to query
|
||||||
|
*
|
||||||
|
* This wraps dma_fence_get_status_locked() to return the error status
|
||||||
|
* condition on a signaled fence. See dma_fence_get_status_locked() for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* Returns 0 if the fence has not yet been signaled, 1 if the fence has
|
||||||
|
* been signaled without an error condition, or a negative error code
|
||||||
|
* if the fence has been completed in err.
|
||||||
|
*/
|
||||||
|
int dma_fence_get_status(struct dma_fence *fence)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
spin_lock_irqsave(fence->lock, flags);
|
||||||
|
status = dma_fence_get_status_locked(fence);
|
||||||
|
spin_unlock_irqrestore(fence->lock, flags);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(dma_fence_get_status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dma_fence_remove_callback - remove a callback from the signaling list
|
* dma_fence_remove_callback - remove a callback from the signaling list
|
||||||
* @fence: [in] the fence to wait on
|
* @fence: [in] the fence to wait on
|
||||||
|
|
|
@ -62,30 +62,29 @@ void sync_file_debug_remove(struct sync_file *sync_file)
|
||||||
|
|
||||||
static const char *sync_status_str(int status)
|
static const char *sync_status_str(int status)
|
||||||
{
|
{
|
||||||
if (status == 0)
|
if (status < 0)
|
||||||
return "signaled";
|
return "error";
|
||||||
|
|
||||||
if (status > 0)
|
if (status > 0)
|
||||||
return "active";
|
return "signaled";
|
||||||
|
|
||||||
return "error";
|
return "active";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sync_print_fence(struct seq_file *s,
|
static void sync_print_fence(struct seq_file *s,
|
||||||
struct dma_fence *fence, bool show)
|
struct dma_fence *fence, bool show)
|
||||||
{
|
{
|
||||||
int status = 1;
|
|
||||||
struct sync_timeline *parent = dma_fence_parent(fence);
|
struct sync_timeline *parent = dma_fence_parent(fence);
|
||||||
|
int status;
|
||||||
|
|
||||||
if (dma_fence_is_signaled_locked(fence))
|
status = dma_fence_get_status_locked(fence);
|
||||||
status = fence->status;
|
|
||||||
|
|
||||||
seq_printf(s, " %s%sfence %s",
|
seq_printf(s, " %s%sfence %s",
|
||||||
show ? parent->name : "",
|
show ? parent->name : "",
|
||||||
show ? "_" : "",
|
show ? "_" : "",
|
||||||
sync_status_str(status));
|
sync_status_str(status));
|
||||||
|
|
||||||
if (status <= 0) {
|
if (status) {
|
||||||
struct timespec64 ts64 =
|
struct timespec64 ts64 =
|
||||||
ktime_to_timespec64(fence->timestamp);
|
ktime_to_timespec64(fence->timestamp);
|
||||||
|
|
||||||
|
@ -136,7 +135,7 @@ static void sync_print_sync_file(struct seq_file *s,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
|
seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
|
||||||
sync_status_str(!dma_fence_is_signaled(sync_file->fence)));
|
sync_status_str(dma_fence_get_status(sync_file->fence)));
|
||||||
|
|
||||||
if (dma_fence_is_array(sync_file->fence)) {
|
if (dma_fence_is_array(sync_file->fence)) {
|
||||||
struct dma_fence_array *array = to_dma_fence_array(sync_file->fence);
|
struct dma_fence_array *array = to_dma_fence_array(sync_file->fence);
|
||||||
|
|
|
@ -373,10 +373,8 @@ static void sync_fill_fence_info(struct dma_fence *fence,
|
||||||
sizeof(info->obj_name));
|
sizeof(info->obj_name));
|
||||||
strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
|
strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
|
||||||
sizeof(info->driver_name));
|
sizeof(info->driver_name));
|
||||||
if (dma_fence_is_signaled(fence))
|
|
||||||
info->status = fence->status >= 0 ? 1 : fence->status;
|
info->status = dma_fence_get_status(fence);
|
||||||
else
|
|
||||||
info->status = 0;
|
|
||||||
info->timestamp_ns = ktime_to_ns(fence->timestamp);
|
info->timestamp_ns = ktime_to_ns(fence->timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,30 @@ static inline struct dma_fence *dma_fence_later(struct dma_fence *f1,
|
||||||
return dma_fence_is_signaled(f2) ? NULL : f2;
|
return dma_fence_is_signaled(f2) ? NULL : f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dma_fence_get_status_locked - returns the status upon completion
|
||||||
|
* @fence: [in] the dma_fence to query
|
||||||
|
*
|
||||||
|
* Drivers can supply an optional error status condition before they signal
|
||||||
|
* the fence (to indicate whether the fence was completed due to an error
|
||||||
|
* rather than success). The value of the status condition is only valid
|
||||||
|
* if the fence has been signaled, dma_fence_get_status_locked() first checks
|
||||||
|
* the signal state before reporting the error status.
|
||||||
|
*
|
||||||
|
* Returns 0 if the fence has not yet been signaled, 1 if the fence has
|
||||||
|
* been signaled without an error condition, or a negative error code
|
||||||
|
* if the fence has been completed in err.
|
||||||
|
*/
|
||||||
|
static inline int dma_fence_get_status_locked(struct dma_fence *fence)
|
||||||
|
{
|
||||||
|
if (dma_fence_is_signaled_locked(fence))
|
||||||
|
return fence->status < 0 ? fence->status : 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dma_fence_get_status(struct dma_fence *fence);
|
||||||
|
|
||||||
signed long dma_fence_wait_timeout(struct dma_fence *,
|
signed long dma_fence_wait_timeout(struct dma_fence *,
|
||||||
bool intr, signed long timeout);
|
bool intr, signed long timeout);
|
||||||
signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
|
signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
|
||||||
|
|
Loading…
Add table
Reference in a new issue