intel/perf: split load_oa_metrics
authorMarcin Ślusarz <marcin.slusarz@intel.com>
Thu, 9 Jul 2020 17:49:55 +0000 (19:49 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 10 Aug 2020 13:41:29 +0000 (13:41 +0000)
Move oa_metrics_available out of load_oa_metrics and call
build_unique_counter_list outside.

This change is a preparation for the next patch. It should
not have any functional impact.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5788>

src/intel/perf/gen_perf.c

index e6a18a3a8d549d3c63a637be092d2f0a021b5e84..4f95b0a84afda1a0163daf99790c44c73e93c1ea 100644 (file)
@@ -662,8 +662,8 @@ build_unique_counter_list(struct gen_perf_config *perf)
 }
 
 static bool
-load_oa_metrics(struct gen_perf_config *perf, int fd,
-                const struct gen_device_info *devinfo)
+oa_metrics_available(struct gen_perf_config *perf, int fd,
+      const struct gen_device_info *devinfo)
 {
    perf_register_oa_queries_t oa_register = get_register_queries_function(devinfo);
    bool i915_perf_oa_available = false;
@@ -697,11 +697,17 @@ load_oa_metrics(struct gen_perf_config *perf, int fd,
       perf->platform_supported = oa_register != NULL;
    }
 
-   if (!i915_perf_oa_available ||
-       !oa_register ||
-       !get_sysfs_dev_dir(perf, fd) ||
-       !init_oa_sys_vars(perf, devinfo))
-      return false;
+   return i915_perf_oa_available &&
+          oa_register &&
+          get_sysfs_dev_dir(perf, fd) &&
+          init_oa_sys_vars(perf, devinfo);
+}
+
+static void
+load_oa_metrics(struct gen_perf_config *perf, int fd,
+                const struct gen_device_info *devinfo)
+{
+   perf_register_oa_queries_t oa_register = get_register_queries_function(devinfo);
 
    perf->oa_metrics_table =
       _mesa_hash_table_create(perf, _mesa_hash_string,
@@ -720,10 +726,6 @@ load_oa_metrics(struct gen_perf_config *perf, int fd,
    } else {
       add_all_metrics(perf, devinfo);
    }
-
-   build_unique_counter_list(perf);
-
-   return true;
 }
 
 struct gen_perf_registers *
@@ -1048,6 +1050,10 @@ gen_perf_init_metrics(struct gen_perf_config *perf_cfg,
       load_pipeline_statistic_metrics(perf_cfg, devinfo);
       gen_perf_register_mdapi_statistic_query(perf_cfg, devinfo);
    }
-   if (load_oa_metrics(perf_cfg, drm_fd, devinfo))
+
+   if (oa_metrics_available(perf_cfg, drm_fd, devinfo)) {
+      load_oa_metrics(perf_cfg, drm_fd, devinfo);
+      build_unique_counter_list(perf_cfg);
       gen_perf_register_mdapi_oa_query(perf_cfg, devinfo);
+   }
 }