[PATCH i-g-t 2/3] tests/intel/xe_pm_residency: Check for other DRM device users

Soham Purkait
2026-03-30T16:25:17Z

If other processes are using the DRM device while idle residency test
is running, GPU engines may be in use, and idle residency might be lower
than expected leading to false positives.
To help identify this issue, a check for the DRM clients, except the very
test, is used and a warning message is printed if any such processes
are found and the test is skipped.

Signed-off-by: Soham Purkait <soham.purkait@intel.com>
---
tests/intel/xe_pm_residency.c | 25 +++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 26 insertions(+)

diff --git a/tests/intel/xe_pm_residency.c b/tests/intel/xe_pm_residency.c
index 61b63ed4f..43c6a27f0 100644
--- a/tests/intel/xe_pm_residency.c
+++ b/tests/intel/xe_pm_residency.c
@@ -20,6 +20,7 @@
#include "igt_power.h"
#include "igt_sysfs.h"

+#include "lib/igt_drm_clients.h"
#include "lib/igt_syncobj.h"

#include "xe/xe_ioctl.h"
@@ -215,6 +216,30 @@ static unsigned long read_idle_residency(int fd, int gt)
static void test_idle_residency(int fd, int gt, enum test_type flag)
{
unsigned long elapsed_ms, residency_start, residency_end;
+ struct igt_drm_client_proc *procs = NULL;
+ unsigned long wait = 100000;
+ int num_clients = 0;
+
+ /* Wait for other processes using the DRM device ends */
+ for (int pass = 0; pass < 50; pass++) {
+ if (!igt_drm_get_client_procs(fd, getpid(), NULL))
+ break;
+ usleep(wait);
+ }
+
+ num_clients = igt_drm_get_client_procs(fd, getpid(), &procs);
+
+ /* Check if any process is still using the DRM device */
+ if (num_clients) {
+ for (unsigned int i = 0; i < num_clients; i++) {
+ igt_warn("%s (pid=%u client=%lu) is using DRM device.\n",
+ procs[i].print_name, procs[i].pid, procs[i].id);
+ }
+ free(procs);
+ procs = NULL;
+ igt_skip("As other processes are using the DRM device, "
+ "measured idle_residency may differ from elapsed_ms.\n");
+ }

igt_assert_f(igt_wait(xe_gt_is_in_c6(fd, gt), 1000, 1), "GT %d not in C6\n", gt);

diff --git a/tests/meson.build b/tests/meson.build
index cecb4a8ae..eb4de8772 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -424,6 +424,7 @@ extra_dependencies = {
'sw_sync': [ libatomic ],
'xe_fault_injection': [ lib_igt_xe_oa ],
'xe_oa': [ lib_igt_xe_oa ],
+ 'xe_pm_residency': [ lib_igt_drm_clients ],
'xe_compute': [ igt_deps,lib_igt_perf,lib_igt_profiling,math ],
}

--
2.43.0