[PATCH 17/33] SQUASH: - Create the default PPGTT in i915_gem_create_context

Jason Ekstrand jason at jlekstrand.net
Thu Jun 3 22:53:14 UTC 2021


---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 26 +++++++++------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 3888af57986fa..28a84afee39d2 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -248,19 +248,6 @@ proto_context_create(struct drm_i915_private *i915, unsigned int flags)
 	if (!pc)
 		return ERR_PTR(-ENOMEM);
 
-	if (HAS_FULL_PPGTT(i915)) {
-		struct i915_ppgtt *ppgtt;
-
-		ppgtt = i915_ppgtt_create(&i915->gt);
-		if (IS_ERR(ppgtt)) {
-			drm_dbg(&i915->drm, "PPGTT setup failed (%ld)\n",
-				PTR_ERR(ppgtt));
-			err = ERR_CAST(ppgtt);
-			goto proto_close;
-		}
-		pc->vm = &ppgtt->vm;
-	}
-
 	pc->user_flags = BIT(UCONTEXT_BANNABLE) |
 			 BIT(UCONTEXT_RECOVERABLE);
 	proto_context_set_persistence(i915, pc, true);
@@ -886,9 +873,18 @@ i915_gem_create_context(struct drm_i915_private *i915,
 		return ctx;
 
 	if (pc->vm) {
-		mutex_lock(&ctx->mutex);
 		__assign_ppgtt(ctx, pc->vm);
-		mutex_unlock(&ctx->mutex);
+	} else if (HAS_FULL_PPGTT(i915)) {
+		struct i915_ppgtt *ppgtt;
+
+		ppgtt = i915_ppgtt_create(&i915->gt);
+		if (IS_ERR(ppgtt)) {
+			drm_dbg(&i915->drm, "PPGTT setup failed (%ld)\n",
+				PTR_ERR(ppgtt));
+			context_close(ctx);
+			return ERR_CAST(ppgtt);
+		}
+		__assign_ppgtt(ctx, &ppgtt->vm);
 	}
 
 	if (pc->single_timeline) {
-- 
2.31.1



More information about the Intel-gfx-trybot mailing list