Module: Mesa
Branch: staging/23.3
Commit: 4e9ef47839f366b6d732af440ef4bddb1ea5182e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e9ef47839f366b6d732af440ef4bddb1ea5182e

Author: Lionel Landwerlin <[email protected]>
Date:   Mon Nov 20 11:43:24 2023 +0200

intel/perf: fix querying of configurations

Using the unsized data field is incorrect. The data is located behind
the entire drm_i915_query_perf_config structure.

Signed-off-by: Lionel Landwerlin <[email protected]>
Cc: mesa-stable
Reviewed-by: Rohan Garg <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26285>
(cherry picked from commit f9bab3566bcfbf4d33bcbb9fb8d5e8d416cb5674)

---

 .pick_status.json           |  2 +-
 src/intel/perf/intel_perf.c | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b78e6533a4f..c1056c20cc4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1394,7 +1394,7 @@
         "description": "intel/perf: fix querying of configurations",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c
index 52f4d989e7a..a047525b375 100644
--- a/src/intel/perf/intel_perf.c
+++ b/src/intel/perf/intel_perf.c
@@ -280,18 +280,19 @@ i915_query_perf_config_data(struct intel_perf_config 
*perf,
 {
    char data[sizeof(struct drm_i915_query_perf_config) +
              sizeof(struct drm_i915_perf_oa_config)] = {};
-   struct drm_i915_query_perf_config *query = (void *)data;
+   struct drm_i915_query_perf_config *i915_query = (void *)data;
+   struct drm_i915_perf_oa_config *i915_config = (void *)data + 
sizeof(*i915_query);
 
-   memcpy(query->uuid, guid, sizeof(query->uuid));
-   memcpy(query->data, config, sizeof(*config));
+   memcpy(i915_query->uuid, guid, sizeof(i915_query->uuid));
+   memcpy(i915_config, config, sizeof(*config));
 
    int32_t item_length = sizeof(data);
    if (intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
                               DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
-                              query, &item_length))
+                              i915_query, &item_length))
       return false;
 
-   memcpy(config, query->data, sizeof(*config));
+   memcpy(config, i915_config, sizeof(*config));
 
    return true;
 }

Reply via email to