intel/perf: Replace i915_perf_version and i915_query_supported by a feature bitmask

Replacing the i915_perf_version that is i915 specific by a feature
mask makes easier to support Xe KMD.
Also this allow us to group a bool and a int into a single enum(int).

No changes in behavior is expected here.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29312>
This commit is contained in:
José Roberto de Souza
2024-05-08 12:34:06 -07:00
committed by Marge Bot
parent a56b085661
commit 0e68d7a735
7 changed files with 25 additions and 18 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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;

View File

@@ -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.
*/

View File

@@ -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,

View File

@@ -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,