[igt-dev] [PATCH i-g-t] lib: Check if device is not wedged while opening fd
Katarzyna Dec
katarzyna.dec at intel.com
Tue Feb 18 12:53: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.
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 | 20 ++++++++++++++++++++
lib/igt_device.h | 2 ++
3 files changed, 23 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..e9d2d01e 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -236,3 +236,23 @@ 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 file_name[20] = {0};
+ char buf[2];
+
+ strcat(file_name, "i915_wedged");
+ 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