From patchwork Wed Sep 13 10:52:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 9951017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 73850603F4 for ; Wed, 13 Sep 2017 10:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6622E28FBC for ; Wed, 13 Sep 2017 10:49:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B18C28FC2; Wed, 13 Sep 2017 10:49:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01B8728FBC for ; Wed, 13 Sep 2017 10:49:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74ADE6E814; Wed, 13 Sep 2017 10:49:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 892BA6E7F5 for ; Wed, 13 Sep 2017 10:48:54 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2017 03:48:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,387,1500966000"; d="scan'208";a="151329348" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by fmsmga006.fm.intel.com with ESMTP; 13 Sep 2017 03:48:53 -0700 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Sep 2017 16:22:04 +0530 Message-Id: <1505299928-13809-6-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505299928-13809-1-git-send-email-sagar.a.kamble@intel.com> References: <1505299928-13809-1-git-send-email-sagar.a.kamble@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 5/9] tests/perf: Add testcase to verify tag X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP v2: Updated property enum names. Defined TAG_MASK, set_tag and get_tag for local use. Signed-off-by: Sagar Arun Kamble --- tests/intel_perf_dapc.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/tests/intel_perf_dapc.c b/tests/intel_perf_dapc.c index ccc37b6..2d76e6f 100644 --- a/tests/intel_perf_dapc.c +++ b/tests/intel_perf_dapc.c @@ -138,6 +138,14 @@ enum { local_DRM_I915_PERF_PROP_MAX /* non-ABI */ }; +/* upper 32 bits of rsvd1 field contain tag */ +#define local_I915_EXEC_TAG_MASK (0xffffffff00000000UL) +#define local_i915_execbuffer2_set_tag(eb2, tag) \ + (eb2).rsvd1 = ((eb2).rsvd1 & ~local_I915_EXEC_TAG_MASK) |\ + ((tag << 32) & local_I915_EXEC_TAG_MASK) +#define local_i915_execbuffer2_get_tag(eb2) \ + (((eb2).rsvd1 & local_I915_EXEC_TAG_MASK) >> 32) + static struct { const char *name; size_t size; @@ -532,6 +540,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, @@ -952,6 +970,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 */ + local_DRM_I915_PERF_PROP_ENGINE, I915_EXEC_RENDER, + local_DRM_I915_PERF_PROP_SAMPLE_TAG, true, + local_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, ¶m); + + execbuf.buffer_count = 1; + /* Do a submission with default tag */ + gem_execbuf(drm_fd, &execbuf); + + local_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(); @@ -979,6 +1118,9 @@ igt_main igt_subtest("perf-pid") test_perf_pid(); + igt_subtest("perf-tag") + test_perf_tag(); + igt_fixture { close(drm_fd); }