[PATCH 17/35] SQUASH: - Create the default PPGTT in i915_gem_create_context
Jason Ekstrand
jason at jlekstrand.net
Tue Jun 8 22:23:55 UTC 2021
---
drivers/gpu/drm/i915/gem/i915_gem_context.c | 32 ++++++++++++---------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index df98098a09f9b..b5d8c1ff5d7b3 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,28 @@ i915_gem_create_context(struct drm_i915_private *i915,
return ctx;
if (pc->vm) {
+ /* __assign_ppgtt() requires this mutex to be held */
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() requires this mutex to be held */
+ mutex_lock(&ctx->mutex);
+ __assign_ppgtt(ctx, &ppgtt->vm);
+ mutex_unlock(&ctx->mutex);
+
+ /* __assign_ppgtt() takes another reference for us */
+ i915_vm_put(&ppgtt->vm);
}
if (pc->single_timeline) {
--
2.31.1
More information about the Intel-gfx-trybot
mailing list