@@ -56,6 +56,11 @@ static inline int pkg_power_open(struct rapl *r)
return rapl_open(r, "pkg");
}
+static inline bool rapl_valid(struct rapl *r)
+{
+ return r->fd >= 0;
+}
+
static inline int ram_power_open(struct rapl *r)
{
return rapl_open(r, "ram");
@@ -69,6 +74,7 @@ static inline bool rapl_read(struct rapl *r, struct power_sample *s)
static inline void rapl_close(struct rapl *r)
{
close(r->fd);
+ r->fd = -1;
}
static inline double power_J(const struct rapl *r,
@@ -1611,8 +1611,8 @@ static void measure_semaphore_power(int i915)
unsigned int engine, signaler;
struct rapl gpu, pkg;
- igt_require(pkg_power_open(&pkg) == 0);
igt_require(gpu_power_open(&gpu) == 0);
+ pkg_power_open(&pkg);
for_each_physical_engine(i915, signaler) {
struct {
@@ -1665,12 +1665,14 @@ static void measure_semaphore_power(int i915)
1e3 * (total - baseline),
1e3 * total);
- baseline = power_W(&pkg, &s_spin[0].pkg, &s_spin[1].pkg);
- total = power_W(&pkg, &s_sema[0].pkg, &s_sema[1].pkg);
- igt_info("pkg: %.1fmW + %.1fmW (total %1.fmW)\n",
- 1e3 * baseline,
- 1e3 * (total - baseline),
- 1e3 * total);
+ if (rapl_valid(&pkg)) {
+ baseline = power_W(&pkg, &s_spin[0].pkg, &s_spin[1].pkg);
+ total = power_W(&pkg, &s_sema[0].pkg, &s_sema[1].pkg);
+ igt_info("pkg: %.1fmW + %.1fmW (total %1.fmW)\n",
+ 1e3 * baseline,
+ 1e3 * (total - baseline),
+ 1e3 * total);
+ }
}
rapl_close(&gpu);
It turns out that not all platforms have working package power. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=112094 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- lib/igt_rapl.h | 6 ++++++ tests/i915/gem_exec_schedule.c | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-)