diff options
author | Rob Clark <robdclark@chromium.org> | 2022-10-14 11:20:39 -0700 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2023-02-20 10:31:36 -0800 |
commit | fdaac15d525635c9ce8cdba4dac55550553f1a65 (patch) | |
tree | 61126680fe774f4ad17f55e033c4a2a1411b4c14 | |
parent | 801133247a1469d5e16a0396036a37664574ed57 (diff) |
tests/msm: Read the devcore back in recovery tests
This also adds coverage for codepaths related to reading back the
devcore file from sysfs, to help catch issues like
https://gitlab.freedesktop.org/drm/msm/-/issues/20
Signed-off-by: Rob Clark <robdclark@chromium.org>
-rw-r--r-- | tests/msm/msm_recovery.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/msm/msm_recovery.c b/tests/msm/msm_recovery.c index e01087b43..05c89948b 100644 --- a/tests/msm/msm_recovery.c +++ b/tests/msm/msm_recovery.c @@ -22,15 +22,57 @@ */ #include <fcntl.h> +#include <glob.h> #include "igt.h" #include "igt_msm.h" +#include "igt_io.h" static struct msm_device *dev; static struct msm_bo *scratch_bo; static uint32_t *scratch; /* + * Helper to read and clear devcore. We want to read it completely to ensure + * we catch any kernel side regressions like: + * https://gitlab.freedesktop.org/drm/msm/-/issues/20 + */ + +static void +read_and_clear_devcore(void) +{ + glob_t glob_buf = {0}; + int ret, fd; + + ret = glob("/sys/class/devcoredump/devcd*/data", GLOB_NOSORT, NULL, &glob_buf); + if ((ret == GLOB_NOMATCH) || !glob_buf.gl_pathc) + return; + + fd = open(glob_buf.gl_pathv[0], O_RDWR); + + if (fd >= 0) { + char buf[0x1000]; + + /* + * We want to read the entire file but we can throw away the + * contents.. we just want to make sure that we exercise the + * kernel side codepaths hit when reading the devcore from + * sysfs + */ + do { + ret = igt_readn(fd, buf, sizeof(buf)); + } while (ret > 0); + + /* Clear the devcore: */ + igt_writen(fd, "1", 1); + + close(fd); + } + + globfree(&glob_buf); +} + +/* * Helpers for cmdstream packet building: */ @@ -102,6 +144,8 @@ do_hang_test(struct msm_pipe *pipe) continue; igt_assert_eq(scratch[1+i], 2+i); } + + read_and_clear_devcore(); } /* |