From: Eric Anholt Date: Thu, 9 Jul 2020 16:41:45 +0000 (-0700) Subject: intel/perf: Move perf query register programming to static tables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d735f075a6aae821c06de1c82a5ebe4430b94674;p=mesa.git intel/perf: Move perf query register programming to static tables. And now that they're static tables, we don't need to ralloc a copy in non-shared memory. Saves ~210k in the built intel drivers. Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1048434 Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index f31b15aa4b2..e6a18a3a8d5 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -328,13 +328,13 @@ i915_add_config(struct gen_perf_config *perf, int fd, memcpy(i915_config.uuid, guid, sizeof(i915_config.uuid)); i915_config.n_mux_regs = config->n_mux_regs; - i915_config.mux_regs_ptr = to_user_pointer(config->mux_regs); + i915_config.mux_regs_ptr = to_const_user_pointer(config->mux_regs); i915_config.n_boolean_regs = config->n_b_counter_regs; - i915_config.boolean_regs_ptr = to_user_pointer(config->b_counter_regs); + i915_config.boolean_regs_ptr = to_const_user_pointer(config->b_counter_regs); i915_config.n_flex_regs = config->n_flex_regs; - i915_config.flex_regs_ptr = to_user_pointer(config->flex_regs); + i915_config.flex_regs_ptr = to_const_user_pointer(config->flex_regs); int ret = gen_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &i915_config); return ret > 0 ? ret : 0; @@ -748,9 +748,9 @@ gen_perf_load_configuration(struct gen_perf_config *perf_cfg, int fd, const char * struct gen_perf_query_register_prog maps exactly to the tuple of * (register offset, register value) returned by the i915. */ - i915_config.flex_regs_ptr = to_user_pointer(config->flex_regs); - i915_config.mux_regs_ptr = to_user_pointer(config->mux_regs); - i915_config.boolean_regs_ptr = to_user_pointer(config->b_counter_regs); + 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; diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index 95aeab9182f..49ea2eb9e81 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -190,13 +190,13 @@ struct gen_perf_query_register_prog { /* Register programming for a given query */ struct gen_perf_registers { - struct gen_perf_query_register_prog *flex_regs; + const struct gen_perf_query_register_prog *flex_regs; uint32_t n_flex_regs; - struct gen_perf_query_register_prog *mux_regs; + const struct gen_perf_query_register_prog *mux_regs; uint32_t n_mux_regs; - struct gen_perf_query_register_prog *b_counter_regs; + const struct gen_perf_query_register_prog *b_counter_regs; uint32_t n_b_counter_regs; }; diff --git a/src/intel/perf/gen_perf.py b/src/intel/perf/gen_perf.py index a5b47ea56e8..e714e1e802d 100644 --- a/src/intel/perf/gen_perf.py +++ b/src/intel/perf/gen_perf.py @@ -430,10 +430,14 @@ def generate_register_configs(set): c_indent(3) registers = register_config.findall('register') - c("query->config.%s = rzalloc_array(query, struct gen_perf_query_register_prog, %d);" % (t, len(registers))) + c("static const struct gen_perf_query_register_prog %s[] = {" % t) + c_indent(3) for register in registers: - c("query->config.%s[query->config.n_%s++] = (struct gen_perf_query_register_prog) { .reg = %s, .val = %s };" % - (t, t, register.get('address'), register.get('value'))) + c("{ .reg = %s, .val = %s }," % (register.get('address'), register.get('value'))) + c_outdent(3) + c("};") + c("query->config.%s = %s;" % (t, t)) + c("query->config.n_%s = ARRAY_SIZE(%s);" % (t, t)) if availability: c_outdent(3) diff --git a/src/intel/perf/gen_perf_private.h b/src/intel/perf/gen_perf_private.h index 2e4568fa9aa..e3e877dd89e 100644 --- a/src/intel/perf/gen_perf_private.h +++ b/src/intel/perf/gen_perf_private.h @@ -31,6 +31,11 @@ static inline uint64_t to_user_pointer(void *ptr) return (uintptr_t) ptr; } +static inline uint64_t to_const_user_pointer(const void *ptr) +{ + return (uintptr_t) ptr; +} + static inline void gen_perf_query_add_stat_reg(struct gen_perf_query_info *query, uint32_t reg, uint32_t numerator, uint32_t denominator,