Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 25/27] xe/oa/mdapi-xml-convert: Add support for 576B_PEC64LL format
Date: Fri,  7 Jun 2024 13:08:45 -0700	[thread overview]
Message-ID: <20240607200847.1964629-26-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20240607200847.1964629-1-ashutosh.dixit@intel.com>

From: José Roberto de Souza <jose.souza@intel.com>

Xe2 don't use the 256bytes long format, instead it uses a 576bytes
long with 64 PEC fields that are 64 bits long.
This patch fixes the xe2 definition and add the parser for this format.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 lib/xe/oa-configs/codegen.py           |  5 ++
 lib/xe/oa-configs/mdapi-xml-convert.py | 76 +++++++++++++++++++++-----
 lib/xe/xe_oa.h                         |  1 +
 3 files changed, 67 insertions(+), 15 deletions(-)

diff --git a/lib/xe/oa-configs/codegen.py b/lib/xe/oa-configs/codegen.py
index f078ef9498..51498f803d 100644
--- a/lib/xe/oa-configs/codegen.py
+++ b/lib/xe/oa-configs/codegen.py
@@ -128,6 +128,7 @@ class Set:
         return self.xml.find(path)
 
 
+#TODO add SqidiTotalCount, L3BankTotalCount, L3NodeTotalCount
 hw_vars_mapping = {
     "$EuCoresTotalCount": { 'c': "perf->devinfo.n_eus", 'desc': "The total number of execution units" },
     "$EuSlicesTotalCount": { 'c': "perf->devinfo.n_eu_slices" },
@@ -159,6 +160,10 @@ hw_vars_mapping = {
     "$GpuMaxFrequency": { 'c': "perf->devinfo.gt_max_freq" },
     "$SkuRevisionId": { 'c': "perf->devinfo.revision" },
     "$QueryMode": { 'c': "perf->devinfo.query_mode" },
+
+    "$ComputeEngineTotalCount": { 'c': "perf->devinfo.n_eus", 'desc': "The total number of execution units" },
+
+    "$CopyEngineTotalCount": { 'c': "perf->devinfo.n_eus", 'desc': "The total number of execution units" },
 }
 
 def is_hw_var(name):
diff --git a/lib/xe/oa-configs/mdapi-xml-convert.py b/lib/xe/oa-configs/mdapi-xml-convert.py
index 575b53e955..602a3965af 100755
--- a/lib/xe/oa-configs/mdapi-xml-convert.py
+++ b/lib/xe/oa-configs/mdapi-xml-convert.py
@@ -149,12 +149,10 @@ mtl_chipset_oam_samedia_params = {
     }
 }
 
-# FIXME: everything except oa_report_size is incorrect here
-xe2_chipset_params = {
-    'a_offset': 16,
-    'b_offset': 192,
-    'c_offset': 224,
+xe2_chipset_params_pec = {
+    'pec_offset': 32,
     'oa_report_size': 576,
+    # TODO: Not sure about the configs below
     'config_reg_blacklist': {
         0x2364, # OACTXID
     },
@@ -183,7 +181,11 @@ mtl_chipset_oa_formats = {
 }
 
 xe2_chipset_oa_formats = {
-    '256B_GENERIC_NOA16': xe2_chipset_params,
+    '576B_PEC64LL': xe2_chipset_params_pec,
+    # We only care about 576B_PEC64LL metrics in Xe2, entries below is just to
+    # surpress warnings
+    '256B_GENERIC_NOA16': xehpsdv_chipset_params,
+    '128B_MPEC8_NOA16': mtl_chipset_oam_samedia_params,
 }
 
 chipsets = {
@@ -209,8 +211,6 @@ chipsets = {
 
 xehp_plus = ( 'ACM', 'MTL' )
 
-xe2_plus = ( 'LNL' )
-
 register_types = { 'OA', 'NOA', 'FLEX', 'PM' }
 
 default_set_blacklist = { "RenderDX1x", # TODO: rename to something non 'DX'
@@ -298,6 +298,46 @@ def read_token_to_rpn_read_oam(chipset, token, raw_offsets, oa_format):
 
     assert 0
 
+def read_token_to_rpn_read_pec(chipset, token, raw_offsets, oa_format):
+    width, offset_str = token.split('@')
+    offset = int(offset_str, 16)
+
+    if width != 'qw':
+        assert 0
+
+    if raw_offsets:
+        pec_offset = chipsets[chipset][oa_format]['pec_offset']
+
+        if offset < pec_offset:
+            if offset == 8:
+                return "GPU_TIME 0 READ"
+            elif offset == 24:
+                return "GPU_CLOCK 0 READ"
+            else:
+                assert 0
+        else:
+            pec_cnt_offset = int((offset - pec_offset) / 8)
+
+            return "PEC " + str(pec_cnt_offset) + " READ"
+    else:
+        # Location in the accumulated deltas
+        idx = int(offset / 8)
+
+        if idx == 0:
+            return "GPU_TIME 0 READ"
+        elif idx == 1:
+            return "GPU_CLOCK 0 READ"
+        else:
+            idx = idx - 2;
+            pec_cnt_offset = str(idx)
+            pec_high_low_text = "low"
+            if (offset % 8) > 0:
+               pec_high_low_text = "high"
+
+            return "PEC " + pec_cnt_offset + " READ"
+
+    assert 0
+
 def read_token_to_rpn_read_oag(chipset, token, raw_offsets, oa_format):
     width, offset_str = token.split('@')
 
@@ -374,9 +414,6 @@ def read_token_to_rpn_read_oag(chipset, token, raw_offsets, oa_format):
                 return "C " + str(idx - 48) + " READ"
             else:
                 return "{0} READ".format(read_value(chipset, offset, oa_format))
-        elif chipset in xe2_plus:
-            # FIXME: skip all metrics to retain just the registers
-                return "GPU_TIME 0 READ"
         else:
             # For Gen8+ the array of accumulated counters is
             # assumed to start with a GPU_TIME then GPU_CLOCK,
@@ -405,6 +442,9 @@ def read_token_to_rpn_read(chipset, token, raw_offsets, oa_format):
     if oa_format in ['192B_MPEC8LL_NOA16', '128B_MPEC8_NOA16']:
         return read_token_to_rpn_read_oam(chipset, token, raw_offsets, oa_format)
 
+    if oa_format in ['576B_PEC64LL']:
+        return read_token_to_rpn_read_pec(chipset, token, raw_offsets, oa_format)
+
     assert 0
 
 def replace_read_tokens_with_rpn_read_ops(chipset, oa_format, equation, raw_offsets):
@@ -905,6 +945,8 @@ for arg in args.xml:
                 mdapi_counter.set('NormalizationEquation', '$GpuCoreClocks 1000000000 UMUL $GpuTime UDIV')
                 #mdapi_counter.set('DeltaReportReadEquation', '$GpuCoreClocks $GpuTime UDIV')
 
+            if mdapi_counter.get('SymbolName') == "ResultUncertainty":
+                continue
 
             symbol_name = oa_registry.Registry.sanitize_symbol_name(mdapi_counter.get('SymbolName'))
 
@@ -992,11 +1034,15 @@ for arg in args.xml:
             # XXX: As a special case, we override the raw and delta report
             # equations for the GpuTime counters, which seem inconsistent
             if mdapi_counter.get('SymbolName') == "GpuTime":
-                mdapi_counter.set('DeltaReportReadEquation', "qw@0x0 1000000000 UMUL $GpuTimestampFrequency UDIV")
-                if chipset == 'MTL' and oa_format != '256B_GENERIC_NOA16':
-                    mdapi_counter.set('SnapshotReportReadEquation', "qw@0x08 1000000000 UMUL $GpuTimestampFrequency UDIV")
+                if oa_format == '576B_PEC64LL':
+                   mdapi_counter.set('DeltaReportReadEquation', "qw@0x0 1000000000 UMUL $GpuTimestampFrequency UDIV")
+                   mdapi_counter.set('SnapshotReportReadEquation', "qw@0x08 1000000000 UMUL $GpuTimestampFrequency UDIV")
                 else:
-                    mdapi_counter.set('SnapshotReportReadEquation', "dw@0x04 1000000000 UMUL $GpuTimestampFrequency UDIV")
+                   mdapi_counter.set('DeltaReportReadEquation', "qw@0x0 1000000000 UMUL $GpuTimestampFrequency UDIV")
+                   if chipset == 'MTL' and oa_format != '256B_GENERIC_NOA16':
+                      mdapi_counter.set('SnapshotReportReadEquation', "qw@0x08 1000000000 UMUL $GpuTimestampFrequency UDIV")
+                   else:
+                      mdapi_counter.set('SnapshotReportReadEquation', "dw@0x04 1000000000 UMUL $GpuTimestampFrequency UDIV")
 
             availability = fixup_equation(mdapi_counter.get('AvailabilityEquation'))
             if availability == "":
diff --git a/lib/xe/xe_oa.h b/lib/xe/xe_oa.h
index c16177ec8e..f6f2768b00 100644
--- a/lib/xe/xe_oa.h
+++ b/lib/xe/xe_oa.h
@@ -275,6 +275,7 @@ struct intel_xe_perf_metric_set {
 	int b_offset;
 	int c_offset;
 	int perfcnt_offset;
+	int pec_offset;
 
 	const struct intel_xe_perf_register_prog *b_counter_regs;
 	uint32_t n_b_counter_regs;
-- 
2.41.0


  parent reply	other threads:[~2024-06-07 20:09 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 20:08 [PATCH i-g-t v3 00/27] Intel Xe OA IGT's Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 01/27] lib/xe/oa: Import OA metric generation files from i915 Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 02/27] lib/xe/oa: Add LNL metric guids Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 03/27] lib/xe/oa: Add OA LNL metrics (oa_lnl.xml) Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 04/27] lib/xe/oa: Add truncated legacy Xe1 metrics XML's Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 05/27] lib/xe/oa: Generate LNL metrics/registers files Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 06/27] lib/xe/oa: Switch generated files to Xe namespace Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 07/27] drm-uapi/xe: Sync with Perf/OA changes Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 08/27] lib/xe: Complete xe_oa lib functionality Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 09/27] tests/intel/xe_query: Add OA units query test Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 10/27] tests/intel/xe_oa: Add first tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 11/27] tests/intel/xe_oa: Add some negative tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 12/27] tests/intel/xe_oa: Add "oa-formats" subtest Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 13/27] tests/intel/xe_oa: Add oa exponent tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 14/27] tests/intel/xe_oa: buffer-fill, non-zero-reason, enable-disable Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 15/27] tests/intel/xe_oa: blocking and polling tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 16/27] tests/intel/xe_oa: OAR/OAC tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 17/27] tests/intel/xe_oa: Exclusive/concurrent access, rc6 and stress open close Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 18/27] tests/intel/xe_oa: add remove OA config tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 19/27] tests/intel/xe_oa: OA buffer mmap tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 20/27] tests/intel/xe_oa: Register whitelisting and MMIO trigger tests Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 21/27] lib/xe/oa: Add xe_oa_data_reader to IGT lib Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 22/27] tools/xe-perf: Add xe_perf_recorder Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 23/27] tools/xe-perf: xe_perf_reader, xe_perf_control and xe_perf_configs Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 24/27] xe/oa: Fix invalid escape warnings Ashutosh Dixit
2024-06-07 20:08 ` Ashutosh Dixit [this message]
2024-06-07 20:08 ` [PATCH i-g-t 26/27] xe/oa: Regenerate oa-lnl.xml now parsing all counters Ashutosh Dixit
2024-06-07 20:08 ` [PATCH i-g-t 27/27] xe/oa/oa-metricset-codegen: Fix XE_OA_FORMAT_PEC64u64 offsets Ashutosh Dixit
2024-06-07 22:48 ` ✗ GitLab.Pipeline: warning for Intel Xe OA IGT's (rev3) Patchwork
2024-06-07 23:22 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-07 23:23 ` ✗ CI.xeBAT: failure " Patchwork
2024-06-08 14:10 ` ✗ CI.xeFULL: " Patchwork
2024-06-08 15:04 ` ✗ Fi.CI.IGT: " 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=20240607200847.1964629-26-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=igt-dev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox