[Intel-gfx] [PATCH] drm/i915: Fix context/engine cleanup order

Chris Wilson chris at chris-wilson.co.uk
Mon Dec 14 09:13:43 PST 2015


On Mon, Dec 14, 2015 at 04:30:04PM +0000, Nick Hoath wrote:
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 900ffd0..7df3c7a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -431,17 +431,22 @@ void i915_gem_context_fini(struct drm_device *dev)
>  		i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state);
>  	}
>  
> -	for (i = 0; i < I915_NUM_RINGS; i++) {
> +	for (i = I915_NUM_RINGS; --i >= 0;) {
>  		struct intel_engine_cs *ring = &dev_priv->ring[i];
>  
>  		if (ring->last_context)
>  			i915_gem_context_unreference(ring->last_context);
>  
> -		ring->default_context = NULL;
>  		ring->last_context = NULL;
>  	}
>  
>  	i915_gem_context_unreference(dctx);
> +
> +	for (i = I915_NUM_RINGS; --i >= 0;) {
> +		struct intel_engine_cs *ring = &dev_priv->ring[i];
> +
> +		ring->default_context = NULL;
> +	}
>  }

Why?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list