diff --git a/src/intel/perf/i915/intel_perf.c b/src/intel/perf/i915/intel_perf.c index 2277b89d0ce..9a8c2a84270 100644 --- a/src/intel/perf/i915/intel_perf.c +++ b/src/intel/perf/i915/intel_perf.c @@ -14,6 +14,7 @@ #include "intel_perf_common.h" #include "perf/intel_perf.h" #include "perf/intel_perf_private.h" +#include "util/compiler.h" #include "drm-uapi/i915_drm.h" @@ -175,11 +176,17 @@ i915_get_sseu(int drm_fd, struct drm_i915_gem_context_param_sseu *sseu) bool i915_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_register_snapshots) { + int version = i915_perf_version(fd); bool i915_perf_oa_available = false; struct stat sb; - perf->i915_query_supported = i915_query_perf_config_supported(perf, fd); - perf->i915_perf_version = i915_perf_version(fd); + if (i915_query_perf_config_supported(perf, fd)) + perf->features_supported |= INTEL_PERF_FEATURE_QUERY_PERF; + + if (version >= 4) + perf->features_supported |= INTEL_PERF_FEATURE_GLOBAL_SSEU; + if (version >= 3) + perf->features_supported |= INTEL_PERF_FEATURE_HOLD_PREEMPTION; /* Record the default SSEU configuration. */ perf->sseu = rzalloc(perf, struct drm_i915_gem_context_param_sseu); diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c index e32557482b9..64f01ffc75a 100644 --- a/src/intel/perf/intel_perf.c +++ b/src/intel/perf/intel_perf.c @@ -678,7 +678,7 @@ oa_metrics_available(struct intel_perf_config *perf, int fd, /* Consider an invalid as supported. */ if (fd == -1) { - perf->i915_query_supported = true; + perf->features_supported = INTEL_PERF_FEATURE_QUERY_PERF; return true; } @@ -756,7 +756,7 @@ load_oa_metrics(struct intel_perf_config *perf, int fd, struct intel_perf_registers * intel_perf_load_configuration(struct intel_perf_config *perf_cfg, int fd, const char *guid) { - if (!perf_cfg->i915_query_supported) + if (!(perf_cfg->features_supported & INTEL_PERF_FEATURE_QUERY_PERF)) return NULL; switch (perf_cfg->devinfo->kmd_type) { diff --git a/src/intel/perf/intel_perf.h b/src/intel/perf/intel_perf.h index b0d36416617..efdbccd44cb 100644 --- a/src/intel/perf/intel_perf.h +++ b/src/intel/perf/intel_perf.h @@ -331,15 +331,18 @@ struct intel_perf_query_counter_info { } location; }; -struct intel_perf_config { +enum intel_perf_features { + INTEL_PERF_FEATURE_HOLD_PREEMPTION = (1 << 0), + INTEL_PERF_FEATURE_GLOBAL_SSEU = (1 << 1), /* Whether i915 has DRM_I915_QUERY_PERF_CONFIG support. */ - bool i915_query_supported; + INTEL_PERF_FEATURE_QUERY_PERF = (1 << 2), +}; +struct intel_perf_config { /* Have extended metrics been enabled */ bool enable_all_metrics; - /* Version of the i915-perf subsystem, refer to i915_drm.h. */ - int i915_perf_version; + enum intel_perf_features features_supported; /* Number of bits to shift the OA timestamp values by to match the ring * timestamp. @@ -566,7 +569,7 @@ uint64_t intel_perf_get_oa_format(struct intel_perf_config *perf_cfg); static inline bool intel_perf_has_hold_preemption(const struct intel_perf_config *perf) { - return perf->i915_perf_version >= 3; + return perf->features_supported & INTEL_PERF_FEATURE_HOLD_PREEMPTION; } /** Whether we have the ability to lock EU array power configuration for the @@ -576,7 +579,7 @@ intel_perf_has_hold_preemption(const struct intel_perf_config *perf) static inline bool intel_perf_has_global_sseu(const struct intel_perf_config *perf) { - return perf->i915_perf_version >= 4; + return perf->features_supported & INTEL_PERF_FEATURE_GLOBAL_SSEU; } uint32_t intel_perf_get_n_passes(struct intel_perf_config *perf, diff --git a/src/intel/perf/intel_perf_query_layout.c b/src/intel/perf/intel_perf_query_layout.c index dc423cf8d50..22eba082433 100644 --- a/src/intel/perf/intel_perf_query_layout.c +++ b/src/intel/perf/intel_perf_query_layout.c @@ -98,7 +98,7 @@ main(int argc, char *argv[]) struct intel_perf_config *perf_cfg = intel_perf_new(NULL); intel_perf_init_metrics(perf_cfg, &devinfo, -1, true, true); - if (!perf_cfg->i915_query_supported) { + if (!(perf_cfg->features_supported & INTEL_PERF_FEATURE_QUERY_PERF)) { fprintf(stderr, "No supported queries for platform.\n"); intel_perf_free(perf_cfg); return EXIT_FAILURE; diff --git a/src/intel/perf/xe/intel_perf.c b/src/intel/perf/xe/intel_perf.c index e3f529b4ca2..416bfa12d5c 100644 --- a/src/intel/perf/xe/intel_perf.c +++ b/src/intel/perf/xe/intel_perf.c @@ -36,9 +36,6 @@ xe_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_registe bool perf_oa_available = false; struct stat sb; - perf->i915_query_supported = false; - perf->i915_perf_version = 0; - /* The existence of this file implies that this Xe KMD version supports * perf interface. */ diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 109c825eaed..259dbe1e99b 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -283,7 +283,7 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_multiview = true, .KHR_performance_query = device->perf && - (device->perf->i915_perf_version >= 3 || + (intel_perf_has_hold_preemption(device->perf) || INTEL_DEBUG(DEBUG_NO_OACONFIG)) && device->use_call_secondary, .KHR_pipeline_executable_properties = true, @@ -448,7 +448,7 @@ get_device_extensions(const struct anv_physical_device *device, .GOOGLE_hlsl_functionality1 = true, .GOOGLE_user_type = true, .INTEL_performance_query = device->perf && - device->perf->i915_perf_version >= 3, + intel_perf_has_hold_preemption(device->perf), .INTEL_shader_integer_functions2 = true, .EXT_multi_draw = true, .NV_compute_shader_derivatives = true, diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index 6b4a092b04e..8231a8d5c74 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -232,7 +232,7 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_multiview = true, .KHR_performance_query = !anv_use_relocations(device) && device->perf && - (device->perf->i915_perf_version >= 3 || + (intel_perf_has_hold_preemption(device->perf) || INTEL_DEBUG(DEBUG_NO_OACONFIG)) && device->use_call_secondary, .KHR_pipeline_executable_properties = true, @@ -332,7 +332,7 @@ get_device_extensions(const struct anv_physical_device *device, .GOOGLE_hlsl_functionality1 = true, .GOOGLE_user_type = true, .INTEL_performance_query = device->perf && - device->perf->i915_perf_version >= 3, + intel_perf_has_hold_preemption(device->perf), .INTEL_shader_integer_functions2 = device->info.ver >= 8, .EXT_multi_draw = true, .NV_compute_shader_derivatives = true,