From patchwork Wed Aug 23 09:43:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 9916965 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 28D81602CB for ; Wed, 23 Aug 2017 09:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B5CD28965 for ; Wed, 23 Aug 2017 09:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1023F2897C; Wed, 23 Aug 2017 09:43:31 +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 8C29F28965 for ; Wed, 23 Aug 2017 09:43:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EBE56E565; Wed, 23 Aug 2017 09:43:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 235976E564 for ; Wed, 23 Aug 2017 09:43:28 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 23 Aug 2017 02:43:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,416,1498546800"; d="scan'208"; a="1209335639" Received: from delly.ld.intel.com ([10.103.239.215]) by fmsmga002.fm.intel.com with ESMTP; 23 Aug 2017 02:43:27 -0700 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Wed, 23 Aug 2017 10:43:13 +0100 Message-Id: <20170823094318.18966-6-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170823094318.18966-1-lionel.g.landwerlin@intel.com> References: <20170823094318.18966-1-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH v2 05/10] tests/perf: remove frequency related changes 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 Experience shows that most of the issues we face with periodicity of the reports produced by the OA unit are related to power management, not frequency. Signed-off-by: Lionel Landwerlin --- tests/perf.c | 143 +++++------------------------------------------------------ 1 file changed, 10 insertions(+), 133 deletions(-) diff --git a/tests/perf.c b/tests/perf.c index 1b441601..b7deb9b2 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -293,12 +293,9 @@ static int card = -1; static int n_eus; static uint64_t test_metric_set_id = UINT64_MAX; -static uint64_t gt_min_freq_mhz_saved = 0; -static uint64_t gt_max_freq_mhz_saved = 0; -static uint64_t gt_min_freq_mhz = 0; -static uint64_t gt_max_freq_mhz = 0; static uint64_t timestamp_frequency = 12500000; +static uint64_t gt_max_freq_mhz = 0; static enum drm_i915_oa_format test_oa_format; static bool *undefined_a_counters; static uint64_t oa_exp_1_millisec; @@ -402,16 +399,6 @@ sysfs_read(const char *file) return read_u64_file(buf); } -static void -sysfs_write(const char *file, uint64_t val) -{ - char buf[512]; - - snprintf(buf, sizeof(buf), "/sys/class/drm/card%d/%s", card, file); - - write_u64_file(buf, val); -} - static char * read_debugfs_record(int device, const char *file, const char *key) { @@ -990,54 +977,6 @@ init_sys_info(void) return try_read_u64_file(buf, &test_metric_set_id); } -static void -gt_frequency_range_save(void) -{ - gt_min_freq_mhz_saved = sysfs_read("gt_min_freq_mhz"); - gt_max_freq_mhz_saved = sysfs_read("gt_max_freq_mhz"); - - gt_min_freq_mhz = gt_min_freq_mhz_saved; - gt_max_freq_mhz = gt_max_freq_mhz_saved; -} - -static void -gt_frequency_pin(int gt_freq_mhz) -{ - igt_debug("requesting pinned GT freq = %dmhz\n", gt_freq_mhz); - - if (gt_freq_mhz > gt_max_freq_mhz) { - sysfs_write("gt_max_freq_mhz", gt_freq_mhz); - sysfs_write("gt_min_freq_mhz", gt_freq_mhz); - } else { - sysfs_write("gt_min_freq_mhz", gt_freq_mhz); - sysfs_write("gt_max_freq_mhz", gt_freq_mhz); - } - gt_min_freq_mhz = gt_freq_mhz; - gt_max_freq_mhz = gt_freq_mhz; -} - -static void -gt_frequency_range_restore(void) -{ - igt_debug("restoring GT frequency range: min = %dmhz, max =%dmhz, current: min=%dmhz, max=%dmhz\n", - (int)gt_min_freq_mhz_saved, - (int)gt_max_freq_mhz_saved, - (int)gt_min_freq_mhz, - (int)gt_max_freq_mhz); - - /* Assume current min/max are the same */ - if (gt_min_freq_mhz_saved > gt_max_freq_mhz) { - sysfs_write("gt_max_freq_mhz", gt_max_freq_mhz_saved); - sysfs_write("gt_min_freq_mhz", gt_min_freq_mhz_saved); - } else { - sysfs_write("gt_min_freq_mhz", gt_min_freq_mhz_saved); - sysfs_write("gt_max_freq_mhz", gt_max_freq_mhz_saved); - } - - gt_min_freq_mhz = gt_min_freq_mhz_saved; - gt_max_freq_mhz = gt_max_freq_mhz_saved; -} - static int i915_read_reports_until_timestamp(enum drm_i915_oa_format oa_format, uint8_t *buf, @@ -1614,33 +1553,9 @@ test_oa_formats(void) } static void -test_oa_exponents(int gt_freq_mhz) +test_oa_exponents(void) { - uint32_t freq_margin; - - /* This test tries to use the sysfs interface for pinning the GT - * frequency so we have another point of reference for comparing with - * the clock frequency as derived from OA reports. - * - * This test has been finicky to stabilise while the - * gt_min/max_freq_mhz files in sysfs don't seem to be a reliable - * mechanism for fixing the gpu frequency. - * - * Since these unit tests are focused on the OA unit not the ability to - * pin the frequency via sysfs we make the test account for pinning not - * being reliable and read back the current frequency for each - * iteration of this test to take this into account. - */ - gt_frequency_pin(gt_freq_mhz); - - igt_debug("Testing OA timer exponents with requested GT frequency = %dmhz\n", - gt_freq_mhz); - - /* allow a +- 10% error margin when checking that the frequency - * calculated from the OA reports matches the frequency according to - * sysfs. - */ - freq_margin = gt_freq_mhz * 0.1; + igt_debug("Testing OA timer exponents\n"); /* It's asking a lot to sample with a 160 nanosecond period and the * test can fail due to buffer overflows if it wasn't possible to @@ -1655,7 +1570,6 @@ test_oa_exponents(int gt_freq_mhz) uint32_t clock_delta; uint32_t freq; int n_tested = 0; - int n_freq_matches = 0; /* The exponent is effectively selecting a bit in the timestamp * to trigger reports on and so in practice we expect the raw @@ -1665,15 +1579,10 @@ test_oa_exponents(int gt_freq_mhz) expected_timestamp_delta = 2 << i; for (int j = 0; n_tested < 10 && j < 100; j++) { - int gt_freq_mhz_0, gt_freq_mhz_1; uint32_t ticks0, ticks1; - gt_freq_mhz_0 = sysfs_read("gt_act_freq_mhz"); - - igt_debug("ITER %d: testing OA exponent %d (period = %"PRIu64"ns) with sysfs GT freq = %dmhz +- %u\n", - j, i, - oa_exponent_to_ns(i), - gt_freq_mhz_0, freq_margin); + igt_debug("ITER %d: testing OA exponent %d (period = %"PRIu64"ns)\n", + j, i, oa_exponent_to_ns(i)); open_and_read_2_oa_reports(test_oa_format, i, /* exponent */ @@ -1682,16 +1591,6 @@ test_oa_exponents(int gt_freq_mhz) true); /* timer triggered reports only */ - gt_freq_mhz_1 = sysfs_read("gt_act_freq_mhz"); - - /* If it looks like the frequency has changed according - * to sysfs then skip looking at this pair of reports - */ - if (gt_freq_mhz_0 != gt_freq_mhz_1) { - igt_debug("skipping OA reports pair due to GT frequency change according to sysfs\n"); - continue; - } - timestamp_delta = oa_report1[1] - oa_report0[1]; igt_assert_neq(timestamp_delta, 0); @@ -1714,31 +1613,13 @@ test_oa_exponents(int gt_freq_mhz) igt_debug("ITER %d: time delta = %"PRIu32"(ns) clock delta = %"PRIu32" freq = %"PRIu32"(mhz)\n", j, time_delta, clock_delta, freq); - if (freq < (gt_freq_mhz_1 + freq_margin) && - freq > (gt_freq_mhz_1 - freq_margin)) - n_freq_matches++; - n_tested++; } if (n_tested < 10) igt_debug("sysfs frequency pinning too unstable for cross-referencing with OA derived frequency"); igt_assert_eq(n_tested, 10); - - igt_debug("number of iterations with expected clock frequency = %d\n", - n_freq_matches); - - /* Don't assert the calculated frequency for extremely short - * durations. - * - * Allow some mismatches since can't be can't be sure about - * frequency changes between sysfs reads. - */ - if (i > 3) - igt_assert(n_freq_matches >= 7); } - - gt_frequency_range_restore(); } /* The OA exponent selects a timestamp counter bit to trigger reports on. @@ -3963,11 +3844,11 @@ igt_main igt_require(init_sys_info()); - gt_frequency_range_save(); - write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1); write_u64_file("/proc/sys/dev/i915/oa_max_sample_rate", 100000); + gt_max_freq_mhz = sysfs_read("gt_boost_freq_mhz"); + render_copy = igt_get_render_copyfunc(devid); igt_require_f(render_copy, "no render-copy function\n"); } @@ -3994,11 +3875,9 @@ igt_main test_invalid_oa_exponent(); igt_subtest("low-oa-exponent-permissions") test_low_oa_exponent_permissions(); - igt_subtest("oa-exponents") { - test_oa_exponents(450); - test_oa_exponents(550); - } - + igt_subtest("oa-exponents") + test_oa_exponents(); + igt_subtest("per-context-mode-unprivileged") { igt_require(IS_HASWELL(devid)); test_per_context_mode_unprivileged(); @@ -4063,8 +3942,6 @@ igt_main write_u64_file("/proc/sys/dev/i915/oa_max_sample_rate", 100000); write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1); - gt_frequency_range_restore(); - close(drm_fd); } }