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 5/8] tests/perf: Add testcase to verify tag
Date: Thu,  7 Sep 2017 15:37:54 +0530	[thread overview]
Message-ID: <1504778877-18822-6-git-send-email-sagar.a.kamble@intel.com> (raw)
In-Reply-To: <1504778877-18822-1-git-send-email-sagar.a.kamble@intel.com>

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
---
 tests/intel_perf_dapc.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)

diff --git a/tests/intel_perf_dapc.c b/tests/intel_perf_dapc.c
index afd49f4..a9903fb 100644
--- a/tests/intel_perf_dapc.c
+++ b/tests/intel_perf_dapc.c
@@ -515,6 +515,16 @@ get_perf_report_size(uint64_t *properties, int prop_size, int format_id)
 	return sample_size;
 }
 
+static size_t
+get_perf_report_size_nonoa(uint64_t *properties, int prop_size)
+{
+	size_t sample_size = 0;
+
+	sample_size += get_oa_report_offset(properties, prop_size);
+
+	return sample_size;
+}
+
 static bool
 read_perf_reports(int stream_fd,
 		  uint8_t *perf_reports,
@@ -935,6 +945,127 @@ test_perf_pid(void)
 	igt_waitchildren();
 }
 
+struct ts_tag_sample {
+	uint64_t tag;
+	uint64_t ts;
+};
+
+static void
+verify_tag(uint8_t *perf_reports, int num_reports, size_t report_size,
+	   uint64_t tag, int match_index)
+{
+	struct ts_tag_sample *sample;
+
+	for (int i = 0; i < num_reports; i++) {
+		size_t offset = i * report_size;
+
+		sample = (struct ts_tag_sample *) (perf_reports + offset);
+
+		igt_debug("read report: tag= %lu, timestamp = %lu\n",
+			  sample->tag, sample->ts);
+
+		if (i < match_index)
+			igt_assert(sample->tag != tag);
+		else
+			igt_assert(sample->tag == tag);
+	}
+}
+
+#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
+#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
+
+static void
+test_perf_tag(void)
+{
+	uint64_t properties[] = {
+		/* CS parameters */
+		DRM_I915_PERF_PROP_ENGINE, I915_EXEC_RENDER,
+		DRM_I915_PERF_PROP_SAMPLE_TAG, true,
+		DRM_I915_PERF_PROP_SAMPLE_TS, 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) {
+		const int gen = intel_gen(intel_get_drm_devid(drm_fd));
+		int prop_size = ARRAY_SIZE(properties);
+		int report_size = get_perf_report_size_nonoa(properties,
+							     prop_size);
+		int num_reports = 4;
+		int total_size = num_reports * report_size;
+		int stream_fd;
+		bool valid_data = false;
+		uint64_t test_tag = 0xFEED0001;
+		uint8_t *perf_reports = NULL;
+		const uint32_t bbe = MI_BATCH_BUFFER_END;
+		struct drm_i915_gem_exec_object2 object[1];
+		struct drm_i915_gem_execbuffer2 execbuf;
+		drm_intel_bufmgr *bufmgr;
+		drm_intel_context *context0;
+		uint32_t ctx_id = 0xffffffff; /* invalid id */
+		int ret;
+
+		memset(&execbuf, 0, sizeof(execbuf));
+		execbuf.buffers_ptr = to_user_pointer(object);
+		execbuf.flags = I915_EXEC_RENDER;
+		execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
+		execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
+		if (gen < 6)
+			execbuf.flags |= I915_EXEC_SECURE;
+
+		memset(object, 0, sizeof(object));
+		object[0].handle = gem_create(drm_fd, 4096);
+		gem_write(drm_fd, object[0].handle, 0, &bbe, sizeof(bbe));
+
+		bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
+		drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+
+		context0 = drm_intel_gem_context_create(bufmgr);
+		igt_assert(context0);
+
+		ret = drm_intel_gem_context_get_id(context0, &ctx_id);
+		igt_assert_eq(ret, 0);
+		igt_assert_neq(ctx_id, 0xffffffff);
+
+		perf_reports = malloc(total_size);
+		igt_assert(perf_reports);
+
+		igt_debug("opening render i915-perf stream\n");
+		stream_fd = __perf_open(drm_fd, &param);
+
+		execbuf.buffer_count = 1;
+		/* Do a submission with default tag */
+		gem_execbuf(drm_fd, &execbuf);
+
+		i915_execbuffer2_set_tag(execbuf, (uint64_t)test_tag);
+		/* Now submit with user tag */
+		gem_execbuf(drm_fd, &execbuf);
+
+		gem_close(drm_fd, object[0].handle);
+
+		drm_intel_gem_context_destroy(context0);
+		drm_intel_bufmgr_destroy(bufmgr);
+
+		valid_data = read_perf_reports(stream_fd, perf_reports,
+					       num_reports, report_size,
+					       false);
+		igt_assert(valid_data);
+		close(stream_fd);
+
+		igt_debug("Verify tag: %lu\n", test_tag);
+		verify_tag(perf_reports, num_reports, report_size,
+			   test_tag, 2);
+		free(perf_reports);
+	}
+	igt_waitchildren();
+}
+
 igt_main
 {
 	igt_skip_on_simulation();
@@ -962,6 +1093,9 @@ igt_main
 	igt_subtest("perf-pid")
 		test_perf_pid();
 
+	igt_subtest("perf-tag")
+		test_perf_tag();
+
 	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 ` [PATCH i-g-t 3/8] tests/perf: Add testcase to verify ctx id Sagar Arun Kamble
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 ` Sagar Arun Kamble [this message]
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-6-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.