[3/3] drm/i915/perf: Wait for lrc_reconfigure on disable
diff mbox series

Message ID 20200226213042.1708867-3-chris@chris-wilson.co.uk
State New
Headers show
Series
  • [1/3] drm/i915/perf: Mark up the racy use of perf->exclusive_stream
Related show

Commit Message

Chris Wilson Feb. 26, 2020, 9:30 p.m. UTC
Wait for the last request (and so waits for all context updates) when
disabling OA. This prevents a rather bizarre error seen on Skylake
where the context is subsequently corrupted. Let's play safe and assume
it may impact all.

Reported-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 2334c45f1d08..20c68b5dea63 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -2191,7 +2191,8 @@  static int gen8_modify_context(struct intel_context *ce,
 }
 
 static int gen8_modify_self(struct intel_context *ce,
-			    const struct flex *flex, unsigned int count)
+			    const struct flex *flex, unsigned int count,
+			    bool sync)
 {
 	struct i915_request *rq;
 	int err;
@@ -2204,7 +2205,12 @@  static int gen8_modify_self(struct intel_context *ce,
 
 	err = gen8_load_flex(rq, ce, flex, count);
 
+	i915_request_get(rq);
 	i915_request_add(rq);
+	if (sync && i915_request_wait(rq, 0, HZ) < 0)
+		err = -ETIME;
+	i915_request_put(rq);
+
 	return err;
 }
 
@@ -2281,7 +2287,7 @@  static int gen12_configure_oar_context(struct i915_perf_stream *stream, bool ena
 		return err;
 
 	/* Apply regs_lri using LRI with pinned context */
-	return gen8_modify_self(ce, regs_lri, ARRAY_SIZE(regs_lri));
+	return gen8_modify_self(ce, regs_lri, ARRAY_SIZE(regs_lri), false);
 }
 
 /*
@@ -2311,7 +2317,8 @@  static int gen12_configure_oar_context(struct i915_perf_stream *stream, bool ena
  */
 static int oa_configure_all_contexts(struct i915_perf_stream *stream,
 				     struct flex *regs,
-				     size_t num_regs)
+				     size_t num_regs,
+				     bool enable)
 {
 	struct drm_i915_private *i915 = stream->perf->i915;
 	struct intel_engine_cs *engine;
@@ -2368,7 +2375,7 @@  static int oa_configure_all_contexts(struct i915_perf_stream *stream,
 
 		regs[0].value = intel_sseu_make_rpcs(i915, &ce->sseu);
 
-		err = gen8_modify_self(ce, regs, num_regs);
+		err = gen8_modify_self(ce, regs, num_regs, !enable);
 		if (err)
 			return err;
 	}
@@ -2386,7 +2393,9 @@  static int gen12_configure_all_contexts(struct i915_perf_stream *stream,
 		},
 	};
 
-	return oa_configure_all_contexts(stream, regs, ARRAY_SIZE(regs));
+	return oa_configure_all_contexts(stream,
+					 regs, ARRAY_SIZE(regs),
+					 oa_config);
 }
 
 static int lrc_configure_all_contexts(struct i915_perf_stream *stream,
@@ -2423,7 +2432,9 @@  static int lrc_configure_all_contexts(struct i915_perf_stream *stream,
 	for (i = 2; i < ARRAY_SIZE(regs); i++)
 		regs[i].value = oa_config_flex_reg(oa_config, regs[i].reg);
 
-	return oa_configure_all_contexts(stream, regs, ARRAY_SIZE(regs));
+	return oa_configure_all_contexts(stream,
+					 regs, ARRAY_SIZE(regs),
+					 oa_config);
 }
 
 static int gen8_enable_metric_set(struct i915_perf_stream *stream)