From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 3/6] lib/i915: Add support for loading perf configurations
Date: Mon, 17 Feb 2020 16:21:52 +0200 [thread overview]
Message-ID: <20200217142155.501499-4-lionel.g.landwerlin@intel.com> (raw)
In-Reply-To: <20200217142155.501499-1-lionel.g.landwerlin@intel.com>
---
lib/i915/perf.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/i915/perf.h | 2 ++
2 files changed, 77 insertions(+)
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index 8aaf8e61..f23a9b12 100644
--- a/lib/i915/perf.c
+++ b/lib/i915/perf.c
@@ -433,3 +433,78 @@ intel_perf_add_metric_set(struct intel_perf *perf,
{
igt_list_add_tail(&metric_set->link, &perf->metric_sets);
}
+
+static void
+load_metric_set_config(struct intel_perf_metric_set *metric_set, int drm_fd)
+{
+ struct drm_i915_perf_oa_config config;
+ uint64_t config_id = 0;
+
+ memset(&config, 0, sizeof(config));
+
+ memcpy(config.uuid, metric_set->hw_config_guid, sizeof(config.uuid));
+
+ config.n_mux_regs = metric_set->n_mux_regs;
+ config.mux_regs_ptr = (uintptr_t) metric_set->mux_regs;
+
+ config.n_boolean_regs = metric_set->n_b_counter_regs;
+ config.boolean_regs_ptr = (uintptr_t) metric_set->b_counter_regs;
+
+ config.n_flex_regs = metric_set->n_flex_regs;
+ config.flex_regs_ptr = (uintptr_t) metric_set->flex_regs;
+
+ while (ioctl(drm_fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &config) < 0 &&
+ (errno == EAGAIN || errno == EINTR));
+
+ metric_set->perf_oa_metrics_set = config_id;
+}
+
+void
+intel_perf_load_perf_configs(struct intel_perf *perf, int drm_fd)
+{
+ int drm_card = get_card_for_fd(drm_fd);
+ struct dirent *entry;
+ char metrics_path[128];
+ DIR *metrics_dir;
+ struct intel_perf_metric_set *metric_set;
+
+ snprintf(metrics_path, sizeof(metrics_path),
+ "/sys/class/drm/card%d/metrics", drm_card);
+ metrics_dir = opendir(metrics_path);
+ if (!metrics_dir)
+ return;
+
+ while ((entry = readdir(metrics_dir))) {
+ char *metric_id_path;
+ uint64_t metric_id;
+
+ if (entry->d_type != DT_DIR)
+ continue;
+
+ asprintf(&metric_id_path, "%s/%s/id",
+ metrics_path, entry->d_name);
+
+ if (!read_file_uint64(metric_id_path, &metric_id)) {
+ free(metric_id_path);
+ continue;
+ }
+
+ free(metric_id_path);
+
+ igt_list_for_each_entry(metric_set, &perf->metric_sets, link) {
+ if (!strcmp(metric_set->hw_config_guid, entry->d_name)) {
+ metric_set->perf_oa_metrics_set = metric_id;
+ break;
+ }
+ }
+ }
+
+ closedir(metrics_dir);
+
+ igt_list_for_each_entry(metric_set, &perf->metric_sets, link) {
+ if (metric_set->perf_oa_metrics_set)
+ continue;
+
+ load_metric_set_config(metric_set, drm_fd);
+ }
+}
diff --git a/lib/i915/perf.h b/lib/i915/perf.h
index 7dfa0472..246d06cf 100644
--- a/lib/i915/perf.h
+++ b/lib/i915/perf.h
@@ -220,6 +220,8 @@ void intel_perf_add_logical_counter(struct intel_perf *perf,
void intel_perf_add_metric_set(struct intel_perf *perf,
struct intel_perf_metric_set *metric_set);
+void intel_perf_load_perf_configs(struct intel_perf *perf, int drm_fd);
+
#ifdef __cplusplus
};
#endif
--
2.25.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-02-17 14:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-17 14:21 [igt-dev] [PATCH i-g-t 0/6] New performance recording/replay tools for i915-perf Lionel Landwerlin
2020-02-17 14:21 ` [igt-dev] [PATCH i-g-t 1/6] lib/intel_chipset: identify Elkhart Lake Lionel Landwerlin
2020-02-18 18:47 ` Chris Wilson
2020-02-17 14:21 ` Lionel Landwerlin [this message]
2020-02-18 18:52 ` [igt-dev] [PATCH i-g-t 3/6] lib/i915: Add support for loading perf configurations Chris Wilson
2020-02-17 14:21 ` [igt-dev] [PATCH i-g-t 4/6] tools: add i915 perf recorder tool Lionel Landwerlin
2020-02-18 18:57 ` Chris Wilson
2020-02-18 19:25 ` Lionel Landwerlin
2020-02-18 19:36 ` Chris Wilson
2020-02-18 19:49 ` Lionel Landwerlin
2020-02-18 20:14 ` Lionel Landwerlin
2020-02-18 20:26 ` Chris Wilson
2020-02-17 14:21 ` [igt-dev] [PATCH i-g-t 5/6] lib: add i915 perf data reader Lionel Landwerlin
2020-02-17 14:21 ` [igt-dev] [PATCH i-g-t 6/6] tools: add i915-perf-reader Lionel Landwerlin
2020-02-17 14:27 ` [igt-dev] [PATCH i-g-t 0/6] New performance recording/replay tools for i915-perf Lionel Landwerlin
2020-02-18 18:46 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200217142155.501499-4-lionel.g.landwerlin@intel.com \
--to=lionel.g.landwerlin@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox