Mesa (staging/20.0): intel/perf: store the probed i915-perf version

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 11 17:22:55 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 071ba3898a4431f9290320272bc26bbcc363f632
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=071ba3898a4431f9290320272bc26bbcc363f632

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Mar  2 14:00:55 2020 +0200

intel/perf: store the probed i915-perf version

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Acked-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli at intel.com>
Reviewed-by: Mark Janes <mark.a.janes at intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4344>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4344>
(cherry picked from commit aad0e6f81049c098fd3922d61aa228e4bf791317)

---

 .pick_status.json           |  2 +-
 src/intel/perf/gen_perf.c   | 18 ++++++++++++++++++
 src/intel/perf/gen_perf.h   |  3 +++
 src/intel/vulkan/anv_perf.c |  2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 8d6a7180ea0..445a5c85d61 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -17338,7 +17338,7 @@
         "description": "intel/perf: store the probed i915-perf version",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c
index 2c5d541feed..1bf2424e108 100644
--- a/src/intel/perf/gen_perf.c
+++ b/src/intel/perf/gen_perf.c
@@ -542,6 +542,23 @@ load_pipeline_statistic_metrics(struct gen_perf_config *perf_cfg,
    query->data_size = sizeof(uint64_t) * query->n_counters;
 }
 
+static int
+i915_perf_version(int drm_fd)
+{
+   int tmp;
+   drm_i915_getparam_t gp = {
+      .param = I915_PARAM_PERF_REVISION,
+      .value = &tmp,
+   };
+
+   int ret = gen_ioctl(drm_fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+   /* Return 0 if this getparam is not supported, the first version supported
+    * is 1.
+    */
+   return ret < 0 ? 0 : tmp;
+}
+
 static bool
 load_oa_metrics(struct gen_perf_config *perf, int fd,
                          const struct gen_device_info *devinfo)
@@ -551,6 +568,7 @@ load_oa_metrics(struct gen_perf_config *perf, int fd,
    struct stat sb;
 
    perf->i915_query_supported = i915_query_perf_config_supported(perf, fd);
+   perf->i915_perf_version = i915_perf_version(fd);
 
    /* The existence of this sysctl parameter implies the kernel supports
     * the i915 perf interface.
diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h
index 8f6fca16aa1..e766d75209a 100644
--- a/src/intel/perf/gen_perf.h
+++ b/src/intel/perf/gen_perf.h
@@ -191,6 +191,9 @@ struct gen_perf_query_info {
 struct gen_perf_config {
    bool i915_query_supported;
 
+   /* Version of the i915-perf subsystem, refer to i915_drm.h. */
+   int i915_perf_version;
+
    struct gen_perf_query_info *queries;
    int n_queries;
 
diff --git a/src/intel/vulkan/anv_perf.c b/src/intel/vulkan/anv_perf.c
index 3d673bb7734..5c8fd5288b2 100644
--- a/src/intel/vulkan/anv_perf.c
+++ b/src/intel/vulkan/anv_perf.c
@@ -40,7 +40,7 @@ anv_get_perf(const struct gen_device_info *devinfo, int fd)
    /* We need DRM_I915_PERF_PROP_HOLD_PREEMPTION support, only available in
     * perf revision 2.
     */
-   if (anv_gem_get_param(fd, I915_PARAM_PERF_REVISION) < 3)
+   if (perf->i915_perf_version < 3)
       goto err;
 
    return perf;



More information about the mesa-commit mailing list