[Intel-gfx] [PATCH 1/3] drm/i915: Cleanup i915_gem_restore_gtt_mappings()

Chris Wilson chris at chris-wilson.co.uk
Fri Nov 18 10:45:59 UTC 2016


On Fri, Nov 18, 2016 at 12:06:01PM +0200, David Weinehall wrote:
> On resume we unbind+bind our VMA-mappings. This patch simplifies
> this a bit by introducing a rebind() helper.  As a nice side-effect
> this also makes the resume callgraph self-documenting.
> 
> Patch by Chris.
> 
> Signed-off-by: David Weinehall <david.weinehall at linux.intel.com>
> CC: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c |  7 +------
>  drivers/gpu/drm/i915/i915_vma.c     | 10 ++++++++++
>  drivers/gpu/drm/i915/i915_vma.h     |  6 ++++--
>  3 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index b4bde1452f2a..76af33443fcd 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -3299,12 +3299,7 @@ void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)
>  			if (vma->vm != &ggtt->base)
>  				continue;
>  
> -			if (!i915_vma_unbind(vma))
> -				continue;
> -
> -			WARN_ON(i915_vma_bind(vma, obj->cache_level,
> -					      PIN_UPDATE));
> -			ggtt_bound = true;
> +			ggtt_bound |= i915_vma_rebind(vma);
>  		}
>  
>  		if (ggtt_bound)
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index 738ff3a5cd6e..1fc54686c2c3 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -648,3 +648,13 @@ int i915_vma_unbind(struct i915_vma *vma)
>  	return 0;
>  }
>  
> +bool i915_vma_rebind(struct i915_vma *vma)
> +{
> +	if (i915_vma_is_pinned(vma)) {
> +		WARN_ON(i915_vma_bind(vma, vma->obj->cache_level, PIN_UPDATE));
> +		return true;
> +	} else {
> +		WARN_ON(i915_vma_unbind(vma));
> +		return false;
> +	}
> +}

This function is a little warny for general consumption.

I think I would prefer this next to i915_gem_restore_gtt_mappings() as
perhaps static bool restore_vma(struct i915_vma *vma) {}
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list