[PATCH i-g-t] i915/gem_exec_schedule: Handle package power RAPL unavailability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 lib/igt_rapl.h                 |  6 ++++++
 tests/i915/gem_exec_schedule.c | 16 +++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/igt_rapl.h b/lib/igt_rapl.h
index 55c46198e..13f4f88a7 100644
--- a/lib/igt_rapl.h
+++ b/lib/igt_rapl.h
@@ -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,
diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
index 9a2f2352b..8695cbe9d 100644
--- a/tests/i915/gem_exec_schedule.c
+++ b/tests/i915/gem_exec_schedule.c
@@ -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);
-- 
2.24.0.rc0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux