@@ -369,8 +369,6 @@ static void hotunbind_lateclose(struct hotunplug *priv)
driver_unbind(priv, "hot ", 0);
- driver_bind(priv, 60);
-
igt_debug("late closing the unbound device instance\n");
priv->fd.drm = close_device(priv->fd.drm);
igt_assert_eq(priv->fd.drm, -1);
@@ -382,11 +380,69 @@ static void hotunplug_lateclose(struct hotunplug *priv)
device_unplug(priv, "hot ", 0);
- bus_rescan(priv, 60);
+ igt_debug("late closing the removed device instance\n");
+ priv->fd.drm = close_device(priv->fd.drm);
+ igt_assert_eq(priv->fd.drm, -1);
+}
+
+static void hotunbind_rebind(struct hotunplug *priv)
+{
+ priv->fd.drm = local_drm_open_driver("", " for hotrebind");
+
+ driver_unbind(priv, "hot ", 60);
+
+ igt_debug("late closing the unbound device instance\n");
+ priv->fd.drm = close_device(priv->fd.drm);
+ igt_assert_eq(priv->fd.drm, -1);
+
+ driver_bind(priv, 0);
+
+ healthcheck(priv, false);
+}
+
+static void hotunplug_rescan(struct hotunplug *priv)
+{
+ priv->fd.drm = local_drm_open_driver("", " for hotreplug");
+
+ device_unplug(priv, "hot ", 60);
+
+ igt_debug("late closing the removed device instance\n");
+ priv->fd.drm = close_device(priv->fd.drm);
+ igt_assert_eq(priv->fd.drm, -1);
+
+ bus_rescan(priv, 0);
+
+ healthcheck(priv, false);
+}
+
+static void hotrebind_lateclose(struct hotunplug *priv)
+{
+ priv->fd.drm = local_drm_open_driver("", " for hotrebind");
+
+ driver_unbind(priv, "hot ", 60);
+
+ driver_bind(priv, 0);
+
+ igt_debug("late closing the unbound device instance\n");
+ priv->fd.drm = close_device(priv->fd.drm);
+ igt_assert_eq(priv->fd.drm, -1);
+
+ healthcheck(priv, false);
+}
+
+static void hotreplug_lateclose(struct hotunplug *priv)
+{
+ priv->fd.drm = local_drm_open_driver("", " for hotreplug");
+
+ device_unplug(priv, "hot ", 60);
+
+ bus_rescan(priv, 0);
igt_debug("late closing the removed device instance\n");
priv->fd.drm = close_device(priv->fd.drm);
igt_assert_eq(priv->fd.drm, -1);
+
+ healthcheck(priv, false);
}
/* Main */
@@ -419,7 +475,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);
@@ -431,7 +487,7 @@ 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-rescan")
unplug_rescan(&priv);
@@ -463,6 +519,54 @@ igt_main
recover(&priv);
}
+ igt_fixture
+ post_healthcheck(&priv);
+
+ igt_subtest_group {
+ igt_describe("Check if the driver can be cleanly rebound to a device after hotunbind-lateclose");
+ igt_subtest("hotunbind-rebind")
+ hotunbind_rebind(&priv);
+
+ igt_fixture
+ recover(&priv);
+ }
+
+ igt_fixture
+ post_healthcheck(&priv);
+
+ igt_subtest_group {
+ igt_describe("Check if a device can be cleanly restored after hotunplug-lateclose");
+ igt_subtest("hotunplug-rescan")
+ hotunplug_rescan(&priv);
+
+ igt_fixture
+ recover(&priv);
+ }
+
+ igt_fixture
+ post_healthcheck(&priv);
+
+ igt_subtest_group {
+ igt_describe("Check if the driver hot unbound from a still open device can be cleanly rebound, then the old instance released");
+ igt_subtest("hotrebind-lateclose")
+ hotrebind_lateclose(&priv);
+
+ igt_fixture
+ recover(&priv);
+ }
+
+ igt_fixture
+ post_healthcheck(&priv);
+
+ igt_subtest_group {
+ igt_describe("Check if a still open while hot unplugged device can be cleanly restored, then the old instance released");
+ igt_subtest("hotreplug-lateclose")
+ hotreplug_lateclose(&priv);
+
+ igt_fixture
+ recover(&priv);
+ }
+
igt_fixture {
post_healthcheck(&priv);