Verify if an additional address space associated with an open device file descriptor is cleaned up correctly on device hotunbind / hotunplug. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@xxxxxxxxxxxxxxx> --- tests/core_hotunplug.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 4f6c4f625..decfcdfda 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -32,6 +32,7 @@ #include "i915/gem.h" #include "i915/gem_context.h" +#include "i915/gem_vm.h" #include "igt.h" #include "igt_device_scan.h" #include "igt_kmod.h" @@ -600,6 +601,60 @@ static void ctx_hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); } +static void vm_hotunbind_lateclose(struct hotunplug *priv) +{ + int vm; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_vm(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating additional GEM user address space"); + vm = gem_vm_create(priv->fd.drm); + + driver_unbind(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the address space"); + igt_assert_eq(__gem_vm_destroy(priv->fd.drm, vm), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); +} + +static void vm_hotunplug_lateclose(struct hotunplug *priv) +{ + int vm; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_vm(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating additional GEM user address space"); + vm = gem_vm_create(priv->fd.drm); + + device_unplug(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the address space"); + igt_assert_eq(__gem_vm_destroy(priv->fd.drm, vm), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); +} + /* Main */ igt_main @@ -761,6 +816,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unboound form a still open device with extra GEM address space, then released"); + igt_subtest("vm-hotunbind-lateclose") + vm_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a still open device with extra GEM address space can be cleanly unplugged, then released"); + igt_subtest("vm-hotunplug-lateclose") + vm_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); -- 2.25.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx