[Intel-gfx] [PATCH 24/24] drm/i915: Add ww locking to pin_to_display_plane

Thomas Hellström (Intel) thomas_os at shipmail.org
Wed Aug 12 20:31:34 UTC 2020


On 8/10/20 12:31 PM, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>

Commit message, please.


> ---
>   drivers/gpu/drm/i915/gem/i915_gem_domain.c | 65 ++++++++++++++++------
>   drivers/gpu/drm/i915/gem/i915_gem_object.h |  1 +
>   2 files changed, 49 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> index 8ebceebd11b0..c0d153284984 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> @@ -37,6 +37,12 @@ void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
>   	i915_gem_object_unlock(obj);
>   }
>   
> +void i915_gem_object_flush_if_display_locked(struct drm_i915_gem_object *obj)
> +{
> +	if (i915_gem_object_is_framebuffer(obj))
> +		__i915_gem_object_flush_for_display(obj);
> +}
> +
>   /**
>    * Moves a single object to the WC read, and possibly write domain.
>    * @obj: object to act on
> @@ -197,18 +203,12 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
>   	if (ret)
>   		return ret;
>   
> -	ret = i915_gem_object_lock_interruptible(obj, NULL);
> -	if (ret)
> -		return ret;
> -
>   	/* Always invalidate stale cachelines */
>   	if (obj->cache_level != cache_level) {
>   		i915_gem_object_set_cache_coherency(obj, cache_level);
>   		obj->cache_dirty = true;
>   	}
>   
> -	i915_gem_object_unlock(obj);
> -
>   	/* The cache-level will be applied when each vma is rebound. */
>   	return i915_gem_object_unbind(obj,
>   				      I915_GEM_OBJECT_UNBIND_ACTIVE |
> @@ -255,6 +255,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
>   	struct drm_i915_gem_caching *args = data;
>   	struct drm_i915_gem_object *obj;
>   	enum i915_cache_level level;
> +	struct i915_gem_ww_ctx ww;
>   	int ret = 0;
>   
>   	switch (args->caching) {
> @@ -293,7 +294,18 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
>   		goto out;
>   	}
>   
> -	ret = i915_gem_object_set_cache_level(obj, level);
> +	i915_gem_ww_ctx_init(&ww, true);
> +retry:
> +	ret = i915_gem_object_lock(obj, &ww);
> +	if (!ret)
> +		ret = i915_gem_object_set_cache_level(obj, level);
> +
> +	if (ret == -EDEADLK) {
> +		ret = i915_gem_ww_ctx_backoff(&ww);
> +		if (!ret)
> +			goto retry;
> +	}
> +	i915_gem_ww_ctx_fini(&ww);

Why a ww transaction for a single lock?

/Thomas




More information about the Intel-gfx mailing list