intel/perf: extract register configuration
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 19 Oct 2018 17:25:13 +0000 (18:25 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 23 Oct 2019 05:41:14 +0000 (05:41 +0000)
We want to query the content of register configurations from the
kernel. Let's pull this out of the query.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/intel/perf/gen_perf.c
src/intel/perf/gen_perf.h
src/intel/perf/gen_perf.py

index 01ee19b5e57f15ff2ca8c67b0220a39438ef102b..61bf8329d2cab83cf58aa8604ee48fc6111b407d 100644 (file)
@@ -616,14 +616,14 @@ init_oa_configs(struct gen_perf_config *perf, int fd)
 
       memcpy(config.uuid, query->guid, sizeof(config.uuid));
 
-      config.n_mux_regs = query->n_mux_regs;
-      config.mux_regs_ptr = (uintptr_t) query->mux_regs;
+      config.n_mux_regs = query->config.n_mux_regs;
+      config.mux_regs_ptr = (uintptr_t) query->config.mux_regs;
 
-      config.n_boolean_regs = query->n_b_counter_regs;
-      config.boolean_regs_ptr = (uintptr_t) query->b_counter_regs;
+      config.n_boolean_regs = query->config.n_b_counter_regs;
+      config.boolean_regs_ptr = (uintptr_t) query->config.b_counter_regs;
 
-      config.n_flex_regs = query->n_flex_regs;
-      config.flex_regs_ptr = (uintptr_t) query->flex_regs;
+      config.n_flex_regs = query->config.n_flex_regs;
+      config.flex_regs_ptr = (uintptr_t) query->config.flex_regs;
 
       ret = gen_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &config);
       if (ret < 0) {
index c79db7cfa44538f8d3d6a070661792da21b98980..5385607b95692383337c7af80fbafb854051195f 100644 (file)
@@ -164,6 +164,18 @@ struct gen_perf_query_register_prog {
    uint32_t val;
 };
 
+/* Register programming for a given query */
+struct gen_perf_configuration {
+   struct gen_perf_query_register_prog *flex_regs;
+   uint32_t n_flex_regs;
+
+   struct gen_perf_query_register_prog *mux_regs;
+   uint32_t n_mux_regs;
+
+   struct gen_perf_query_register_prog *b_counter_regs;
+   uint32_t n_b_counter_regs;
+};
+
 struct gen_perf_query_info {
    enum gen_perf_query_type {
       GEN_PERF_QUERY_TYPE_OA,
@@ -188,15 +200,7 @@ struct gen_perf_query_info {
    int b_offset;
    int c_offset;
 
-   /* Register programming for a given query */
-   struct gen_perf_query_register_prog *flex_regs;
-   uint32_t n_flex_regs;
-
-   struct gen_perf_query_register_prog *mux_regs;
-   uint32_t n_mux_regs;
-
-   struct gen_perf_query_register_prog *b_counter_regs;
-   uint32_t n_b_counter_regs;
+   struct gen_perf_configuration config;
 };
 
 struct gen_perf_config {
index 6f42c04dab87a38147c3e2ed414626fdcf2f678b..8e05a8e472b3f4db02f51bbe4943e9488680c915 100644 (file)
@@ -419,7 +419,7 @@ def generate_register_configs(set):
             c_indent(3)
 
         for register in register_config.findall('register'):
-            c("query->%s[query->n_%s++] = (struct gen_perf_query_register_prog) { .reg = %s, .val = %s };" %
+            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')))
 
         if availability:
@@ -692,9 +692,13 @@ def main():
                     .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")