All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [RFC PATCH i-g-t 0/8] tests/core_hotunplug: New subtests and enhancements
@ 2020-06-22 15:18 ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Add a bunch of new test variants, enhance debugging of hotunplug driver
issues.

Janusz Krzysztofik (8):
  tests/core_hotunplug: Duplicate debug messages in dmesg
  tests/core_hotunplug: Use PCI device sysfs entry, not DRM
  tests/core_hotunplug: Add unbind-unplug-rescan variant
  tests/core_hotunplug: Add 'lateclose before recover' variants
  tests/core_hotunplug: Add 'GEM address space' variant
  tests/core_hotunplug: Add 'GEM object' variant
  tests/core_hotunplug: Add 'PRIME handle' variant
  tests/core_hotunplug: Add 'GEM batch' variant

 tests/core_hotunplug.c | 331 +++++++++++++++++++++++++++++++++++------
 1 file changed, 284 insertions(+), 47 deletions(-)

-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 0/8] tests/core_hotunplug: New subtests and enhancements
@ 2020-06-22 15:18 ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Add a bunch of new test variants, enhance debugging of hotunplug driver
issues.

Janusz Krzysztofik (8):
  tests/core_hotunplug: Duplicate debug messages in dmesg
  tests/core_hotunplug: Use PCI device sysfs entry, not DRM
  tests/core_hotunplug: Add unbind-unplug-rescan variant
  tests/core_hotunplug: Add 'lateclose before recover' variants
  tests/core_hotunplug: Add 'GEM address space' variant
  tests/core_hotunplug: Add 'GEM object' variant
  tests/core_hotunplug: Add 'PRIME handle' variant
  tests/core_hotunplug: Add 'GEM batch' variant

 tests/core_hotunplug.c | 331 +++++++++++++++++++++++++++++++++++------
 1 file changed, 284 insertions(+), 47 deletions(-)

-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 1/8] tests/core_hotunplug: Duplicate debug messages in dmesg
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

The purpose of debug messages displayed by the test is to make
identification of a subtest phase that fails more easy.  Since issues
exhibited by the test are mostly reported to dmesg, print those debug
messages to /dev/kmsg as well.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index f9cfc8c3c..187168009 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -48,6 +48,12 @@ struct hotunplug {
 
 /* Helpers */
 
+#define local_debug(msg...)						     \
+({									     \
+	igt_debug("%s: %s\n", __func__, msg);				     \
+	igt_kmsg(KMSG_DEBUG "%s: %s: %s\n", igt_test_name(), __func__, msg); \
+})
+
 static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
 {
 	int len;
@@ -67,9 +73,9 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
 	close(priv->fd.sysfs_dev);
 }
 
-static void prepare(struct hotunplug *priv, char *buf, int buflen)
+static inline void prepare(struct hotunplug *priv, char *buf, int buflen)
 {
-	igt_debug("opening device\n");
+	local_debug("opening device");
 	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
 	igt_assert(priv->fd.drm >= 0);
 
@@ -136,14 +142,14 @@ static void bus_rescan(int fd_sysfs_bus)
 	close(fd_sysfs_bus);
 }
 
-static void healthcheck(void)
+static inline void healthcheck(void)
 {
 	int fd_drm;
 
 	/* device name may have changed, rebuild IGT device list */
 	igt_devices_scan(true);
 
-	igt_debug("reopening the device\n");
+	local_debug("reopening the device");
 	fd_drm = __drm_open_driver(DRIVER_ANY);
 	igt_abort_on_f(fd_drm < 0, "Device reopen failure");
 
@@ -179,13 +185,13 @@ static void unbind_rebind(void)
 
 	prepare(&priv, buf, sizeof(buf));
 
-	igt_debug("closing the device\n");
+	local_debug("closing the device");
 	close(priv.fd.drm);
 
-	igt_debug("unbinding the driver from the device\n");
+	local_debug("unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("rebinding the driver to the device\n");
+	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
 	healthcheck();
@@ -197,13 +203,13 @@ static void unplug_rescan(void)
 
 	prepare(&priv, NULL, 0);
 
-	igt_debug("closing the device\n");
+	local_debug("closing the device");
 	close(priv.fd.drm);
 
-	igt_debug("unplugging the device\n");
+	local_debug("unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
 
-	igt_debug("recovering the device\n");
+	local_debug("recovering the device");
 	bus_rescan(priv.fd.sysfs_bus);
 
 	healthcheck();
@@ -216,13 +222,13 @@ static void hotunbind_lateclose(void)
 
 	prepare(&priv, buf, sizeof(buf));
 
-	igt_debug("hot unbinding the driver from the device\n");
+	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("rebinding the driver to the device\n");
+	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("late closing the unbound device instance\n");
+	local_debug("late closing the unbound device instance");
 	close(priv.fd.drm);
 
 	healthcheck();
@@ -234,13 +240,13 @@ static void hotunplug_lateclose(void)
 
 	prepare(&priv, NULL, 0);
 
-	igt_debug("hot unplugging the device\n");
+	local_debug("hot unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
 
-	igt_debug("recovering the device\n");
+	local_debug("recovering the device");
 	bus_rescan(priv.fd.sysfs_bus);
 
-	igt_debug("late closing the removed device instance\n");
+	local_debug("late closing the removed device instance");
 	close(priv.fd.drm);
 
 	healthcheck();
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 1/8] tests/core_hotunplug: Duplicate debug messages in dmesg
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

The purpose of debug messages displayed by the test is to make
identification of a subtest phase that fails more easy.  Since issues
exhibited by the test are mostly reported to dmesg, print those debug
messages to /dev/kmsg as well.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index f9cfc8c3c..187168009 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -48,6 +48,12 @@ struct hotunplug {
 
 /* Helpers */
 
+#define local_debug(msg...)						     \
+({									     \
+	igt_debug("%s: %s\n", __func__, msg);				     \
+	igt_kmsg(KMSG_DEBUG "%s: %s: %s\n", igt_test_name(), __func__, msg); \
+})
+
 static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
 {
 	int len;
@@ -67,9 +73,9 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
 	close(priv->fd.sysfs_dev);
 }
 
-static void prepare(struct hotunplug *priv, char *buf, int buflen)
+static inline void prepare(struct hotunplug *priv, char *buf, int buflen)
 {
-	igt_debug("opening device\n");
+	local_debug("opening device");
 	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
 	igt_assert(priv->fd.drm >= 0);
 
@@ -136,14 +142,14 @@ static void bus_rescan(int fd_sysfs_bus)
 	close(fd_sysfs_bus);
 }
 
-static void healthcheck(void)
+static inline void healthcheck(void)
 {
 	int fd_drm;
 
 	/* device name may have changed, rebuild IGT device list */
 	igt_devices_scan(true);
 
-	igt_debug("reopening the device\n");
+	local_debug("reopening the device");
 	fd_drm = __drm_open_driver(DRIVER_ANY);
 	igt_abort_on_f(fd_drm < 0, "Device reopen failure");
 
@@ -179,13 +185,13 @@ static void unbind_rebind(void)
 
 	prepare(&priv, buf, sizeof(buf));
 
-	igt_debug("closing the device\n");
+	local_debug("closing the device");
 	close(priv.fd.drm);
 
-	igt_debug("unbinding the driver from the device\n");
+	local_debug("unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("rebinding the driver to the device\n");
+	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
 	healthcheck();
@@ -197,13 +203,13 @@ static void unplug_rescan(void)
 
 	prepare(&priv, NULL, 0);
 
-	igt_debug("closing the device\n");
+	local_debug("closing the device");
 	close(priv.fd.drm);
 
-	igt_debug("unplugging the device\n");
+	local_debug("unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
 
-	igt_debug("recovering the device\n");
+	local_debug("recovering the device");
 	bus_rescan(priv.fd.sysfs_bus);
 
 	healthcheck();
@@ -216,13 +222,13 @@ static void hotunbind_lateclose(void)
 
 	prepare(&priv, buf, sizeof(buf));
 
-	igt_debug("hot unbinding the driver from the device\n");
+	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("rebinding the driver to the device\n");
+	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
-	igt_debug("late closing the unbound device instance\n");
+	local_debug("late closing the unbound device instance");
 	close(priv.fd.drm);
 
 	healthcheck();
@@ -234,13 +240,13 @@ static void hotunplug_lateclose(void)
 
 	prepare(&priv, NULL, 0);
 
-	igt_debug("hot unplugging the device\n");
+	local_debug("hot unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
 
-	igt_debug("recovering the device\n");
+	local_debug("recovering the device");
 	bus_rescan(priv.fd.sysfs_bus);
 
-	igt_debug("late closing the removed device instance\n");
+	local_debug("late closing the removed device instance");
 	close(priv.fd.drm);
 
 	healthcheck();
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 2/8] tests/core_hotunplug: Use PCI device sysfs entry, not DRM
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Future subtests may want to access PCI attributes of the device after
driver unbind.  Refactor prepare() helper.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/core_hotunplug.c | 68 +++++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 28 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 187168009..c7213d728 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -54,42 +54,54 @@ struct hotunplug {
 	igt_kmsg(KMSG_DEBUG "%s: %s: %s\n", igt_test_name(), __func__, msg); \
 })
 
-static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
+static inline int prepare_common(struct hotunplug *priv)
 {
-	int len;
+	int fd_sysfs_drm;
+
+	local_debug("opening device");
+	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
+	igt_assert(priv->fd.drm >= 0);
+
+	fd_sysfs_drm = igt_sysfs_open(priv->fd.drm);
+	igt_assert(fd_sysfs_drm >= 0);
+
+	return fd_sysfs_drm;
+}
+
+static inline void prepare_for_rebind(struct hotunplug *priv,
+				      char *buf, int buflen)
+{
+	int fd_sysfs_drm, len;
 
 	igt_assert(buflen);
 
-	priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "device/driver",
-				    O_DIRECTORY);
-	igt_assert(priv->fd.sysfs_drv >= 0);
+	fd_sysfs_drm = prepare_common(priv);
+
+	priv->fd.sysfs_drv = openat(fd_sysfs_drm, "device/driver", O_DIRECTORY);
 
-	len = readlinkat(priv->fd.sysfs_dev, "device", buf, buflen - 1);
+	len = readlinkat(fd_sysfs_drm, "device", buf, buflen - 1);
 	buf[len] = '\0';
 	priv->dev_bus_addr = strrchr(buf, '/');
-	igt_assert(priv->dev_bus_addr++);
 
-	/* sysfs_dev no longer needed */
-	close(priv->fd.sysfs_dev);
+	close(fd_sysfs_drm);
+
+	igt_assert(priv->fd.sysfs_drv >= 0);
+	igt_assert(priv->dev_bus_addr++);
 }
 
-static inline void prepare(struct hotunplug *priv, char *buf, int buflen)
+static inline void prepare_for_rescan(struct hotunplug *priv)
 {
-	local_debug("opening device");
-	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
-	igt_assert(priv->fd.drm >= 0);
+	int fd_sysfs_drm = prepare_common(priv);
 
-	priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm);
-	igt_assert(priv->fd.sysfs_dev >= 0);
+	priv->fd.sysfs_dev = openat(fd_sysfs_drm, "device", O_DIRECTORY);
 
-	if (buf) {
-		prepare_for_unbind(priv, buf, buflen);
-	} else {
-		/* prepare for bus rescan */
-		priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev,
-					    "device/subsystem", O_DIRECTORY);
-		igt_assert(priv->fd.sysfs_bus >= 0);
-	}
+	priv->fd.sysfs_bus = openat(fd_sysfs_drm, "device/subsystem",
+				    O_DIRECTORY);
+
+	close(fd_sysfs_drm);
+
+	igt_assert(priv->fd.sysfs_dev >= 0);
+	igt_assert(priv->fd.sysfs_bus >= 0);
 }
 
 static const char *failure;
@@ -123,7 +135,7 @@ static void device_unplug(int fd_sysfs_dev)
 {
 	failure = "Device unplug timeout!";
 	igt_set_timeout(60, failure);
-	igt_sysfs_set(fd_sysfs_dev, "device/remove", "1");
+	igt_sysfs_set(fd_sysfs_dev, "remove", "1");
 	igt_reset_timeout();
 	failure = NULL;
 
@@ -183,7 +195,7 @@ static void unbind_rebind(void)
 	struct hotunplug priv;
 	char buf[PATH_MAX];
 
-	prepare(&priv, buf, sizeof(buf));
+	prepare_for_rebind(&priv, buf, sizeof(buf));
 
 	local_debug("closing the device");
 	close(priv.fd.drm);
@@ -201,7 +213,7 @@ static void unplug_rescan(void)
 {
 	struct hotunplug priv;
 
-	prepare(&priv, NULL, 0);
+	prepare_for_rescan(&priv);
 
 	local_debug("closing the device");
 	close(priv.fd.drm);
@@ -220,7 +232,7 @@ static void hotunbind_lateclose(void)
 	struct hotunplug priv;
 	char buf[PATH_MAX];
 
-	prepare(&priv, buf, sizeof(buf));
+	prepare_for_rebind(&priv, buf, sizeof(buf));
 
 	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
@@ -238,7 +250,7 @@ static void hotunplug_lateclose(void)
 {
 	struct hotunplug priv;
 
-	prepare(&priv, NULL, 0);
+	prepare_for_rescan(&priv);
 
 	local_debug("hot unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 2/8] tests/core_hotunplug: Use PCI device sysfs entry, not DRM
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Future subtests may want to access PCI attributes of the device after
driver unbind.  Refactor prepare() helper.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/core_hotunplug.c | 68 +++++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 28 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 187168009..c7213d728 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -54,42 +54,54 @@ struct hotunplug {
 	igt_kmsg(KMSG_DEBUG "%s: %s: %s\n", igt_test_name(), __func__, msg); \
 })
 
-static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen)
+static inline int prepare_common(struct hotunplug *priv)
 {
-	int len;
+	int fd_sysfs_drm;
+
+	local_debug("opening device");
+	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
+	igt_assert(priv->fd.drm >= 0);
+
+	fd_sysfs_drm = igt_sysfs_open(priv->fd.drm);
+	igt_assert(fd_sysfs_drm >= 0);
+
+	return fd_sysfs_drm;
+}
+
+static inline void prepare_for_rebind(struct hotunplug *priv,
+				      char *buf, int buflen)
+{
+	int fd_sysfs_drm, len;
 
 	igt_assert(buflen);
 
-	priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "device/driver",
-				    O_DIRECTORY);
-	igt_assert(priv->fd.sysfs_drv >= 0);
+	fd_sysfs_drm = prepare_common(priv);
+
+	priv->fd.sysfs_drv = openat(fd_sysfs_drm, "device/driver", O_DIRECTORY);
 
-	len = readlinkat(priv->fd.sysfs_dev, "device", buf, buflen - 1);
+	len = readlinkat(fd_sysfs_drm, "device", buf, buflen - 1);
 	buf[len] = '\0';
 	priv->dev_bus_addr = strrchr(buf, '/');
-	igt_assert(priv->dev_bus_addr++);
 
-	/* sysfs_dev no longer needed */
-	close(priv->fd.sysfs_dev);
+	close(fd_sysfs_drm);
+
+	igt_assert(priv->fd.sysfs_drv >= 0);
+	igt_assert(priv->dev_bus_addr++);
 }
 
-static inline void prepare(struct hotunplug *priv, char *buf, int buflen)
+static inline void prepare_for_rescan(struct hotunplug *priv)
 {
-	local_debug("opening device");
-	priv->fd.drm = __drm_open_driver(DRIVER_ANY);
-	igt_assert(priv->fd.drm >= 0);
+	int fd_sysfs_drm = prepare_common(priv);
 
-	priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm);
-	igt_assert(priv->fd.sysfs_dev >= 0);
+	priv->fd.sysfs_dev = openat(fd_sysfs_drm, "device", O_DIRECTORY);
 
-	if (buf) {
-		prepare_for_unbind(priv, buf, buflen);
-	} else {
-		/* prepare for bus rescan */
-		priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev,
-					    "device/subsystem", O_DIRECTORY);
-		igt_assert(priv->fd.sysfs_bus >= 0);
-	}
+	priv->fd.sysfs_bus = openat(fd_sysfs_drm, "device/subsystem",
+				    O_DIRECTORY);
+
+	close(fd_sysfs_drm);
+
+	igt_assert(priv->fd.sysfs_dev >= 0);
+	igt_assert(priv->fd.sysfs_bus >= 0);
 }
 
 static const char *failure;
@@ -123,7 +135,7 @@ static void device_unplug(int fd_sysfs_dev)
 {
 	failure = "Device unplug timeout!";
 	igt_set_timeout(60, failure);
-	igt_sysfs_set(fd_sysfs_dev, "device/remove", "1");
+	igt_sysfs_set(fd_sysfs_dev, "remove", "1");
 	igt_reset_timeout();
 	failure = NULL;
 
@@ -183,7 +195,7 @@ static void unbind_rebind(void)
 	struct hotunplug priv;
 	char buf[PATH_MAX];
 
-	prepare(&priv, buf, sizeof(buf));
+	prepare_for_rebind(&priv, buf, sizeof(buf));
 
 	local_debug("closing the device");
 	close(priv.fd.drm);
@@ -201,7 +213,7 @@ static void unplug_rescan(void)
 {
 	struct hotunplug priv;
 
-	prepare(&priv, NULL, 0);
+	prepare_for_rescan(&priv);
 
 	local_debug("closing the device");
 	close(priv.fd.drm);
@@ -220,7 +232,7 @@ static void hotunbind_lateclose(void)
 	struct hotunplug priv;
 	char buf[PATH_MAX];
 
-	prepare(&priv, buf, sizeof(buf));
+	prepare_for_rebind(&priv, buf, sizeof(buf));
 
 	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
@@ -238,7 +250,7 @@ static void hotunplug_lateclose(void)
 {
 	struct hotunplug priv;
 
-	prepare(&priv, NULL, 0);
+	prepare_for_rescan(&priv);
 
 	local_debug("hot unplugging the device");
 	device_unplug(priv.fd.sysfs_dev);
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 3/8] tests/core_hotunplug: Add unbind-unplug-rescan variant
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Check if this 3-step procedure exhibits any issues with device recover
after unplug.  Such issues may indicate insufficient device hardware
re-initialization performed by the device driver, or other kernel bugs
outside the driver code.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index c7213d728..0b7c6006b 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -209,6 +209,35 @@ static void unbind_rebind(void)
 	healthcheck();
 }
 
+static void unbind_unplug_rescan(void)
+{
+	struct hotunplug priv;
+	char buf[PATH_MAX];
+
+	/* prepare for unbind */
+	prepare_for_rebind(&priv, buf, sizeof(buf));
+
+	/* also prepare for unplug */
+	local_debug("closing the device");
+	close(priv.fd.drm);
+	prepare_for_rescan(&priv);
+
+	local_debug("closing the device");
+	close(priv.fd.drm);
+
+	local_debug("unbinding the driver from the device");
+	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+	close(priv.fd.sysfs_drv);
+
+	local_debug("unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 static void unplug_rescan(void)
 {
 	struct hotunplug priv;
@@ -288,14 +317,21 @@ igt_main
 		close(fd_drm);
 	}
 
-	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();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if a device believed to be closed can be cleanly unplugged");
+	igt_describe("Check if a device with the driver unbound from it can be cleanly recovered after being unplugged\n");
+	igt_subtest("unbind-unplug-rescan")
+		unbind_unplug_rescan();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device believed to be closed can be cleanly unplugged and recovered");
 	igt_subtest("unplug-rescan")
 		unplug_rescan();
 
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 3/8] tests/core_hotunplug: Add unbind-unplug-rescan variant
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Check if this 3-step procedure exhibits any issues with device recover
after unplug.  Such issues may indicate insufficient device hardware
re-initialization performed by the device driver, or other kernel bugs
outside the driver code.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index c7213d728..0b7c6006b 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -209,6 +209,35 @@ static void unbind_rebind(void)
 	healthcheck();
 }
 
+static void unbind_unplug_rescan(void)
+{
+	struct hotunplug priv;
+	char buf[PATH_MAX];
+
+	/* prepare for unbind */
+	prepare_for_rebind(&priv, buf, sizeof(buf));
+
+	/* also prepare for unplug */
+	local_debug("closing the device");
+	close(priv.fd.drm);
+	prepare_for_rescan(&priv);
+
+	local_debug("closing the device");
+	close(priv.fd.drm);
+
+	local_debug("unbinding the driver from the device");
+	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+	close(priv.fd.sysfs_drv);
+
+	local_debug("unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 static void unplug_rescan(void)
 {
 	struct hotunplug priv;
@@ -288,14 +317,21 @@ igt_main
 		close(fd_drm);
 	}
 
-	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();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if a device believed to be closed can be cleanly unplugged");
+	igt_describe("Check if a device with the driver unbound from it can be cleanly recovered after being unplugged\n");
+	igt_subtest("unbind-unplug-rescan")
+		unbind_unplug_rescan();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device believed to be closed can be cleanly unplugged and recovered");
 	igt_subtest("unplug-rescan")
 		unplug_rescan();
 
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 4/8] tests/core_hotunplug: Add 'lateclose before recover' variants
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

If a GPU gets wedged during driver rebind or device re-plug for some
reason, current hotunbind/hotunplug test variants may time out before
lateclose phase, resulting in incomplete CI reports.  Let's rename
those variants to more adequate hotrebind/hotreplug-lateclose and add
new variants focused on exercising the lateclose phase regardless of
potential rebind/re-plug issues under old names.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/core_hotunplug.c | 57 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 0b7c6006b..f736a991f 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -266,6 +266,43 @@ static void hotunbind_lateclose(void)
 	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
+	local_debug("late closing the unbound device instance");
+	close(priv.fd.drm);
+
+	local_debug("rebinding the driver to the device");
+	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+
+	healthcheck();
+}
+
+static void hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
+static void hotrebind_lateclose(void)
+{
+	struct hotunplug priv;
+	char buf[PATH_MAX];
+
+	prepare_for_rebind(&priv, buf, sizeof(buf));
+
+	local_debug("hot unbinding the driver from the device");
+	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+
 	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
@@ -275,7 +312,7 @@ static void hotunbind_lateclose(void)
 	healthcheck();
 }
 
-static void hotunplug_lateclose(void)
+static void hotreplug_lateclose(void)
 {
 	struct hotunplug priv;
 
@@ -338,17 +375,31 @@ igt_main
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if the driver can be cleanly unbound from a still open device, then released");
+	igt_describe("Check if the driver can be cleanly unbound from a still open device, then released and rebound");
 	igt_subtest("hotunbind-lateclose")
 		hotunbind_lateclose();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if a still open device can be cleanly unplugged, then released");
+	igt_describe("Check if a still open device can be cleanly unplugged, then released and recovered");
 	igt_subtest("hotunplug-lateclose")
 		hotunplug_lateclose();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if the driver can be cleanly unbound from an open device and rebound back, then released");
+	igt_subtest("hotrebind-lateclose")
+		hotrebind_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a still open device can be cleanly unplugged and recovered, then released");
+	igt_subtest("hotreplug-lateclose")
+		hotreplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 4/8] tests/core_hotunplug: Add 'lateclose before recover' variants
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

If a GPU gets wedged during driver rebind or device re-plug for some
reason, current hotunbind/hotunplug test variants may time out before
lateclose phase, resulting in incomplete CI reports.  Let's rename
those variants to more adequate hotrebind/hotreplug-lateclose and add
new variants focused on exercising the lateclose phase regardless of
potential rebind/re-plug issues under old names.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/core_hotunplug.c | 57 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 0b7c6006b..f736a991f 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -266,6 +266,43 @@ static void hotunbind_lateclose(void)
 	local_debug("hot unbinding the driver from the device");
 	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
+	local_debug("late closing the unbound device instance");
+	close(priv.fd.drm);
+
+	local_debug("rebinding the driver to the device");
+	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+
+	healthcheck();
+}
+
+static void hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
+static void hotrebind_lateclose(void)
+{
+	struct hotunplug priv;
+	char buf[PATH_MAX];
+
+	prepare_for_rebind(&priv, buf, sizeof(buf));
+
+	local_debug("hot unbinding the driver from the device");
+	driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr);
+
 	local_debug("rebinding the driver to the device");
 	driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr);
 
@@ -275,7 +312,7 @@ static void hotunbind_lateclose(void)
 	healthcheck();
 }
 
-static void hotunplug_lateclose(void)
+static void hotreplug_lateclose(void)
 {
 	struct hotunplug priv;
 
@@ -338,17 +375,31 @@ igt_main
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if the driver can be cleanly unbound from a still open device, then released");
+	igt_describe("Check if the driver can be cleanly unbound from a still open device, then released and rebound");
 	igt_subtest("hotunbind-lateclose")
 		hotunbind_lateclose();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
 
-	igt_describe("Check if a still open device can be cleanly unplugged, then released");
+	igt_describe("Check if a still open device can be cleanly unplugged, then released and recovered");
 	igt_subtest("hotunplug-lateclose")
 		hotunplug_lateclose();
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if the driver can be cleanly unbound from an open device and rebound back, then released");
+	igt_subtest("hotrebind-lateclose")
+		hotrebind_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a still open device can be cleanly unplugged and recovered, then released");
+	igt_subtest("hotreplug-lateclose")
+		hotreplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 5/8] tests/core_hotunplug: Add 'GEM address space' variant
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Verify if an additional address space associated with an open device
file descriptor is cleaned up correctly on device hotunplug.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index f736a991f..6d9f530b1 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -34,6 +34,8 @@
 #include "igt_kmod.h"
 #include "igt_sysfs.h"
 
+#include "i915/gem_vm.h"
+
 IGT_TEST_DESCRIPTION("Examine behavior of a driver on device hot unplug");
 
 struct hotunplug {
@@ -330,6 +332,29 @@ static void hotreplug_lateclose(void)
 	healthcheck();
 }
 
+static void vm_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	gem_require_vm(priv.fd.drm);
+
+	local_debug("creating additional GEM user address space");
+	igt_ignore_warn(gem_vm_create(priv.fd.drm));
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -402,4 +427,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a still open device with extra GEM address space can be cleanly unplugged, then released and recovered");
+	igt_subtest("vm-hotunplug-lateclose")
+		vm_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 5/8] tests/core_hotunplug: Add 'GEM address space' variant
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Verify if an additional address space associated with an open device
file descriptor is cleaned up correctly on device hotunplug.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index f736a991f..6d9f530b1 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -34,6 +34,8 @@
 #include "igt_kmod.h"
 #include "igt_sysfs.h"
 
+#include "i915/gem_vm.h"
+
 IGT_TEST_DESCRIPTION("Examine behavior of a driver on device hot unplug");
 
 struct hotunplug {
@@ -330,6 +332,29 @@ static void hotreplug_lateclose(void)
 	healthcheck();
 }
 
+static void vm_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	gem_require_vm(priv.fd.drm);
+
+	local_debug("creating additional GEM user address space");
+	igt_ignore_warn(gem_vm_create(priv.fd.drm));
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -402,4 +427,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a still open device with extra GEM address space can be cleanly unplugged, then released and recovered");
+	igt_subtest("vm-hotunplug-lateclose")
+		vm_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 6/8] tests/core_hotunplug: Add 'GEM object' variant
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

GEM objects belonging to user file descriptors still open on device
hotunplug may exhibit still more driver issues.  Add a subtest that
implements this scenario.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 6d9f530b1..309d4efef 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -355,6 +355,29 @@ static void vm_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void gem_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("creating a GEM user object");
+	igt_ignore_warn(gem_create(priv.fd.drm, 4096));
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -434,4 +457,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still open GEM object can be cleanly unplugged, then released and recovered");
+	igt_subtest("gem-hotunplug-lateclose")
+		gem_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 6/8] tests/core_hotunplug: Add 'GEM object' variant
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

GEM objects belonging to user file descriptors still open on device
hotunplug may exhibit still more driver issues.  Add a subtest that
implements this scenario.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 6d9f530b1..309d4efef 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -355,6 +355,29 @@ static void vm_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void gem_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("creating a GEM user object");
+	igt_ignore_warn(gem_create(priv.fd.drm, 4096));
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -434,4 +457,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still open GEM object can be cleanly unplugged, then released and recovered");
+	igt_subtest("gem-hotunplug-lateclose")
+		gem_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 7/8] tests/core_hotunplug: Add 'PRIME handle' variant
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Even if all device file descriptors are closed on device hotunplug,
PRIME exported objects may still exists, referenced by still open
dma-buf file handles.  Add a subtest that keeps such handle open on
device hotunplug.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 309d4efef..35a4fb13c 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -378,6 +378,35 @@ static void gem_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void prime_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+	uint32_t handle;
+	int dmabuf;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("creating and PRIME-exporting a GEM object");
+	handle = gem_create(priv.fd.drm, 4096);
+	dmabuf = prime_handle_to_fd(priv.fd.drm, handle);
+
+	local_debug("closing the device");
+	close(priv.fd.drm);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the PRIME file handle");
+	close(dmabuf);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -464,4 +493,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still open PRIME-exported object can be cleanly unplugged, then released and recovered");
+	igt_subtest("prime-hotunplug-lateclose")
+		prime_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 7/8] tests/core_hotunplug: Add 'PRIME handle' variant
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Even if all device file descriptors are closed on device hotunplug,
PRIME exported objects may still exists, referenced by still open
dma-buf file handles.  Add a subtest that keeps such handle open on
device hotunplug.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 309d4efef..35a4fb13c 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -378,6 +378,35 @@ static void gem_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void prime_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+	uint32_t handle;
+	int dmabuf;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("creating and PRIME-exporting a GEM object");
+	handle = gem_create(priv.fd.drm, 4096);
+	dmabuf = prime_handle_to_fd(priv.fd.drm, handle);
+
+	local_debug("closing the device");
+	close(priv.fd.drm);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the PRIME file handle");
+	close(dmabuf);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -464,4 +493,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still open PRIME-exported object can be cleanly unplugged, then released and recovered");
+	igt_subtest("prime-hotunplug-lateclose")
+		prime_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Intel-gfx] [RFC PATCH i-g-t 8/8] tests/core_hotunplug: Add 'GEM batch' variant
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  -1 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Verify if a device with a GEM batch job still running on a GPU can be
hot-unplugged cleanly and released, then recovered.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 35a4fb13c..c8d7ec7e1 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -31,6 +31,7 @@
 
 #include "igt.h"
 #include "igt_device_scan.h"
+#include "igt_dummyload.h"
 #include "igt_kmod.h"
 #include "igt_sysfs.h"
 
@@ -407,6 +408,32 @@ static void prime_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void batch_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+	igt_spin_t *spin;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("running dummy load");
+	spin = __igt_spin_new(priv.fd.drm, .flags = IGT_SPIN_POLL_RUN |
+						    IGT_SPIN_NO_PREEMPTION);
+	igt_spin_busywait_until_started(spin);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -500,4 +527,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still running batch can be cleanly unplugged, then released and recovered");
+	igt_subtest("batch-hotunplug-lateclose")
+		batch_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] [RFC PATCH i-g-t 8/8] tests/core_hotunplug: Add 'GEM batch' variant
@ 2020-06-22 15:18   ` Janusz Krzysztofik
  0 siblings, 0 replies; 19+ messages in thread
From: Janusz Krzysztofik @ 2020-06-22 15:18 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Verify if a device with a GEM batch job still running on a GPU can be
hot-unplugged cleanly and released, then recovered.

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

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 35a4fb13c..c8d7ec7e1 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -31,6 +31,7 @@
 
 #include "igt.h"
 #include "igt_device_scan.h"
+#include "igt_dummyload.h"
 #include "igt_kmod.h"
 #include "igt_sysfs.h"
 
@@ -407,6 +408,32 @@ static void prime_hotunplug_lateclose(void)
 	healthcheck();
 }
 
+static void batch_hotunplug_lateclose(void)
+{
+	struct hotunplug priv;
+	igt_spin_t *spin;
+
+	prepare_for_rescan(&priv);
+
+	igt_require_gem(priv.fd.drm);
+
+	local_debug("running dummy load");
+	spin = __igt_spin_new(priv.fd.drm, .flags = IGT_SPIN_POLL_RUN |
+						    IGT_SPIN_NO_PREEMPTION);
+	igt_spin_busywait_until_started(spin);
+
+	local_debug("hot unplugging the device");
+	device_unplug(priv.fd.sysfs_dev);
+
+	local_debug("late closing the removed device instance");
+	close(priv.fd.drm);
+
+	local_debug("recovering the device");
+	bus_rescan(priv.fd.sysfs_bus);
+
+	healthcheck();
+}
+
 /* Main */
 
 igt_main
@@ -500,4 +527,11 @@ igt_main
 
 	igt_fixture
 		igt_abort_on_f(failure, "%s\n", failure);
+
+	igt_describe("Check if a device with a still running batch can be cleanly unplugged, then released and recovered");
+	igt_subtest("batch-hotunplug-lateclose")
+		batch_hotunplug_lateclose();
+
+	igt_fixture
+		igt_abort_on_f(failure, "%s\n", failure);
 }
-- 
2.21.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [igt-dev] ✗ Fi.CI.BUILD: failure for tests/core_hotunplug: New subtests and enhancements
  2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
                   ` (8 preceding siblings ...)
  (?)
@ 2020-06-22 15:41 ` Patchwork
  -1 siblings, 0 replies; 19+ messages in thread
From: Patchwork @ 2020-06-22 15:41 UTC (permalink / raw)
  To: Janusz Krzysztofik; +Cc: igt-dev

== Series Details ==

Series: tests/core_hotunplug: New subtests and enhancements
URL   : https://patchwork.freedesktop.org/series/78698/
State : failure

== Summary ==

Applying: tests/core_hotunplug: Duplicate debug messages in dmesg
Applying: tests/core_hotunplug: Use PCI device sysfs entry, not DRM
Applying: tests/core_hotunplug: Add unbind-unplug-rescan variant
Applying: tests/core_hotunplug: Add 'lateclose before recover' variants
Applying: tests/core_hotunplug: Add 'GEM address space' variant
Applying: tests/core_hotunplug: Add 'GEM object' variant
Applying: tests/core_hotunplug: Add 'PRIME handle' variant
Applying: tests/core_hotunplug: Add 'GEM batch' variant
Patch failed at 0008 tests/core_hotunplug: Add 'GEM batch' variant
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".

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-06-22 15:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 15:18 [Intel-gfx] [RFC PATCH i-g-t 0/8] tests/core_hotunplug: New subtests and enhancements Janusz Krzysztofik
2020-06-22 15:18 ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 1/8] tests/core_hotunplug: Duplicate debug messages in dmesg Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 2/8] tests/core_hotunplug: Use PCI device sysfs entry, not DRM Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 3/8] tests/core_hotunplug: Add unbind-unplug-rescan variant Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 4/8] tests/core_hotunplug: Add 'lateclose before recover' variants Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 5/8] tests/core_hotunplug: Add 'GEM address space' variant Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 6/8] tests/core_hotunplug: Add 'GEM object' variant Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 7/8] tests/core_hotunplug: Add 'PRIME handle' variant Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:18 ` [Intel-gfx] [RFC PATCH i-g-t 8/8] tests/core_hotunplug: Add 'GEM batch' variant Janusz Krzysztofik
2020-06-22 15:18   ` [igt-dev] " Janusz Krzysztofik
2020-06-22 15:41 ` [igt-dev] ✗ Fi.CI.BUILD: failure for tests/core_hotunplug: New subtests and enhancements Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.