From patchwork Wed Sep 13 10:52:02 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: 9951003 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 301C96024A for ; Wed, 13 Sep 2017 10:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2289828FBC for ; Wed, 13 Sep 2017 10:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 178BF28FC0; Wed, 13 Sep 2017 10:48:55 +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 96EFD28FBC for ; Wed, 13 Sep 2017 10:48:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D4D9C6E0CF; Wed, 13 Sep 2017 10:48:53 +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 B45F66E0CF for ; Wed, 13 Sep 2017 10:48:52 +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:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,387,1500966000"; d="scan'208";a="151329340" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by fmsmga006.fm.intel.com with ESMTP; 13 Sep 2017 03:48:51 -0700 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Sep 2017 16:22:02 +0530 Message-Id: <1505299928-13809-4-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 3/9] tests/perf: Add testcase to verify ctx id 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 This subtest verifies that the CS perf samples contains proper HW context ID as captured through CONTEXT_PARAM_HW_ID. v2: Updated property enum names. Signed-off-by: Sagar Arun Kamble Reviewed-by: Ewelina Musial --- 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 090c125..44f15a0 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -131,6 +131,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 92b4dee..23d6ffe 100644 --- a/tests/intel_perf_dapc.c +++ b/tests/intel_perf_dapc.c @@ -644,10 +644,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(¶m, 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, ¶m) == -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; @@ -676,6 +694,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); @@ -776,7 +797,8 @@ test_oa_source(void) igt_assert(perf_reports); perf_stream_capture_workload_samples(¶m, perf_reports, - num_reports, report_size); + num_reports, report_size, + NULL); verify_source(perf_reports, num_reports, report_size); free(perf_reports); } @@ -784,6 +806,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 */ + local_DRM_I915_PERF_PROP_ENGINE, I915_EXEC_RENDER, + local_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(¶m, 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(); @@ -805,6 +900,9 @@ igt_main igt_subtest("oa-source") test_oa_source(); + igt_subtest("perf-ctxid") + test_perf_ctxid(); + igt_fixture { close(drm_fd); }