From 273e66baef8bf930959c503041b68411bb42ff80 Mon Sep 17 00:00:00 2001 From: Tvrtko Ursulin Date: Tue, 10 Oct 2017 08:22:30 +0100 Subject: intel-gpu-overlay: Use RAPL PMU for power reading Wire up to the RAPL PMU for GPU energy readings. The only complication is that we have to add code to parse: # cat /sys/devices/power/events/energy-gpu.scale 2.3283064365386962890625e-10 v2: Link with -lm. v3: strtod can handle scientific notation, even though my initial reading of the man page did not spot that. (Chris Wilson) v4: Meson fix. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- lib/igt_perf.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/igt_perf.c') diff --git a/lib/igt_perf.c b/lib/igt_perf.c index 20847430..0221461e 100644 --- a/lib/igt_perf.c +++ b/lib/igt_perf.c @@ -27,11 +27,12 @@ uint64_t i915_type_id(void) return strtoull(buf, NULL, 0); } -static int _perf_open(uint64_t config, int group, uint64_t format) +static int +_perf_open(uint64_t type, uint64_t config, int group, uint64_t format) { struct perf_event_attr attr = { }; - attr.type = i915_type_id(); + attr.type = type; if (attr.type == 0) return -ENOENT; @@ -46,11 +47,18 @@ static int _perf_open(uint64_t config, int group, uint64_t format) int perf_i915_open(uint64_t config) { - return _perf_open(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED); + return _perf_open(i915_type_id(), config, -1, + PERF_FORMAT_TOTAL_TIME_ENABLED); } int perf_i915_open_group(uint64_t config, int group) { - return _perf_open(config, group, + return _perf_open(i915_type_id(), config, group, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP); } + +int igt_perf_open(uint64_t type, uint64_t config) +{ + return _perf_open(type, config, -1, + PERF_FORMAT_TOTAL_TIME_ENABLED); +} -- cgit v1.2.3