All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH] drm/i915/perf: reintroduce wait on OA configuration completion
Date: Thu, 27 Feb 2020 14:43:56 +0200	[thread overview]
Message-ID: <20200227124356.1625616-1-lionel.g.landwerlin@intel.com> (raw)

We still need to wait for the initial OA configuration to happen
before we enable OA report writes to the OA buffer.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 15d0ace1f876 ("drm/i915/perf: execute OA configuration from command stream")
---
 drivers/gpu/drm/i915/i915_perf.c       | 49 +++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_perf_types.h |  8 +++++
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index f4e1dd525fa2..3883c21b13b2 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1378,6 +1378,23 @@ free_noa_wait(struct i915_perf_stream *stream)
 	i915_vma_unpin_and_release(&stream->noa_wait, 0);
 }
 
+static int
+wait_and_put_configure_request(struct i915_perf_stream *stream)
+{
+	struct i915_request *rq = stream->configure_request;
+	int ret = 0;
+
+	stream->configure_request = NULL;
+	GEM_BUG_ON(rq == NULL);
+
+	if (i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT) < 0)
+		ret = -ETIME;
+
+	i915_request_put(rq);
+
+	return ret;
+}
+
 static void i915_oa_stream_destroy(struct i915_perf_stream *stream)
 {
 	struct i915_perf *perf = stream->perf;
@@ -1390,6 +1407,7 @@ static void i915_oa_stream_destroy(struct i915_perf_stream *stream)
 	 */
 	perf->exclusive_stream = NULL;
 	perf->ops.disable_metric_set(stream);
+	GEM_BUG_ON(stream->configure_request != NULL);
 
 	free_oa_buffer(stream);
 
@@ -1954,7 +1972,8 @@ get_oa_vma(struct i915_perf_stream *stream, struct i915_oa_config *oa_config)
 
 static int emit_oa_config(struct i915_perf_stream *stream,
 			  struct i915_oa_config *oa_config,
-			  struct intel_context *ce)
+			  struct intel_context *ce,
+			  bool store_on_stream)
 {
 	struct i915_request *rq;
 	struct i915_vma *vma;
@@ -1987,6 +2006,12 @@ static int emit_oa_config(struct i915_perf_stream *stream,
 	err = rq->engine->emit_bb_start(rq,
 					vma->node.start, 0,
 					I915_DISPATCH_SECURE);
+
+	if (err == 0 && store_on_stream) {
+		GEM_BUG_ON(stream->configure_request != NULL);
+		stream->configure_request = i915_request_get(rq);
+	}
+
 err_add_request:
 	i915_request_add(rq);
 err_vma_unpin:
@@ -2020,7 +2045,9 @@ static int hsw_enable_metric_set(struct i915_perf_stream *stream)
 	intel_uncore_rmw(uncore, GEN6_UCGCTL1,
 			 0, GEN6_CSUNIT_CLOCK_GATE_DISABLE);
 
-	return emit_oa_config(stream, stream->oa_config, oa_context(stream));
+	return emit_oa_config(stream, stream->oa_config,
+			      oa_context(stream),
+			      true /* store_on_stream */);
 }
 
 static void hsw_disable_metric_set(struct i915_perf_stream *stream)
@@ -2448,7 +2475,9 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream)
 	if (ret)
 		return ret;
 
-	return emit_oa_config(stream, oa_config, oa_context(stream));
+	return emit_oa_config(stream, oa_config,
+			      oa_context(stream),
+			      true /* store_on_stream */);
 }
 
 static u32 oag_report_ctx_switches(const struct i915_perf_stream *stream)
@@ -2502,7 +2531,9 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
 			return ret;
 	}
 
-	return emit_oa_config(stream, oa_config, oa_context(stream));
+	return emit_oa_config(stream, oa_config,
+			      oa_context(stream),
+			      true /* store_on_stream */);
 }
 
 static void gen8_disable_metric_set(struct i915_perf_stream *stream)
@@ -2837,6 +2868,12 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 		goto err_enable;
 	}
 
+	ret = wait_and_put_configure_request(stream);
+	if (ret) {
+		DRM_DEBUG("Wait on OA config request timed out\n");
+		goto err_enable;
+	}
+
 	DRM_DEBUG("opening stream oa config uuid=%s\n",
 		  stream->oa_config->uuid);
 
@@ -2851,6 +2888,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 err_enable:
 	perf->exclusive_stream = NULL;
 	perf->ops.disable_metric_set(stream);
+	GEM_BUG_ON(stream->configure_request != NULL);
 
 	free_oa_buffer(stream);
 
@@ -3160,7 +3198,8 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
 		 * When set globally, we use a low priority kernel context,
 		 * so it will effectively take effect when idle.
 		 */
-		err = emit_oa_config(stream, config, oa_context(stream));
+		err = emit_oa_config(stream, config, oa_context(stream),
+				     false /* store_on_stream */);
 		if (err == 0)
 			config = xchg(&stream->oa_config, config);
 		else
diff --git a/drivers/gpu/drm/i915/i915_perf_types.h b/drivers/gpu/drm/i915/i915_perf_types.h
index d994fa6a1c5f..92fd3cf5afcc 100644
--- a/drivers/gpu/drm/i915/i915_perf_types.h
+++ b/drivers/gpu/drm/i915/i915_perf_types.h
@@ -309,6 +309,14 @@ struct i915_perf_stream {
 	 * reprogrammed.
 	 */
 	struct i915_vma *noa_wait;
+
+	/**
+	 * @configure_request: Request on which to wait for HW to complete its
+	 * initial configuration. This is required for applications caring
+	 * about system wide monitoring. We want all the data they can get
+	 * through the OA buffer to be valid.
+	 */
+	struct i915_request *configure_request;
 };
 
 /**
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2020-02-27 12:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 12:43 Lionel Landwerlin [this message]
2020-02-27 16:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/perf: reintroduce wait on OA configuration completion Patchwork
2020-02-27 16:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-02-27 17:04 ` [Intel-gfx] [PATCH] " Chris Wilson
2020-02-28 10:52   ` Chris Wilson
2020-02-28 11:27     ` Lionel Landwerlin
2020-02-28 19:13 ` [Intel-gfx] ✓ Fi.CI.IGT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200227124356.1625616-1-lionel.g.landwerlin@intel.com \
    --to=lionel.g.landwerlin@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.