From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Subject: [PATCH i-g-t 3/6] tests/intel/xe_oa: Sanity check PEC report data for TestOa metric set
Date: Tue, 8 Apr 2025 11:12:07 -0700 [thread overview]
Message-ID: <20250408181210.1052760-4-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20250408181210.1052760-1-ashutosh.dixit@intel.com>
Implement sanity checking for Xe2 PEC OA reports. Previously there was
sanity checking only for Xe1 OA reports, but no sanity checking for Xe2 PEC
OA reports.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
tests/intel/xe_oa.c | 121 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 119 insertions(+), 2 deletions(-)
diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
index 2440101900..eaf97ae0df 100644
--- a/tests/intel/xe_oa.c
+++ b/tests/intel/xe_oa.c
@@ -966,6 +966,115 @@ accumulator_print(struct accumulator *accumulator, const char *title)
igt_debug("\tC%u = %"PRIu64"\n", i, deltas[idx++]);
}
+
+/*
+ * pec_sanity_check_reports() uses the following properties of the TestOa
+ * metric set with the "576B_PEC64LL" or XE_OA_FORMAT_PEC64u64 format. See
+ * e.g. lib/xe/oa-configs/oa-lnl.xml.
+ *
+ * If pec[] is the array of pec qwords following the report header (Bspec
+ * 60942) then we have:
+ *
+ * pec[2] : test_event1_cycles
+ * pec[3] : test_event1_cycles_xecore0
+ * pec[4] : test_event1_cycles_xecore1
+ * pec[5] : test_event1_cycles_xecore2
+ * pec[6] : test_event1_cycles_xecore3
+ * pec[21] : test_event1_cycles_xecore4
+ * pec[22] : test_event1_cycles_xecore5
+ * pec[23] : test_event1_cycles_xecore6
+ * pec[24] : test_event1_cycles_xecore7
+ *
+ * test_event1_cycles_xecore* increment with every clock, so they increment
+ * the same as gpu_ticks in report headers in successive reports. And
+ * test_event1_cycles increment by 'gpu_ticks * num_xecores'.
+ *
+ * These equations are not exact due to fluctuations, but are precise when
+ * averaged over long periods.
+ */
+static void pec_sanity_check_one(const u32 *report)
+{
+ int xecore_idx[] = {3, 4, 5, 6, 21, 22, 23, 24};
+ u64 first, *pec = (u64 *)(report + 8);
+
+ igt_debug("\ttest_event1_cycles: %#lx\n", pec[2]);
+ for (int i = 0; i < ARRAY_SIZE(xecore_idx); i++)
+ igt_debug("\ttest_event1_cycles_xecore %d: %#lx\n", i, pec[xecore_idx[i]]);
+
+ /* Compare against the first non-zero test_event1_cycles_xecore* */
+ for (int i = 0; i < ARRAY_SIZE(xecore_idx); i++) {
+ first = pec[xecore_idx[i]];
+ if (first)
+ break;
+ }
+
+ /* test_event1_cycles_xecore* should be within an epsilon of each other */
+ for (int i = 0; i < ARRAY_SIZE(xecore_idx); i++) {
+ igt_debug("n %d: pec[n] %#lx, first %#lx\n",
+ xecore_idx[i], pec[xecore_idx[i]], first);
+ /* 0 value for pec[xecore_idx[i]] indicates missing xecore */
+ if (pec[xecore_idx[i]])
+ assert_within_epsilon(pec[xecore_idx[i]], first, 0.1);
+ }
+
+ igt_debug("first * num_xecores: %#lx, pec[2] %#lx\n",
+ first * intel_xe_perf->devinfo.n_eu_sub_slices, pec[2]);
+ /* test_event1_cycles should be close to (test_event1_cycles_xecore* * num_xecores) */
+ assert_within_epsilon(first * intel_xe_perf->devinfo.n_eu_sub_slices, pec[2], 0.1);
+}
+
+static void pec_sanity_check_two(const u32 *report0, const u32 *report1,
+ struct intel_xe_perf_metric_set *set)
+{
+ u64 tick_delta = oa_tick_delta(report1, report0, set->perf_oa_format);
+ int xecore_idx[] = {3, 4, 5, 6, 21, 22, 23, 24};
+ u64 *pec0 = (u64 *)(report0 + 8);
+ u64 *pec1 = (u64 *)(report1 + 8);
+
+ igt_debug("tick delta = %#lx\n", tick_delta);
+
+ /* Difference in test_event1_cycles_xecore* values should be close to tick_delta */
+ for (int i = 0; i < ARRAY_SIZE(xecore_idx); i++) {
+ igt_debug("n %d: pec1[n] - pec0[n] %#lx, tick delta %#lx\n",
+ xecore_idx[i], pec1[xecore_idx[i]] - pec0[xecore_idx[i]], tick_delta);
+ /* 0 value for pec[xecore_idx[i]] indicates missing xecore */
+ if (pec1[xecore_idx[i]] && pec0[xecore_idx[i]])
+ assert_within_epsilon(pec1[xecore_idx[i]] - pec0[xecore_idx[i]],
+ tick_delta, 0.1);
+ /* Same test_event1_cycles_xecore* should be present in all reports */
+ if (pec1[xecore_idx[i]])
+ igt_assert(pec0[xecore_idx[i]]);
+ }
+
+ igt_debug("pec1[2] - pec0[2] %#lx, tick_delta * num_xecores: %#lx\n",
+ pec1[2] - pec0[2], tick_delta * intel_xe_perf->devinfo.n_eu_sub_slices);
+ /* Difference in test_event1_cycles should be close to (tick_delta * num_xecores) */
+ assert_within_epsilon(pec1[2] - pec0[2],
+ tick_delta * intel_xe_perf->devinfo.n_eu_sub_slices, 0.1);
+}
+
+/* Sanity check Xe2+ PEC reports. Note: report format must be @set->perf_oa_format */
+static void pec_sanity_check_reports(const u32 *report0, const u32 *report1,
+ struct intel_xe_perf_metric_set *set)
+{
+ if (igt_run_in_simulation() || intel_graphics_ver(devid) < IP_VER(20, 0)) {
+ igt_debug("%s: Skip checking PEC reports in simulation or Xe1\n", __func__);
+ return;
+ }
+
+ if (strcmp(set->name, "TestOa")) {
+ igt_debug("%s: Can't check reports for metric set %s\n", __func__, set->name);
+ return;
+ }
+
+ dump_report(report0, set->perf_raw_size, "pec_report0");
+ dump_report(report1, set->perf_raw_size, "pec_report1");
+
+ pec_sanity_check_one(report0);
+ pec_sanity_check_one(report1);
+ pec_sanity_check_two(report0, report1, set);
+}
+
/* The TestOa metric set is designed so */
static void
sanity_check_reports(const uint32_t *oa_report0, const uint32_t *oa_report1,
@@ -1589,6 +1698,9 @@ static void test_oa_formats(const struct drm_xe_engine_class_instance *hwe)
print_reports(oa_report0, oa_report1, i);
sanity_check_reports(oa_report0, oa_report1, i);
+
+ if (i == metric_set(hwe)->perf_oa_format)
+ pec_sanity_check_reports(oa_report0, oa_report1, metric_set(hwe));
}
}
@@ -2527,8 +2639,10 @@ test_non_zero_reason(const struct drm_xe_engine_class_instance *hwe, size_t oa_b
igt_assert_neq(reason, 0);
- if (last_report)
+ if (last_report) {
sanity_check_reports(last_report, report, fmt);
+ pec_sanity_check_reports(last_report, report, metric_set(hwe));
+ }
last_report = report;
}
@@ -4266,9 +4380,12 @@ static void mmap_check_reports(void *oa_vaddr, uint32_t oa_size,
continue;
timer_reports++;
- if (timer_reports >= 3)
+ if (timer_reports >= 3) {
sanity_check_reports(reports - 2 * report_words,
reports - report_words, fmt);
+ pec_sanity_check_reports(reports - 2 * report_words,
+ reports - report_words, metric_set(hwe));
+ }
}
igt_assert(timer_reports >= 3);
--
2.48.1
next prev parent reply other threads:[~2025-04-08 18:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 18:12 [PATCH i-g-t 0/6] Sanity check Xe2 PEC OA reports Ashutosh Dixit
2025-04-08 18:12 ` [PATCH i-g-t 1/6] tests/intel/xe_oa: Rename check_reports to mmap_check_reports Ashutosh Dixit
2025-04-14 22:20 ` Umesh Nerlige Ramappa
2025-04-08 18:12 ` [PATCH i-g-t 2/6] tests/intel/xe_oa: Fix oa_tick_delta Ashutosh Dixit
2025-04-14 22:21 ` Umesh Nerlige Ramappa
2025-04-08 18:12 ` Ashutosh Dixit [this message]
2025-04-14 23:16 ` [PATCH i-g-t 3/6] tests/intel/xe_oa: Sanity check PEC report data for TestOa metric set Umesh Nerlige Ramappa
2025-04-15 16:57 ` Dixit, Ashutosh
2025-04-16 16:20 ` Umesh Nerlige Ramappa
2025-04-22 19:42 ` Dixit, Ashutosh
2025-04-08 18:12 ` [PATCH i-g-t 4/6] tests/intel/xe_oa: Only sanity check timer PEC reports Ashutosh Dixit
2025-04-14 22:36 ` Umesh Nerlige Ramappa
2025-04-08 18:12 ` [PATCH i-g-t 5/6] tests/intel/xe_oa: Reduce test_non_zero_reason execution time Ashutosh Dixit
2025-04-14 22:40 ` Umesh Nerlige Ramappa
2025-04-15 16:49 ` Dixit, Ashutosh
2025-04-08 18:12 ` [PATCH i-g-t 6/6] tests/intel/xe_oa: Use TestOa metric set also for OAM Ashutosh Dixit
2025-04-14 22:41 ` Umesh Nerlige Ramappa
2025-04-14 23:22 ` Dixit, Ashutosh
2025-04-08 19:58 ` ✓ i915.CI.BAT: success for Sanity check Xe2 PEC OA reports Patchwork
2025-04-08 20:04 ` ✓ Xe.CI.BAT: " Patchwork
2025-04-08 21:04 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-08 21:42 ` ✗ i915.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-04-22 19:34 [PATCH i-g-t 0/6] " Ashutosh Dixit
2025-04-22 19:34 ` [PATCH i-g-t 3/6] tests/intel/xe_oa: Sanity check PEC report data for TestOa metric set Ashutosh Dixit
2025-05-02 22:00 ` Umesh Nerlige Ramappa
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=20250408181210.1052760-4-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=umesh.nerlige.ramappa@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox