From 1e96ca072c66a1bea5936186cfd0db7201c71c4a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 27 Nov 2020 17:01:44 +0000 Subject: lib/kms: Open per-crtc debugfs around kmstests Drivers may include useful snippets of information in per-crtc debugfs, that we may check around pipe tests. For instance, rather than the kernel warn everytime a CRTC update exceeds a certain threshold, we can check ourselves and so only flag a test failure when looking for such failures. And more importantly, present the information for debugging them. Signed-off-by: Chris Wilson --- lib/igt_kms.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 71 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 9175e50f..3f879033 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -4890,3 +4890,71 @@ void igt_dump_crtcs_fd(int drmfd) drmModeFreeResources(mode_resources); } + +static int open_crtc_debugfs(int drmfd, enum pipe pipe) +{ + char buf[80]; + int dbg, dir; + + dbg = igt_debugfs_dir(drmfd); + if (dbg < 0) + return -1; + + snprintf(buf, sizeof(buf), "crtc-%d", pipe); + dir = openat(dbg, buf, O_DIRECTORY); + close(dbg); + + return dir; +} + +void kmstest_pipe_begin(int drmfd, enum pipe pipe) +{ + int dir; + + dir = open_crtc_debugfs(drmfd, pipe); + if (dir < 0) + return; + + igt_sysfs_set(dir, "i915_update_info", "reset"); + close(dir); +} + +static void check_i915_updates(enum pipe pipe, const char *str) +{ + const char *s; + unsigned long over; + + s = strstr(str, "Overrun"); + if (!s) + return; + + s = strchr(s, ':'); + if (!s) + return; + + over = 0; + sscanf(s + 1, "%lu", &over); + if (over) { + igt_warn("%s exceeded update threshold\n", + kmstest_pipe_name(pipe)); + igt_debug("%s\n", str); + } +} + +void kmstest_pipe_end(int drmfd, enum pipe pipe) +{ + char *str; + int dir; + + dir = open_crtc_debugfs(drmfd, pipe); + if (dir < 0) + return; + + str = igt_sysfs_get(dir, "i915_update_info"); + if (str) { + check_i915_updates(pipe, str); + free(str); + } + + close(dir); +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 1fcae243..da26b460 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -68,6 +68,9 @@ const char *kmstest_pipe_name(enum pipe pipe); int kmstest_pipe_to_index(char pipe); const char *kmstest_plane_type_name(int plane_type); +void kmstest_pipe_begin(int drmfd, enum pipe pipe); +void kmstest_pipe_end(int drmfd, enum pipe pipe); + enum port { PORT_A = 0, PORT_B, -- cgit v1.2.3