Mesa (staging/22.0): intel/perf: Fix OA report accumulation on Gfx12+.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 20:00:54 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 6f9a2da02f6621bb169e2e6781b1d415856317d2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f9a2da02f6621bb169e2e6781b1d415856317d2

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Mon Apr  4 15:45:54 2022 -0700

intel/perf: Fix OA report accumulation on Gfx12+.

The intel_perf_query path used for performance queries on GL was
passing a bogus "end" pointer to intel_perf_query_result_accumulate(),
causing it to accumulate garbage values.  This was causing the values
of many performance counters to be corrupted.

The "end" pointer was incorrect because the current code was assuming
that different OA reports were located TOTAL_QUERY_DATA_SIZE bytes
apart, which is a hard-coded preprocessor define.  However recent
(Gfx12+) hardware generations use a variable query size determined by
the query layout.  Use the size derived from it instead, and remove
the stale define.

Fixes: 3c513250255d6a ("intel/perf: switch query code to use query layout")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15783>
(cherry picked from commit e858da39e54ed34712ae044d80bcc23c398b53f3)

---

 .pick_status.json                 |  2 +-
 src/intel/perf/intel_perf_query.c | 21 ++++-----------------
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 4044dc2c96a..a5f963b4ab8 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2916,7 +2916,7 @@
         "description": "intel/perf: Fix OA report accumulation on Gfx12+.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 5,
+        "resolution": 1,
         "because_sha": "3c513250255d6ad031b8574ed7bb54a1e1ccdeef"
     },
     {
diff --git a/src/intel/perf/intel_perf_query.c b/src/intel/perf/intel_perf_query.c
index cff3138f577..65fadc026a9 100644
--- a/src/intel/perf/intel_perf_query.c
+++ b/src/intel/perf/intel_perf_query.c
@@ -48,19 +48,6 @@
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 
-/* Align to 64bytes, requirement for OA report write address. */
-#define TOTAL_QUERY_DATA_SIZE            \
-   ALIGN(256 /* OA report */ +           \
-         4  /* freq register */ +        \
-         8 + 8 /* perf counter 1 & 2 */, \
-         64)
-
-
-static uint32_t field_offset(bool end, uint32_t offset)
-{
-   return (end ? TOTAL_QUERY_DATA_SIZE : 0) + offset;
-}
-
 #define MAP_READ  (1 << 0)
 #define MAP_WRITE (1 << 1)
 
@@ -1089,8 +1076,8 @@ read_oa_samples_for_query(struct intel_perf_context *perf_ctx,
    if (query->oa.map == NULL)
       query->oa.map = perf_cfg->vtbl.bo_map(perf_ctx->ctx, query->oa.bo, MAP_READ);
 
-   start = last = query->oa.map + field_offset(false, 0);
-   end = query->oa.map + field_offset(true, 0);
+   start = last = query->oa.map;
+   end = query->oa.map + perf_ctx->perf->query_layout.size;
 
    if (start[0] != query->oa.begin_report_id) {
       DBG("Spurious start report id=%"PRIu32"\n", start[0]);
@@ -1280,8 +1267,8 @@ accumulate_oa_reports(struct intel_perf_context *perf_ctx,
 
    assert(query->oa.map != NULL);
 
-   start = last = query->oa.map + field_offset(false, 0);
-   end = query->oa.map + field_offset(true, 0);
+   start = last = query->oa.map;
+   end = query->oa.map + perf_ctx->perf->query_layout.size;
 
    if (start[0] != query->oa.begin_report_id) {
       DBG("Spurious start report id=%"PRIu32"\n", start[0]);



More information about the mesa-commit mailing list