Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/amdgpu/amd_hotplug: Check the suspend state after resume
@ 2025-03-10  9:13 Tom Chung
  2025-03-10 12:27 ` ✓ i915.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tom Chung @ 2025-03-10  9:13 UTC (permalink / raw)
  To: igt-dev; +Cc: alex.hung, sunpeng.li, chiahsuan.chung

[Why & How]
Check the last hardware sleep state after resume to make sure
last suspend really reached hardware sleep state.

Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
---
 tests/amdgpu/amd_hotplug.c | 48 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/tests/amdgpu/amd_hotplug.c b/tests/amdgpu/amd_hotplug.c
index c13bf49d3..df394f920 100644
--- a/tests/amdgpu/amd_hotplug.c
+++ b/tests/amdgpu/amd_hotplug.c
@@ -27,6 +27,8 @@ IGT_TEST_DESCRIPTION("Test simulated hotplugging on connectors");
 
 /* Maximum pipes on any AMD ASIC. */
 #define MAX_PIPES 6
+#define LAST_HW_SLEEP_PATH "/sys/power/suspend_stats/last_hw_sleep"
+#define MEM_SLEEP_PATH "/sys/power/mem_sleep"
 
 /* Common test data. */
 typedef struct data {
@@ -98,6 +100,47 @@ static void test_fini(data_t *data)
 	igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
 }
 
+/* Check if mem_sleep is s2idle */
+static bool is_system_s2idle(void)
+{
+	int fd;
+	char dst[64];
+	int read_byte;
+
+	fd = open(MEM_SLEEP_PATH, O_RDONLY);
+	if (fd == -1)
+		igt_skip("Open %s file error\n", MEM_SLEEP_PATH);
+
+	read_byte = read(fd, dst, sizeof(dst));
+	close(fd);
+
+	if (read_byte <= 0)
+		igt_skip("Read %s file error\n", MEM_SLEEP_PATH);
+
+	return strstr(dst, "[s2idle]");
+}
+
+
+/* return the last hw_sleep duration time */
+static int get_last_hw_sleep_time(void)
+{
+	int fd;
+	char dst[64];
+	int read_byte;
+
+	fd = open(LAST_HW_SLEEP_PATH, O_RDONLY);
+	if (fd == -1)
+		igt_skip("Open HW sleep statistics file error\n");
+
+	read_byte = read(fd, dst, sizeof(dst));
+	close(fd);
+
+	if (read_byte <= 0)
+		igt_skip("Read HW sleep statistics file error\n");
+
+	return strtol(dst, NULL, 10);
+}
+
 static void test_hotplug_basic(data_t *data, bool suspend)
 {
 	igt_output_t *output;
@@ -131,8 +174,13 @@ static void test_hotplug_basic(data_t *data, bool suspend)
 	}
 
 	if (suspend) {
+		if (!is_system_s2idle())
+			igt_skip("System is not configured for s2idle\n");
+
 		igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
 					      SUSPEND_TEST_NONE);
+		igt_assert_f(get_last_hw_sleep_time() > 0,
+					  "Suspend did not reach hardware sleep state\n");
 	}
 
 	/* Trigger hotplug and confirm reference image is the same. */
-- 
2.43.0


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

end of thread, other threads:[~2025-03-11  6:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10  9:13 [PATCH i-g-t] tests/amdgpu/amd_hotplug: Check the suspend state after resume Tom Chung
2025-03-10 12:27 ` ✓ i915.CI.BAT: success for " Patchwork
2025-03-10 12:38 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-10 14:42 ` ✗ i915.CI.Full: failure " Patchwork
2025-03-11  6:37 ` ✓ Xe.CI.Full: success " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox