[PATCH 23/33] SQUASH: - Don't allow more resetting user engines

Jason Ekstrand jason at jlekstrand.net
Fri Jun 4 03:50:43 UTC 2021


---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 21 ++++++---------------
 1 file changed, 6 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 294e50b87c17d..1c59cf761383f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -191,24 +191,17 @@ static int validate_priority(struct drm_i915_private *i915,
 	return 0;
 }
 
-static void proto_context_free_user_engines(struct i915_gem_proto_context *pc)
+static void proto_context_close(struct i915_gem_proto_context *pc)
 {
 	int i;
 
+	if (pc->vm)
+		i915_vm_put(pc->vm);
 	if (pc->user_engines) {
 		for (i = 0; i < pc->num_user_engines; i++)
 			kfree(pc->user_engines[i].siblings);
 		kfree(pc->user_engines);
 	}
-	pc->user_engines = NULL;
-	pc->num_user_engines = -1;
-}
-
-static void proto_context_close(struct i915_gem_proto_context *pc)
-{
-	if (pc->vm)
-		i915_vm_put(pc->vm);
-	proto_context_free_user_engines(pc);
 	kfree(pc);
 }
 
@@ -504,10 +497,9 @@ static int set_proto_ctx_engines(struct drm_i915_file_private *fpriv,
 	u64 extensions;
 	int err;
 
-	if (!args->size) {
-		proto_context_free_user_engines(pc);
-		memset(&pc->legacy_rcs_sseu, 0, sizeof(pc->legacy_rcs_sseu));
-		return 0;
+	if (pc->num_user_engines >= 0) {
+		drm_dbg(&i915->drm, "Cannot set engines twice");
+		return -EINVAL;
 	}
 
 	if (args->size < sizeof(*user) ||
@@ -567,7 +559,6 @@ static int set_proto_ctx_engines(struct drm_i915_file_private *fpriv,
 		return err;
 	}
 
-	proto_context_free_user_engines(pc);
 	pc->num_user_engines = set.num_engines;
 	pc->user_engines = set.engines;
 
-- 
2.31.1



More information about the Intel-gfx-trybot mailing list