Skip to contentSkip to conversation

tests/msm: Read the devcore back in recovery tests

PATCH In review Rob Clark 3 participants 6 messages Dec 11, 2022 – Dec 13, 2022

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 tests/msm: Read the devcore back in recovery tests

From: Rob Clark <[email protected]>

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

---
 tests/msm/msm_recovery.c | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/msm/msm_recovery.c +42 -0
index e01087b4..4c2f2846 100644
@@ -22,14 +22,54 @@
  */
 
 #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);
+	}
+
+	globfree(&glob_buf);
+}
+
 /*
  * Helpers for cmdstream packet building:
  */
@@ -102,6 +142,8 @@ do_hang_test(struct msm_pipe *pipe)
 			continue;
 		igt_assert_eq(scratch[1+i], 2+i);
 	}
+
+	read_and_clear_devcore();
 }
 
 /*
Signature · 1 line
2.38.1
#1 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/msm: Read the devcore back in recovery tests

== Series Details ==

== Series Details ==

Series: tests/msm: Read the devcore back in recovery tests
URL : https://patchwork.freedesktop.org/series/111828/
State : failure

== Summary ==

Applying: tests/msm: Read the devcore back in recovery tests Using index info to reconstruct a base tree...
M tests/msm/msm_recovery.c
Falling back to patching base and 3-way merge... Auto-merging tests/msm/msm_recovery.c
CONFLICT (content): Merge conflict in tests/msm/msm_recovery.c Patch failed at 0001 tests/msm: Read the devcore back in recovery tests When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

#2 lore raw
In reply to Rob Clark

Hi Rob,

before sending again please rebase on current igt (see logs from gitlab).
I have also one small nit below.

Quoted 52 lines · Rob Clark

From: Rob Clark <[email protected]>

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

---
 tests/msm/msm_recovery.c | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/msm/msm_recovery.c +25 -0
index e01087b4..4c2f2846 100644
@@ -22,14 +22,54 @@
  */
 
 #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

tests/msm/msm_recovery.c line 67

Quoted 10 lines
tests/msm/msm_recovery.c +10 -0
+		 * 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);

Put here:

		fclose(fd);

Regards,
Kamil

Quoted 20 lines
tests/msm/msm_recovery.c +7 -0
+	}
+
+	globfree(&glob_buf);
+}
+
 /*
  * Helpers for cmdstream packet building:
  */
@@ -102,6 +142,8 @@ do_hang_test(struct msm_pipe *pipe)
 			continue;
 		igt_assert_eq(scratch[1+i], 2+i);
 	}
+
+	read_and_clear_devcore();
 }
 
 /*
Signature · 1 line
2.38.1
author
#3 lore raw
Quoted 5 lines · Kamil Konieczny

Hi Rob,

before sending again please rebase on current igt (see logs from gitlab).

sure.. but I was based on ToT as of the 7th, and it rebased cleanly.. not sure if you had some concern than I'm overlooking

Quoted 67 lines

I have also one small nit below.

Quoted 52 lines · Rob Clark

From: Rob Clark <[email protected]>

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

---
 tests/msm/msm_recovery.c | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/msm/msm_recovery.c +25 -0
index e01087b4..4c2f2846 100644
@@ -22,14 +22,54 @@
  */
 
 #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

tests/msm/msm_recovery.c line 67

Quoted 10 lines
tests/msm/msm_recovery.c +10 -0
+              * 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);

Put here:

Quoted 2 lines
                fclose(fd);

oh, right, good catch

BR,
-R

Quoted 23 lines

Regards,
Kamil

Quoted 20 lines
tests/msm/msm_recovery.c +7 -1
+     }
+
+     globfree(&glob_buf);
+}
+
 /*
  * Helpers for cmdstream packet building:
  */
@@ -102,6 +142,8 @@ do_hang_test(struct msm_pipe *pipe)
                      continue;
              igt_assert_eq(scratch[1+i], 2+i);
      }
+
+     read_and_clear_devcore();
 }
 
 /*
--

2.38.1

#4 lore raw

Hi Rob,

Quoted 10 lines · Rob Clark
Quoted 5 lines · Kamil Konieczny

Hi Rob,

before sending again please rebase on current igt (see logs from gitlab).

sure.. but I was based on ToT as of the 7th, and it rebased cleanly.. not sure if you had some concern than I'm overlooking

Well it depends on previous ones, especially this one:

[1/2] lib: Add helper to wait and close fence fd

so please either send it as part of whole series or wait for others to be merged.
Btw it would help if you at least note such dependancy in cover letter or in patch description after "---" like:

---
some notes that will not go into git repo, for example:
This patch depends on "lib: Add helper to wait and close fence fd"

It will help maintainters to look at this only after other parts will go.

Regards,
Kamil

Quoted 99 lines
Quoted 68 lines

I have also one small nit below.

Quoted 52 lines · Rob Clark

From: Rob Clark <[email protected]>

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

---
 tests/msm/msm_recovery.c | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/msm/msm_recovery.c +25 -0
index e01087b4..4c2f2846 100644
@@ -22,14 +22,54 @@
  */
 
 #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

tests/msm/msm_recovery.c line 67

Quoted 10 lines
tests/msm/msm_recovery.c +10 -0
+              * 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);

Put here:

Quoted 2 lines
                fclose(fd);

oh, right, good catch

BR,
-R

Quoted 23 lines

Regards,
Kamil

Quoted 20 lines
tests/msm/msm_recovery.c +7 -1
+     }
+
+     globfree(&glob_buf);
+}
+
 /*
  * Helpers for cmdstream packet building:
  */
@@ -102,6 +142,8 @@ do_hang_test(struct msm_pipe *pipe)
                      continue;
              igt_assert_eq(scratch[1+i], 2+i);
      }
+
+     read_and_clear_devcore();
 }
 
 /*
--

2.38.1

author
#5 lore raw
Quoted 12 lines · Kamil Konieczny

Hi Rob,

Quoted 8 lines · Rob Clark
Quoted 5 lines · Kamil Konieczny

Hi Rob,

before sending again please rebase on current igt (see logs from gitlab).

Quoted 7 lines
Quoted 2 lines

sure.. but I was based on ToT as of the 7th, and it rebased cleanly.. not sure if you had some concern than I'm overlooking

Well it depends on previous ones, especially this one:

[1/2] lib: Add helper to wait and close fence fd

there is a trivial conflict to resolve if this is merged before that series.. but I can deal with that before pushing, once patches get r-b's ;-)

BR,
-R

Quoted 114 lines

so please either send it as part of whole series or wait for others to be merged.
Btw it would help if you at least note such dependancy in cover letter or in patch description after "---" like:

---
some notes that will not go into git repo, for example:
This patch depends on "lib: Add helper to wait and close fence fd"

It will help maintainters to look at this only after other parts will go.

Regards,
Kamil

Quoted 99 lines
Quoted 68 lines

I have also one small nit below.

Quoted 52 lines · Rob Clark

From: Rob Clark <[email protected]>

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

---
 tests/msm/msm_recovery.c | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/msm/msm_recovery.c +25 -0
index e01087b4..4c2f2846 100644
@@ -22,14 +22,54 @@
  */
 
 #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

tests/msm/msm_recovery.c line 67

Quoted 10 lines
tests/msm/msm_recovery.c +10 -0
+              * 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);

Put here:

Quoted 2 lines
                fclose(fd);

oh, right, good catch

BR,
-R

Quoted 23 lines

Regards,
Kamil

Quoted 20 lines
tests/msm/msm_recovery.c +7 -1
+     }
+
+     globfree(&glob_buf);
+}
+
 /*
  * Helpers for cmdstream packet building:
  */
@@ -102,6 +142,8 @@ do_hang_test(struct msm_pipe *pipe)
                      continue;
              igt_assert_eq(scratch[1+i], 2+i);
      }
+
+     read_and_clear_devcore();
 }
 
 /*
--

2.38.1