[Intel-gfx] [PATCH 07/12] drm/i915: Move pinning of dev_priv->kernel_context into its creator

Chris Wilson chris at chris-wilson.co.uk
Mon May 23 09:45:14 UTC 2016


On Mon, May 23, 2016 at 10:33:24AM +0100, Tvrtko Ursulin wrote:
> >@@ -313,30 +311,14 @@ i915_gem_create_context(struct drm_device *dev,
> >  	if (IS_ERR(ctx))
> >  		return ctx;
> >
> >-	if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state) {
> >-		/* We may need to do things with the shrinker which
> >-		 * require us to immediately switch back to the default
> >-		 * context. This can cause a problem as pinning the
> >-		 * default context also requires GTT space which may not
> >-		 * be available. To avoid this we always pin the default
> >-		 * context.
> >-		 */
> >-		ret = i915_gem_obj_ggtt_pin(ctx->legacy_hw_ctx.rcs_state,
> >-					    get_context_alignment(to_i915(dev)), 0);
> >-		if (ret) {
> >-			DRM_DEBUG_DRIVER("Couldn't pin %d\n", ret);
> >-			goto err_destroy;
> >-		}
> >-	}
> >-
> >  	if (USES_FULL_PPGTT(dev)) {
> >  		struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv);
> >
> >-		if (IS_ERR_OR_NULL(ppgtt)) {
> >+		if (IS_ERR(ppgtt)) {
> >  			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
> >  					 PTR_ERR(ppgtt));
> >-			ret = PTR_ERR(ppgtt);
> >-			goto err_unpin;
> >+			i915_gem_context_put(ctx);
> >+			return ERR_CAST(ppgtt);
> >  		}
> >
> >  		ctx->ppgtt = ppgtt;
> >@@ -345,14 +327,6 @@ i915_gem_create_context(struct drm_device *dev,
> >  	trace_i915_context_create(ctx);
> >
> >  	return ctx;
> >-
> >-err_unpin:
> >-	if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state)
> >-		i915_gem_object_ggtt_unpin(ctx->legacy_hw_ctx.rcs_state);
> >-err_destroy:
> >-	idr_remove(&file_priv->context_idr, ctx->user_handle);
> 
> Isn't idr_remove still required in the error path above?

Yes. I can blame a rebase error here since in the kernel it was
extracted upon we call context_close() here instead which does the idr
removal as well.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list