summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-11-27 17:01:44 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2020-12-13 12:01:30 +0000
commit1e96ca072c66a1bea5936186cfd0db7201c71c4a (patch)
tree454820210a1c4b5dd1eaca26505b148849df887a
parent0c080f1aa0757e93cf2440154b5e0615910e7239 (diff)
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 <chris@chris-wilson.co.uk>
-rw-r--r--lib/igt_kms.c68
-rw-r--r--lib/igt_kms.h3
2 files changed, 71 insertions, 0 deletions
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,