All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagar Arun Kamble <sagar.a.kamble@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/8] tests/perf: Add testcase to verify ctx id
Date: Thu,  7 Sep 2017 15:37:52 +0530	[thread overview]
Message-ID: <1504778877-18822-4-git-send-email-sagar.a.kamble@intel.com> (raw)
In-Reply-To: <1504778877-18822-1-git-send-email-sagar.a.kamble@intel.com>

This subtest verifies that the CS perf samples contains
proper HW context ID as captured through CONTEXT_PARAM_HW_ID.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
---
 lib/ioctl_wrappers.h    |   1 +
 tests/intel_perf_dapc.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 8915edc..e3cdaff 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -130,6 +130,7 @@ struct local_i915_gem_context_param {
 #define LOCAL_CONTEXT_PARAM_GTT_SIZE	0x3
 #define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE	0x4
 #define LOCAL_CONTEXT_PARAM_BANNABLE	0x5
+#define LOCAL_CONTEXT_PARAM_HW_ID	0x6
 	uint64_t value;
 };
 void gem_context_require_bannable(int fd);
diff --git a/tests/intel_perf_dapc.c b/tests/intel_perf_dapc.c
index 8e2f8ce..82cb8e6 100644
--- a/tests/intel_perf_dapc.c
+++ b/tests/intel_perf_dapc.c
@@ -627,10 +627,28 @@ read_perf_reports(int stream_fd,
 	return true;
 }
 
+static unsigned int
+context_get_hw_ctx_id(int fd, unsigned int ctx)
+{
+	struct local_i915_gem_context_param param;
+
+	memset(&param, 0, sizeof(param));
+	param.context = ctx;
+	param.param = LOCAL_CONTEXT_PARAM_HW_ID;
+	param.value = 0;
+	param.size = 0;
+
+	if (__gem_context_get_param(fd, &param) == -EINVAL)
+		igt_assert(param.value == 0);
+
+	return param.value;
+}
+
 static void
 perf_stream_capture_workload_samples(struct drm_i915_perf_open_param *param,
 				     uint8_t *perf_reports,
-				     int num_reports, int report_size)
+				     int num_reports, int report_size,
+				     uint64_t *hw_ctx_id)
 {
 	drm_intel_bufmgr *bufmgr;
 	drm_intel_context *context0;
@@ -659,6 +677,9 @@ retry:
 	igt_assert_eq(ret, 0);
 	igt_assert_neq(ctx_id, 0xffffffff);
 
+	if (hw_ctx_id)
+		*hw_ctx_id = context_get_hw_ctx_id(drm_fd, ctx_id);
+
 	igt_debug("opening i915-perf stream\n");
 	stream_fd = __perf_open(drm_fd, param);
 
@@ -759,7 +780,8 @@ test_oa_source(void)
 		igt_assert(perf_reports);
 
 		perf_stream_capture_workload_samples(&param, perf_reports,
-						     num_reports, report_size);
+						     num_reports, report_size,
+						     NULL);
 		verify_source(perf_reports, num_reports, report_size);
 		free(perf_reports);
 	}
@@ -767,6 +789,79 @@ test_oa_source(void)
 	igt_waitchildren();
 }
 
+struct oa_ctxid_sample {
+	uint64_t ctx_id;
+	uint8_t oa_report[];
+};
+
+static void
+verify_ctxid(uint8_t *perf_reports, int num_reports, size_t report_size,
+	     uint64_t hw_ctx_id)
+{
+	struct oa_ctxid_sample *sample;
+	uint32_t *oa_report;
+
+	for (int i = 0; i < num_reports; i++) {
+		size_t offset = i * report_size;
+
+		sample = (struct oa_ctxid_sample *) (perf_reports + offset);
+		oa_report = (uint32_t *) sample->oa_report;
+
+		igt_debug("read report: ctx_id= %lu, reason = %x, "
+			  "timestamp = %x\n",
+			  sample->ctx_id, oa_report[0], oa_report[1]);
+
+		if (!oa_report[0])
+			igt_assert(sample->ctx_id == hw_ctx_id);
+	}
+}
+
+static void
+test_perf_ctxid(void)
+{
+	uint64_t properties[] = {
+		/* Include OA reports in samples */
+		DRM_I915_PERF_PROP_SAMPLE_OA, true,
+
+		/* OA unit configuration */
+		DRM_I915_PERF_PROP_OA_METRICS_SET, test_metric_set_id,
+		DRM_I915_PERF_PROP_OA_FORMAT, test_oa_format,
+		DRM_I915_PERF_PROP_OA_EXPONENT, oa_exp_1_millisec,
+
+		/* CS parameters */
+		DRM_I915_PERF_PROP_ENGINE, I915_EXEC_RENDER,
+		DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true,
+	};
+	struct drm_i915_perf_open_param param = {
+		.flags = I915_PERF_FLAG_FD_CLOEXEC,
+		.num_properties = sizeof(properties) / 16,
+		.properties_ptr = to_user_pointer(properties),
+	};
+
+	/* should be default, but just to be sure... */
+	write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1);
+
+	igt_fork(child, 1) {
+		int prop_size = ARRAY_SIZE(properties);
+		int num_reports = 10;
+		int report_size = get_perf_report_size(properties, prop_size,
+						       test_oa_format);
+		int total_size = num_reports * report_size;
+		uint8_t *perf_reports = malloc(total_size);
+		uint64_t hw_ctx_id;
+
+		igt_assert(perf_reports);
+
+		perf_stream_capture_workload_samples(&param, perf_reports,
+						     num_reports, report_size,
+						     &hw_ctx_id);
+		verify_ctxid(perf_reports, num_reports, report_size, hw_ctx_id);
+		free(perf_reports);
+	}
+
+	igt_waitchildren();
+}
+
 igt_main
 {
 	igt_skip_on_simulation();
@@ -788,6 +883,9 @@ igt_main
 	igt_subtest("oa-source")
 		test_oa_source();
 
+	igt_subtest("perf-ctxid")
+		test_perf_ctxid();
+
 	igt_fixture {
 		close(drm_fd);
 	}
-- 
1.9.1

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

  parent reply	other threads:[~2017-09-07 10:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 10:07 [PATCH i-g-t 0/8] IGT Testcases for i915 DAPC feature Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 1/8] tests/perf: Rename perf test to intel_perf Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 2/8] tests/perf: Test i915 assisted command stream based perf metrics capture Sagar Arun Kamble
2017-09-07 10:07 ` Sagar Arun Kamble [this message]
2017-09-07 10:07 ` [PATCH i-g-t 4/8] tests/perf: Add testcase to verify pid Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 5/8] tests/perf: Add testcase to verify tag Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 6/8] tests/perf: Add testcase to verify timestamps Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 7/8] tests/perf: Add testcase to verify mmio Sagar Arun Kamble
2017-09-07 10:07 ` [PATCH i-g-t 8/8] tests/perf: Add testcase to verify concurrent streams Sagar Arun Kamble
2017-09-07 12:04 ` ✗ Fi.CI.BAT: failure for IGT Testcases for i915 DAPC feature 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=1504778877-18822-4-git-send-email-sagar.a.kamble@intel.com \
    --to=sagar.a.kamble@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.