intel/perf: store the probed i915-perf version
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 2 Mar 2020 12:00:55 +0000 (14:00 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 27 Mar 2020 14:14:49 +0000 (14:14 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Mark Janes <mark.a.janes@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>

src/intel/perf/gen_perf.c
src/intel/perf/gen_perf.h
src/intel/vulkan/anv_perf.c

index 2c5d541feedd39c2077151cb1ead4be1d4ea7908..1bf2424e108f46fa129686fd977fd8a02a29a547 100644 (file)
@@ -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.
index facd5bb6a4cf3ef3fd2c80d39ae321c0f28f0790..4f0805f2b269397b79ba3e0f0cc23f7fbc114b88 100644 (file)
@@ -192,6 +192,9 @@ struct gen_perf_config {
    /* Whether i915 has DRM_I915_QUERY_PERF_CONFIG support. */
    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;
 
index 3d673bb77341de5414dc59f14e6a88148a97a1fe..5c8fd5288b22c39c52ff7b69c94184333663b851 100644 (file)
@@ -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;