All of lore.kernel.org
 help / color / mirror / Atom feed
From: sourab.gupta@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Sourab Gupta <sourab.gupta@intel.com>,
	Deepak S <deepak.s@intel.com>
Subject: [PATCH 09/16] drm/i915: Populate ctx ID for periodic OA reports
Date: Fri, 22 Apr 2016 17:03:58 +0530	[thread overview]
Message-ID: <1461324845-25755-10-git-send-email-sourab.gupta@intel.com> (raw)
In-Reply-To: <1461324845-25755-1-git-send-email-sourab.gupta@intel.com>

From: Sourab Gupta <sourab.gupta@intel.com>

This adds support for populating the ctx id for the periodic OA reports
when requested through the corresponding property.

For Gen8, the OA reports itself have the ctx ID and it is the one programmed
into HW while submitting workloads. Thus it's retrieved from reports itself.
For Gen7, the OA reports don't have any such field, and we can populate this
field with the last seen ctx ID while sending CS reports.

Signed-off-by: Sourab Gupta <sourab.gupta@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  3 +++
 drivers/gpu/drm/i915/i915_perf.c | 52 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 6bea3bb..53bf148 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1823,6 +1823,8 @@ struct i915_oa_ops {
 		    u32 ts, u32 max_records);
 	int (*oa_buffer_num_samples)(struct drm_i915_private *dev_priv,
 					u32 *last_ts);
+	u32 (*oa_buffer_get_ctx_id)(struct i915_perf_stream *stream,
+					const u8 *report);
 };
 
 /*
@@ -2174,6 +2176,7 @@ struct drm_i915_private {
 			u32 status;
 		} command_stream_buf;
 
+		u32 last_ctx_id;
 		struct list_head node_list;
 		spinlock_t node_list_lock;
 	} perf;
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 147f377..a112c20 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -476,6 +476,46 @@ gen7_oa_buffer_num_samples_fop_unlocked(struct drm_i915_private *dev_priv,
 	return num_samples;
 }
 
+static u32 gen7_oa_buffer_get_ctx_id(struct i915_perf_stream *stream,
+				    const u8 *report)
+{
+	struct drm_i915_private *dev_priv = stream->dev_priv;
+
+	if (!stream->cs_mode)
+		WARN_ONCE(1,
+			"CTX ID can't be retrieved if command stream mode not enabled");
+
+	/*
+	 * OA reports generated in Gen7 don't have the ctx ID information.
+	 * Therefore, just rely on the ctx ID information from the last CS
+	 * sample forwarded
+	 */
+	return dev_priv->perf.last_ctx_id;
+}
+
+static u32 gen8_oa_buffer_get_ctx_id(struct i915_perf_stream *stream,
+				    const u8 *report)
+{
+	struct drm_i915_private *dev_priv = stream->dev_priv;
+
+	/* The ctx ID present in the OA reports have intel_context::global_id
+	 * present, since this is programmed into the ELSP in execlist mode.
+	 * In non-execlist mode, fall back to retrieving the ctx ID from the
+	 * last saved ctx ID from command stream mode.
+	 */
+	if (i915.enable_execlists) {
+		u32 ctx_id = *(u32 *)(report + 12);
+		ctx_id &= 0xfffff;
+		return ctx_id;
+	} else {
+		if (!stream->cs_mode)
+		WARN_ONCE(1,
+			"CTX ID can't be retrieved if command stream mode not enabled");
+
+		return dev_priv->perf.last_ctx_id;
+	}
+}
+
 /**
  * Appends a status record to a userspace read() buffer.
  */
@@ -571,9 +611,9 @@ static int append_oa_buffer_sample(struct i915_perf_stream *stream,
 
 		data.source = source;
 	}
-#warning "FIXME: append_oa_buffer_sample: read ctx ID from report and map that to an intel_context::global_id"
 	if (sample_flags & SAMPLE_CTX_ID)
-		data.ctx_id = 0;
+		data.ctx_id = dev_priv->perf.oa.ops.oa_buffer_get_ctx_id(
+						stream, report);
 
 	if (sample_flags & SAMPLE_OA_REPORT)
 		data.report = report;
@@ -998,8 +1038,10 @@ static int append_oa_rcs_sample(struct i915_perf_stream *stream,
 	if (sample_flags & SAMPLE_OA_SOURCE_INFO)
 		data.source = I915_PERF_OA_EVENT_SOURCE_RCS;
 
-	if (sample_flags & SAMPLE_CTX_ID)
+	if (sample_flags & SAMPLE_CTX_ID) {
 		data.ctx_id = node->ctx_id;
+		dev_priv->perf.last_ctx_id = node->ctx_id;
+	}
 
 	if (sample_flags & SAMPLE_OA_REPORT)
 		data.report = report;
@@ -2717,6 +2759,8 @@ void i915_perf_init(struct drm_device *dev)
 		dev_priv->perf.oa.ops.read = gen7_oa_read;
 		dev_priv->perf.oa.ops.oa_buffer_num_samples =
 			gen7_oa_buffer_num_samples_fop_unlocked;
+		dev_priv->perf.oa.ops.oa_buffer_get_ctx_id =
+					gen7_oa_buffer_get_ctx_id;
 
 		dev_priv->perf.oa.oa_formats = hsw_oa_formats;
 
@@ -2732,6 +2776,8 @@ void i915_perf_init(struct drm_device *dev)
 		dev_priv->perf.oa.ops.read = gen8_oa_read;
 		dev_priv->perf.oa.ops.oa_buffer_num_samples =
 				gen8_oa_buffer_num_samples_fop_unlocked;
+		dev_priv->perf.oa.ops.oa_buffer_get_ctx_id =
+					gen8_oa_buffer_get_ctx_id;
 
 		dev_priv->perf.oa.oa_formats = gen8_plus_oa_formats;
 
-- 
1.9.1

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

  parent reply	other threads:[~2016-04-22 11:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 11:33 [PATCH 00/16] Framework to collect command stream gpu metrics using i915 perf sourab.gupta
2016-04-22 11:33 ` [PATCH 01/16] drm/i915: Introduce global id for contexts sourab.gupta
2016-04-22 11:33 ` [PATCH 02/16] drm/i915: Constrain intel_context::global_id to 20 bits sourab.gupta
2016-04-22 11:33 ` [PATCH 03/16] drm/i915: return ctx->global_id from intel_execlists_ctx_id() sourab.gupta
2016-04-22 11:33 ` [PATCH 04/16] drm/i915: Add ctx getparam ioctl parameter to retrieve ctx global id sourab.gupta
2016-04-22 11:33 ` [PATCH 05/16] drm/i915: Expose OA sample source to userspace sourab.gupta
2016-04-22 11:33 ` [PATCH 06/16] drm/i915: Framework for capturing command stream based OA reports sourab.gupta
2016-04-22 11:33 ` [PATCH 07/16] drm/i915: flush periodic samples, in case of no pending CS sample requests sourab.gupta
2016-04-22 11:33 ` [PATCH 08/16] drm/i915: Handle the overflow condition for command stream buf sourab.gupta
2016-04-22 11:33 ` sourab.gupta [this message]
2016-04-22 11:33 ` [PATCH 10/16] drm/i915: Add support for having pid output with OA report sourab.gupta
2016-04-22 11:34 ` [PATCH 11/16] drm/i915: Add support for emitting execbuffer tags through OA counter reports sourab.gupta
2016-04-22 11:34 ` [PATCH 12/16] drm/i915: Extend i915 perf framework for collecting timestamps on all gpu engines sourab.gupta
2016-04-22 11:34 ` [PATCH 13/16] drm/i915: Extract raw GPU timestamps from OA reports to forward in perf samples sourab.gupta
2016-04-22 11:34 ` [PATCH 14/16] drm/i915: Support opening multiple concurrent perf streams sourab.gupta
2016-04-22 11:34 ` [PATCH 15/16] drm/i915: Mechanism to forward clock monotonic time in perf samples sourab.gupta
2016-04-22 19:49   ` Chris Wilson
2016-05-09  5:59     ` sourab gupta
2016-05-09  8:06       ` Chris Wilson
2016-04-22 11:34 ` [PATCH 16/16] drm/i915: Support for capturing MMIO register values sourab.gupta
2016-04-22 22:18   ` Chris Wilson

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=1461324845-25755-10-git-send-email-sourab.gupta@intel.com \
    --to=sourab.gupta@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=deepak.s@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.