All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] i915/gem_exec_suspend: Measure power consumption during suspend
@ 2019-10-27 16:22 ` Chris Wilson
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2019-10-27 16:22 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

For this test, we need a laptop running on battery power so that we can
read the battery charge level before and after suspend. And then wait
long enough for a reliable measure.

References: https://bugs.freedesktop.org/show_bug.cgi?id=111909
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 tests/i915/gem_exec_suspend.c | 37 ++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index af6190ddd..21cfa888a 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -27,9 +27,13 @@
  * Exercise executing batches across suspend before checking the results.
  */
 
+#include <fcntl.h>
+#include <unistd.h>
+
 #include "igt.h"
-#include "igt_gt.h"
 #include "igt_dummyload.h"
+#include "igt_gt.h"
+#include "igt_sysfs.h"
 
 #define NOSLEEP 0
 #define IDLE 1
@@ -232,6 +236,32 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 		test_all(fd, flags);
 }
 
+static void power_test(int i915, unsigned engine, unsigned flags)
+{
+	uint64_t before, after;
+	char *status;
+	int dir;
+
+	dir = open("/sys/class/power_supply/BAT0", O_RDONLY);
+	igt_require_f(dir != -1, "/sys/class/power_supply/BAT0 not available\n");
+
+	status = igt_sysfs_get(dir, "status");
+	igt_require_f(status && strcmp(status, "Discharging") == 0,
+		      "power test needs to be on battery, not mains, power\n");
+	free(status);
+
+	igt_set_autoresume_delay(30 * 60); /* 30 minutes */
+
+	igt_sysfs_scanf(dir, "energy_now", "%"PRIu64, &before);
+	run_test(i915, engine, flags);
+	igt_sysfs_scanf(dir, "energy_now", "%"PRIu64, &after);
+
+	igt_set_autoresume_delay(0);
+
+	igt_info("Power consumed while suspended: %.3fmWh\n",
+		 (before - after) * 1e-3);
+}
+
 igt_main
 {
 	const struct {
@@ -289,6 +319,11 @@ igt_main
 	igt_subtest("hang-S4")
 		run_test(fd, 0, HIBERNATE | HANG);
 
+	igt_subtest("power-S0")
+		power_test(fd, 0, IDLE);
+	igt_subtest("power-S3")
+		power_test(fd, 0, SUSPEND);
+
 	igt_fixture {
 		igt_disallow_hang(fd, hang);
 		close(fd);
-- 
2.24.0.rc1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-10-30 12:49 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-27 16:22 [igt-dev] [PATCH i-g-t] i915/gem_exec_suspend: Measure power consumption during suspend Chris Wilson
2019-10-27 16:22 ` [Intel-gfx] " Chris Wilson
2019-10-27 16:22 ` Chris Wilson
2019-10-27 16:41 ` [igt-dev] ✗ GitLab.Pipeline: warning for " Patchwork
2019-10-27 17:03 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2019-10-27 17:11   ` [Intel-gfx] [PATCH i-g-t] " Chris Wilson
2019-10-27 17:11     ` Chris Wilson
2019-10-30 12:30     ` [igt-dev] " Mika Kuoppala
2019-10-30 12:30       ` [Intel-gfx] " Mika Kuoppala
2019-10-30 12:30       ` Mika Kuoppala
2019-10-30 12:48       ` [igt-dev] " Chris Wilson
2019-10-30 12:48         ` [Intel-gfx] " Chris Wilson
2019-10-30 12:48         ` Chris Wilson
2019-10-27 17:51   ` [igt-dev] ✗ GitLab.Pipeline: warning for i915/gem_exec_suspend: Measure power consumption during suspend (rev2) Patchwork
2019-10-27 18:02   ` [igt-dev] ✗ Fi.CI.BAT: failure " Patchwork
2019-10-28 18:12 ` [igt-dev] ✓ Fi.CI.IGT: success for i915/gem_exec_suspend: Measure power consumption during suspend Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.