intel/perf: Move i915 specific code to load configurations to i915 file

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/29421>
This commit is contained in:
José Roberto de Souza
2024-05-02 12:38:04 -07:00
committed by Marge Bot
parent 30f97a7242
commit e1c2847b81
3 changed files with 38 additions and 25 deletions

View File

@@ -13,6 +13,7 @@
#include "dev/intel_device_info.h"
#include "intel_perf_common.h"
#include "perf/intel_perf.h"
#include "perf/intel_perf_private.h"
#include "drm-uapi/i915_drm.h"
@@ -97,7 +98,7 @@ i915_query_perf_config_supported(struct intel_perf_config *perf, int fd)
NULL, &length);
}
bool
static bool
i915_query_perf_config_data(struct intel_perf_config *perf,
int fd, const char *guid,
struct drm_i915_perf_oa_config *config)
@@ -121,6 +122,36 @@ i915_query_perf_config_data(struct intel_perf_config *perf,
return true;
}
struct intel_perf_registers *
i915_perf_load_configurations(struct intel_perf_config *perf_cfg, int fd, const char *guid)
{
struct drm_i915_perf_oa_config i915_config = { 0, };
if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config))
return NULL;
struct intel_perf_registers *config = rzalloc(NULL, struct intel_perf_registers);
config->n_flex_regs = i915_config.n_flex_regs;
config->flex_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_flex_regs);
config->n_mux_regs = i915_config.n_mux_regs;
config->mux_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_mux_regs);
config->n_b_counter_regs = i915_config.n_boolean_regs;
config->b_counter_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_b_counter_regs);
/*
* struct intel_perf_query_register_prog maps exactly to the tuple of
* (register offset, register value) returned by the i915.
*/
i915_config.flex_regs_ptr = to_const_user_pointer(config->flex_regs);
i915_config.mux_regs_ptr = to_const_user_pointer(config->mux_regs);
i915_config.boolean_regs_ptr = to_const_user_pointer(config->b_counter_regs);
if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config)) {
ralloc_free(config);
return NULL;
}
return config;
}
static int
i915_perf_version(int drm_fd)
{

View File

@@ -18,6 +18,6 @@ int i915_perf_stream_open(struct intel_perf_config *perf_config, int drm_fd,
uint64_t report_format, uint64_t period_exponent,
bool hold_preemption, bool enable);
bool i915_query_perf_config_data(struct intel_perf_config *perf, int fd, const char *guid, struct drm_i915_perf_oa_config *config);
struct intel_perf_registers *i915_perf_load_configurations(struct intel_perf_config *perf_cfg, int fd, const char *guid);
bool i915_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_register_snapshots);

View File

@@ -736,31 +736,13 @@ intel_perf_load_configuration(struct intel_perf_config *perf_cfg, int fd, const
if (!perf_cfg->i915_query_supported)
return NULL;
struct drm_i915_perf_oa_config i915_config = { 0, };
if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config))
return NULL;
struct intel_perf_registers *config = rzalloc(NULL, struct intel_perf_registers);
config->n_flex_regs = i915_config.n_flex_regs;
config->flex_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_flex_regs);
config->n_mux_regs = i915_config.n_mux_regs;
config->mux_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_mux_regs);
config->n_b_counter_regs = i915_config.n_boolean_regs;
config->b_counter_regs = rzalloc_array(config, struct intel_perf_query_register_prog, config->n_b_counter_regs);
/*
* struct intel_perf_query_register_prog maps exactly to the tuple of
* (register offset, register value) returned by the i915.
*/
i915_config.flex_regs_ptr = to_const_user_pointer(config->flex_regs);
i915_config.mux_regs_ptr = to_const_user_pointer(config->mux_regs);
i915_config.boolean_regs_ptr = to_const_user_pointer(config->b_counter_regs);
if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config)) {
ralloc_free(config);
switch (perf_cfg->devinfo->kmd_type) {
case INTEL_KMD_TYPE_I915:
return i915_perf_load_configurations(perf_cfg, fd, guid);
default:
unreachable("missing");
return NULL;
}
return config;
}
uint64_t