[PATCH 08/10] drm/syncobj: use the timeline point in drm_syncobj_find_fence v3

Chunming Zhou zhoucm1 at amd.com
Tue Dec 4 12:47:02 UTC 2018



在 2018/12/4 19:59, Christian König 写道:
> Implement finding the right timeline point in drm_syncobj_find_fence.
>
> v2: return -EINVAL when the point is not submitted yet.
> v3: fix reference counting bug, add flags handling as well
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>   drivers/gpu/drm/drm_syncobj.c | 43 ++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 40 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index ee44cf2a8a12..fdbec8cedc3d 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -231,16 +231,53 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
>   			   struct dma_fence **fence)
>   {
>   	struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
> -	int ret = 0;
> +	struct syncobj_wait_entry wait;
> +	int ret;
>   
>   	if (!syncobj)
>   		return -ENOENT;
>   
>   	*fence = drm_syncobj_fence_get(syncobj);
> -	if (!*fence) {
> +	drm_syncobj_put(syncobj);
> +
> +	if (*fence) {
> +		ret = dma_fence_chain_find_seqno(fence, point);
> +		if (!ret)
> +			return 0;
> +		dma_fence_put(*fence);
> +	} else {
>   		ret = -EINVAL;
>   	}
> -	drm_syncobj_put(syncobj);
> +
> +	if (!(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT))
> +		return ret;
> +
> +	memset(&wait, 0, sizeof(wait));
> +	wait.task = current;
> +	wait.point = point;
> +	drm_syncobj_fence_add_wait(syncobj, &wait);
> +
> +	do {
> +		set_current_state(TASK_INTERRUPTIBLE);
> +		if (wait.fence) {
> +			ret = 0;
> +			break;
> +		}
> +
> +		if (signal_pending(current)) {
> +			ret = -ERESTARTSYS;
> +			break;
> +		}
> +
> +		schedule();
> +	} while (1);
> +
> +	__set_current_state(TASK_RUNNING);
> +	*fence = wait.fence;
> +
> +	if (wait.node.next)

This condition isn't need, which is already in 
drm_syncobj_remove_wait(), with that fix, Reviewed-by: Chunming Zhou 
<david1.zhou at amd.com>

> +		drm_syncobj_remove_wait(syncobj, &wait);
> +
>   	return ret;
>   }
>   EXPORT_SYMBOL(drm_syncobj_find_fence);



More information about the amd-gfx mailing list