[PATCH i-g-t v6 17/24] tests/core_hotunplug: Also check health of render device node

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Wed Sep 9 17:40:24 UTC 2020


Failures of subsequent tests accessing the render device node have been
observed on CI after late close of a hot rebound device.  Extend our
health check over the render node to detect that condition, then start
our recovery phase from unbinding the driver from the device found
faulty.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
 tests/core_hotunplug.c | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index bcd5451f4..77f4b5aee 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -55,13 +55,16 @@ struct hotunplug {
  * use drm_open_driver() since in case of an i915 device it opens it
  * twice and keeps a second file descriptor open for exit handler use.
  */
-static int local_drm_open_driver(const char *prefix, const char *suffix)
+static int local_drm_open_driver(bool render, const char *prefix,
+				 const char *suffix)
 {
 	int fd_drm;
 
-	igt_debug("%sopening device%s\n", prefix, suffix);
+	igt_debug("%sopening %s device%s\n", prefix, render ? "render" : "DRM",
+		  suffix);
 
-	fd_drm = __drm_open_driver(DRIVER_ANY);
+	fd_drm = render ? __drm_open_driver_render(DRIVER_ANY) :
+			  __drm_open_driver(DRIVER_ANY);
 	igt_assert_fd(fd_drm);
 
 	return fd_drm;
@@ -196,16 +199,14 @@ static void cleanup(struct hotunplug *priv)
 	priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev);
 }
 
-static void healthcheck(struct hotunplug *priv)
+static void node_healthcheck(struct hotunplug *priv, bool render)
 {
 	/* preserve error code potentially stored before in priv->fd.drm */
 	int fd_drm;
 
-	/* device name may have changed, rebuild IGT device list */
-	igt_devices_scan(true);
-
-	priv->failure = "Device reopen failure!";
-	fd_drm = local_drm_open_driver("re", " for healthcheck");
+	priv->failure = render ? "Render device reopen failure!" :
+				 "DRM device reopen failure!";
+	fd_drm = local_drm_open_driver(render, "re", " for healthcheck");
 	if (priv->fd.drm == -1)	/* store for cleanup if no error to preserve */
 		priv->fd.drm = fd_drm;
 
@@ -227,10 +228,24 @@ static void healthcheck(struct hotunplug *priv)
 	igt_fail_on_f(priv->failure, "%s\n", priv->failure);
 }
 
+static void healthcheck(struct hotunplug *priv)
+{
+	/* device name may have changed, rebuild IGT device list */
+	igt_devices_scan(true);
+
+	node_healthcheck(priv, false);
+	node_healthcheck(priv, true);
+}
+
 static void recover(struct hotunplug *priv)
 {
 	cleanup(priv);
 
+	/* unbind the driver from a possibly hot rebound unhealthy device */
+	if (!faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0) &&
+	    priv->fd.drm == -1 && priv->failure)
+		driver_unbind(priv, "post ", 60);
+
 	if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0))
 		bus_rescan(priv, 60);
 
@@ -291,7 +306,7 @@ static void unplug_rescan(struct hotunplug *priv)
 static void hotunbind_lateclose(struct hotunplug *priv)
 {
 	igt_assert_eq(priv->fd.drm, -1);
-	priv->fd.drm = local_drm_open_driver("", " for hotunbind");
+	priv->fd.drm = local_drm_open_driver(false, "", " for hotunbind");
 
 	driver_unbind(priv, "hot ", 0);
 
@@ -307,7 +322,7 @@ static void hotunbind_lateclose(struct hotunplug *priv)
 static void hotunplug_lateclose(struct hotunplug *priv)
 {
 	igt_assert_eq(priv->fd.drm, -1);
-	priv->fd.drm = local_drm_open_driver("", " for hotunplug");
+	priv->fd.drm = local_drm_open_driver(false, "", " for hotunplug");
 
 	device_unplug(priv, "hot ", 0);
 
-- 
2.21.1



More information about the Intel-gfx-trybot mailing list