def generate_register_configs(set):
register_configs = set.findall('register_config')
+
for register_config in register_configs:
t = register_types[register_config.get('type')]
output_availability(set, availability, register_config.get('type') + ' register config')
c_indent(3)
- for register in register_config.findall('register'):
+ registers = register_config.findall('register')
+ c("query->config.%s = rzalloc_array(query, struct gen_perf_query_register_prog, %d);" % (t, len(registers)))
+ 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')))
#include <drm-uapi/i915_drm.h>
#include "util/hash_table.h"
+ #include "util/ralloc.h"
"""))
counters = set.counters
c("\n")
- register_lengths = compute_register_lengths(set);
- for reg_type, reg_length in register_lengths.items():
- c("static struct gen_perf_query_register_prog {0}_{1}_{2}[{3}];".format(gen.chipset,
- set.underscore_name,
- reg_type, reg_length))
-
- c("\nstatic struct gen_perf_query_counter {0}_{1}_query_counters[{2}];\n".format(gen.chipset, set.underscore_name, len(counters)))
- c("static struct gen_perf_query_info " + gen.chipset + "_" + set.underscore_name + "_query = {\n")
+ c("\nstatic void\n")
+ c("{0}_register_{1}_counter_query(struct gen_perf_config *perf)\n".format(gen.chipset, set.underscore_name))
+ c("{\n")
c_indent(3)
- c(".kind = GEN_PERF_QUERY_TYPE_OA,\n")
- c(".name = \"" + set.name + "\",\n")
- c(".guid = \"" + set.hw_config_guid + "\",\n")
+ c("struct gen_perf_query_info *query = rzalloc(perf, struct gen_perf_query_info);\n")
+ c("\n")
+ c("query->kind = GEN_PERF_QUERY_TYPE_OA;\n")
+ c("query->name = \"" + set.name + "\";\n")
+ c("query->guid = \"" + set.hw_config_guid + "\";\n")
- c(".counters = {0}_{1}_query_counters,".format(gen.chipset, set.underscore_name))
- c(".n_counters = 0,")
- c(".oa_metrics_set_id = 0, /* determined at runtime, via sysfs */")
+ c("query->counters = rzalloc_array(query, struct gen_perf_query_counter, %u);" % len(counters))
+ c("query->n_counters = 0;")
+ c("query->oa_metrics_set_id = 0; /* determined at runtime, via sysfs */")
if gen.chipset == "hsw":
c(textwrap.dedent("""\
- .oa_format = I915_OA_FORMAT_A45_B8_C8,
-
+ query->oa_format = I915_OA_FORMAT_A45_B8_C8;
/* Accumulation buffer offsets... */
- .gpu_time_offset = 0,
- .a_offset = 1,
- .b_offset = 46,
- .c_offset = 54,
+ query->gpu_time_offset = 0;
+ query->a_offset = 1;
+ query->b_offset = 46;
+ query->c_offset = 54;
"""))
else:
c(textwrap.dedent("""\
- .oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8,
-
+ query->oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8;
/* Accumulation buffer offsets... */
- .gpu_time_offset = 0,
- .gpu_clock_offset = 1,
- .a_offset = 2,
- .b_offset = 38,
- .c_offset = 46,
+ query->gpu_time_offset = 0;
+ query->gpu_clock_offset = 1;
+ query->a_offset = 2;
+ query->b_offset = 38;
+ query->c_offset = 46;
"""))
- c(".config = {")
- c_indent(3)
- for reg_type, reg_length in register_lengths.items():
- c(".{0} = {1}_{2}_{3},".format(reg_type, gen.chipset, set.underscore_name, reg_type))
- c(".n_{0} = 0, /* Determined at runtime */".format(reg_type))
- c_outdent(3)
- c("},")
- c_outdent(3)
- c("};\n")
-
- c("\nstatic void\n")
- c("{0}_register_{1}_counter_query(struct gen_perf_config *perf)\n".format(gen.chipset, set.underscore_name))
- c("{\n")
- c_indent(3)
-
- c("static struct gen_perf_query_info *query = &" + gen.chipset + "_" + set.underscore_name + "_query;\n")
- c("struct gen_perf_query_counter *counter;\n")
+ c("\n")
+ c("struct gen_perf_query_counter *counter = query->counters;\n")
c("\n")
c("/* Note: we're assuming there can't be any variation in the definition ")