[Intel-gfx] [PATCH 24/28] drm: use new iterator in drm_gem_plane_helper_prepare_fb

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Oct 5 07:53:53 UTC 2021


On 01/10/2021 11:06, Christian König wrote:
> Makes the handling a bit more complex, but avoids the use of
> dma_resv_get_excl_unlocked().
> 
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>   drivers/gpu/drm/drm_gem_atomic_helper.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c
> index e570398abd78..21ed930042b8 100644
> --- a/drivers/gpu/drm/drm_gem_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
> @@ -143,6 +143,7 @@
>    */
>   int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state)
>   {
> +	struct dma_resv_iter cursor;
>   	struct drm_gem_object *obj;
>   	struct dma_fence *fence;
>   
> @@ -150,9 +151,17 @@ int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_st
>   		return 0;
>   
>   	obj = drm_gem_fb_get_obj(state->fb, 0);
> -	fence = dma_resv_get_excl_unlocked(obj->resv);
> -	drm_atomic_set_fence_for_plane(state, fence);
> +	dma_resv_iter_begin(&cursor, obj->resv, false);
> +	dma_resv_for_each_fence_unlocked(&cursor, fence) {
> +		dma_fence_get(fence);
> +		dma_resv_iter_end(&cursor);
> +		/* TODO: We only use the first write fence here */

What is the TODO? NB instead?

> +		drm_atomic_set_fence_for_plane(state, fence);
> +		return 0;
> +	}
> +	dma_resv_iter_end(&cursor);
>   
> +	drm_atomic_set_fence_for_plane(state, NULL);

	dma_resv_iter_begin(&cursor, obj->resv, false);
	dma_resv_for_each_fence_unlocked(&cursor, fence) {
		dma_fence_get(fence);
		break;
	}
	dma_resv_iter_end(&cursor);

	drm_atomic_set_fence_for_plane(state, fence);

Does this work?

But overall I am not sure this is nicer. Is the goal to remove 
dma_resv_get_excl_unlocked as API it just does not happen in this series?

Regards,

Tvrtko

>   	return 0;
>   }
>   EXPORT_SYMBOL_GPL(drm_gem_plane_helper_prepare_fb);
> 


More information about the Intel-gfx mailing list