[PATCH i-g-t 16/20] tests/core_hotunplug: Turn off autoprobe on bus rescan

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Thu Jul 23 14:57:39 UTC 2020


Potential work around DMAR errors on immediate driver binding to a
rediscovered device.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index b4f2a2c5a..b8e08e738 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -160,6 +160,19 @@ static void bus_rescan(struct hotunplug *priv)
 		      "Fakely unplugged device not rediscovered!\n");
 }
 
+static void device_restore(struct hotunplug *priv)
+{
+	igt_warn_on_f(!igt_sysfs_set(priv->fd.sysfs_bus, "../drivers_autoprobe",
+				     "0"),
+		      "An attempt to turn off bus drivers autoprobe failed\n");
+	bus_rescan(priv);
+	igt_assert_f(igt_sysfs_set(priv->fd.sysfs_bus, "../drivers_autoprobe",
+				   "1"),
+		     "An attempt to restore bus drivers autoprobe failed\n");
+
+	driver_bind(priv);
+}
+
 static void cleanup(struct hotunplug *priv)
 {
 	priv->fd.drm = local_close(priv->fd.drm);
@@ -173,7 +186,7 @@ static void healthcheck(struct hotunplug *priv)
 
 	if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) {
 		priv->failure = "Bus rescan failed!";
-		bus_rescan(priv);
+		device_restore(priv);
 		priv->failure = NULL;
 	}
 
@@ -246,6 +259,15 @@ static void unbind_rebind(struct hotunplug *priv)
 	driver_bind(priv);
 }
 
+static void unplug_restore(struct hotunplug *priv)
+{
+	priv->failure = "subtest failure";
+
+	device_unplug(priv, "");
+
+	device_restore(priv);
+}
+
 static void unplug_rescan(struct hotunplug *priv)
 {
 	priv->failure = "subtest failure";
@@ -282,7 +304,7 @@ static void hotunplug_lateclose(struct hotunplug *priv)
 
 	device_unplug(priv, "hot ");
 
-	bus_rescan(priv);
+	device_restore(priv);
 
 	igt_debug("late closing the removed device instance\n");
 	priv->fd.drm = local_close(priv->fd.drm);
@@ -321,7 +343,7 @@ igt_main
 	}
 
 	igt_subtest_group {
-		igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed");
+		igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed, then rebound");
 		igt_subtest("unbind-rebind")
 			unbind_rebind(&priv);
 
@@ -333,7 +355,19 @@ igt_main
 		post_healthcheck(&priv);
 
 	igt_subtest_group {
-		igt_describe("Check if a device believed to be closed can be cleanly unplugged");
+		igt_describe("Check if a device believed to be closed can be cleanly unplugged, then restored");
+		igt_subtest("unplug-restore")
+			unplug_restore(&priv);
+
+		igt_fixture
+			healthcheck(&priv);
+	}
+
+	igt_fixture
+		post_healthcheck(&priv);
+
+	igt_subtest_group {
+		igt_describe("Check if a device believed to be closed can be cleanly unplugged, then rediscovered");
 		igt_subtest("unplug-rescan")
 			unplug_rescan(&priv);
 
-- 
2.21.1



More information about the Intel-gfx-trybot mailing list