[PATCH 4/5] dirty-regs-root

Chris Wilson chris at chris-wilson.co.uk
Fri Jun 21 16:43:36 UTC 2019


---
 .../gpu/drm/i915/gt/selftest_workarounds.c    | 47 ++++++++++++++-----
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_workarounds.c b/drivers/gpu/drm/i915/gt/selftest_workarounds.c
index a0782a2997d0..290375961930 100644
--- a/drivers/gpu/drm/i915/gt/selftest_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/selftest_workarounds.c
@@ -349,7 +349,8 @@ static int check_whitelist_across_reset(struct intel_engine_cs *engine,
 	return err;
 }
 
-static struct i915_vma *create_batch(struct i915_gem_context *ctx)
+static struct i915_vma *create_batch(struct i915_gem_context *ctx,
+				     struct i915_address_space *vm)
 {
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
@@ -359,7 +360,7 @@ static struct i915_vma *create_batch(struct i915_gem_context *ctx)
 	if (IS_ERR(obj))
 		return ERR_CAST(obj);
 
-	vma = i915_vma_instance(obj, ctx->vm, NULL);
+	vma = i915_vma_instance(obj, vm, NULL);
 	if (IS_ERR(vma)) {
 		err = PTR_ERR(vma);
 		goto err_obj;
@@ -427,7 +428,8 @@ static int whitelist_writable_count(struct intel_engine_cs *engine)
 }
 
 static int check_dirty_whitelist(struct i915_gem_context *ctx,
-				 struct intel_engine_cs *engine)
+				 struct intel_engine_cs *engine,
+				 unsigned int flags)
 {
 	const u32 values[] = {
 		0x00000000,
@@ -455,21 +457,32 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
 		0xffff00ff,
 		0xffffffff,
 	};
+	struct i915_address_space *vm;
 	struct i915_vma *scratch;
 	struct i915_vma *batch;
 	int err = 0, i, v;
 	u32 *cs, *results;
 
-	scratch = create_scratch(ctx->vm, 2 * ARRAY_SIZE(values) + 1);
+	if (flags & I915_DISPATCH_SECURE)
+		vm = &engine->gt->ggtt->vm;
+	else
+		vm = ctx->vm;
+
+	scratch = create_scratch(vm, 2 * ARRAY_SIZE(values) + 1);
 	if (IS_ERR(scratch))
 		return PTR_ERR(scratch);
 
-	batch = create_batch(ctx);
+	batch = create_batch(ctx, vm);
 	if (IS_ERR(batch)) {
 		err = PTR_ERR(batch);
 		goto out_scratch;
 	}
 
+	if (flags & I915_DISPATCH_SECURE) {
+		GEM_BUG_ON(!i915_vma_is_ggtt(batch));
+		GEM_BUG_ON(!i915_vma_is_ggtt(scratch));
+	}
+
 	for (i = 0; i < engine->whitelist.count; i++) {
 		u32 reg = i915_mmio_reg_offset(engine->whitelist.list[i].reg);
 		u64 addr = scratch->node.start;
@@ -488,6 +501,10 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
 		lrm = MI_LOAD_REGISTER_MEM;
 		if (INTEL_GEN(ctx->i915) >= 8)
 			lrm++, srm++;
+		if (flags & I915_DISPATCH_SECURE) {
+			lrm |= MI_USE_GGTT;
+			srm |= MI_USE_GGTT;
+		}
 
 		pr_debug("%s: Writing garbage to %x\n",
 			 engine->name, reg);
@@ -559,7 +576,7 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
 
 		err = engine->emit_bb_start(rq,
 					    batch->node.start, PAGE_SIZE,
-					    0);
+					    flags);
 		if (err)
 			goto err_request;
 
@@ -585,8 +602,9 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
 		GEM_BUG_ON(values[ARRAY_SIZE(values) - 1] != 0xffffffff);
 		rsvd = results[ARRAY_SIZE(values)]; /* detect write masking */
 		if (!rsvd) {
-			pr_err("%s: Unable to write to whitelisted register %x\n",
-			       engine->name, reg);
+			pr_err("%s: Unable to write to whitelisted register %x as %s\n",
+			       engine->name, reg,
+			       flags & I915_DISPATCH_SECURE ? "root" : "user");
 			goto err_show;
 		}
 
@@ -605,8 +623,9 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
 			idx++;
 		}
 		if (err) {
-			pr_err("%s: %d mismatch between values written to whitelisted register [%x], and values read back!\n",
-			       engine->name, err, reg);
+			pr_err("%s: %d mismatch between values written to whitelisted register [%x], and values read back as %s!\n",
+			       engine->name, err, reg,
+			       flags & I915_DISPATCH_SECURE ? "root" : "user");
 err_show:
 			pr_info("%s: Whitelisted register: %x, original value %08x, rsvd %08x\n",
 				engine->name, reg, results[0], rsvd);
@@ -681,7 +700,11 @@ static int live_dirty_whitelist(void *arg)
 		if (engine->whitelist.count == 0)
 			continue;
 
-		err = check_dirty_whitelist(ctx, engine);
+		err = check_dirty_whitelist(ctx, engine, I915_DISPATCH_SECURE);
+		if (err)
+			goto out_file;
+
+		err = check_dirty_whitelist(ctx, engine, 0);
 		if (err)
 			goto out_file;
 	}
@@ -782,7 +805,7 @@ static int scrub_whitelisted_registers(struct i915_gem_context *ctx,
 	int i, err = 0;
 	u32 *cs;
 
-	batch = create_batch(ctx);
+	batch = create_batch(ctx, ctx->vm);
 	if (IS_ERR(batch))
 		return PTR_ERR(batch);
 
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list