From f44a24fe9f1948a117daf3162db53df7820f9923 Mon Sep 17 00:00:00 2001
From: Anshuman Gupta <anshuman.gupta@intel.com>
Date: Fri, 3 Mar 2023 21:19:41 +0530
Subject: [PATCH] perf_pmu: Dump i915_runtime_pm_status

Dump i915_pm_runtime_status in case of i915 device failed to runtime
suspend, it will dump the rpm wakeref tracking information which
will useful to debug the runtime pm issues.

v2:
- Use wait_for_suspended(). [Ashutosh]

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 tests/i915/perf_pmu.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
index c1779fc9d..df194c8ad 100644
--- a/tests/i915/perf_pmu.c
+++ b/tests/i915/perf_pmu.c
@@ -1703,6 +1703,16 @@ static bool wait_for_rc6(int fd, int timeout)
 	return false;
 }
 
+static bool wait_for_suspended(int gem_fd)
+{
+	bool suspended = igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED);
+
+	if (!suspended)
+		__igt_debugfs_dump(gem_fd, "i915_runtime_pm_status", IGT_LOG_INFO);
+
+	return suspended;
+}
+
 static void
 test_rc6(int gem_fd, unsigned int flags)
 {
@@ -1727,7 +1737,7 @@ test_rc6(int gem_fd, unsigned int flags)
 		drmModeFreeResources(res);
 
 		igt_require(igt_setup_runtime_pm(gem_fd));
-		igt_require(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+		igt_require(wait_for_suspended(gem_fd));
 
 		/*
 		 * Sleep for a bit to see if once woken up estimated RC6 hasn't
-- 
GitLab