[igt-dev] [PATCH i-g-t v2] lib: Check if device is not wedged while opening fd

Katarzyna Dec katarzyna.dec at intel.com
Tue Feb 18 12:58:33 UTC 2020


In rare cases it is possible to use wedged device in testing,
what is causing to have false results. Let's abort any fd usage when
GPU is wedged. Use sysfs to check status to make any environment happy.

v2: removed unnecessary file

Signed-off-by: Katarzyna Dec <katarzyna.dec at intel.com>
Cc: Zbigniew Kempczynski <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
---
 lib/drmtest.c    |  1 +
 lib/igt_device.c | 18 ++++++++++++++++++
 lib/igt_device.h |  2 ++
 3 files changed, 21 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 1fc39925..e770462e 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -476,6 +476,7 @@ int drm_open_driver(int chipset)
 		}
 	}
 
+	igt_fail_on_f(igt_device_is_wedged(fd), "Device is wedged.\n");
 	return fd;
 }
 
diff --git a/lib/igt_device.c b/lib/igt_device.c
index 07bb0a0d..6284aff7 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -236,3 +236,21 @@ struct pci_device *igt_device_get_pci_device(int fd)
 
 	return pci_dev;
 }
+
+/**
+ * igt_device_is_wedged:
+ * @fd: device fd
+ *
+ * Return true is device is wedged.
+ */
+bool igt_device_is_wedged(int fd)
+{
+	char buf[2];
+
+	igt_debugfs_read(fd, "i915_wedged", buf);
+
+	if (!strstr(buf, "0"))
+		return true;
+
+	return false;
+}
diff --git a/lib/igt_device.h b/lib/igt_device.h
index 278ba7a9..cb3f9b94 100644
--- a/lib/igt_device.h
+++ b/lib/igt_device.h
@@ -34,4 +34,6 @@ void igt_device_drop_master(int fd);
 int igt_device_get_card_index(int fd);
 struct pci_device *igt_device_get_pci_device(int fd);
 
+bool igt_device_is_wedged(int fd);
+
 #endif /* __IGT_DEVICE_H__ */
-- 
2.20.1



More information about the igt-dev mailing list