diff --git a/src/intel/perf/i915/intel_perf.c b/src/intel/perf/i915/intel_perf.c index 127352c4250..c2840327030 100644 --- a/src/intel/perf/i915/intel_perf.c +++ b/src/intel/perf/i915/intel_perf.c @@ -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) { diff --git a/src/intel/perf/i915/intel_perf.h b/src/intel/perf/i915/intel_perf.h index d10dddda727..cfa3cbde519 100644 --- a/src/intel/perf/i915/intel_perf.h +++ b/src/intel/perf/i915/intel_perf.h @@ -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); diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c index 1f5415c4a0f..9c884a695c7 100644 --- a/src/intel/perf/intel_perf.c +++ b/src/intel/perf/intel_perf.c @@ -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