public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib: Check if device is not wedged while opening fd
@ 2020-02-18 12:53 Katarzyna Dec
  2020-02-18 12:56 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Katarzyna Dec @ 2020-02-18 12:53 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

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@intel.com>
Cc: Zbigniew Kempczynski <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@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

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

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

end of thread, other threads:[~2020-02-18 20:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-18 12:53 [igt-dev] [PATCH i-g-t] lib: Check if device is not wedged while opening fd Katarzyna Dec
2020-02-18 12:56 ` Chris Wilson
2020-02-18 13:35   ` Katarzyna Dec
2020-02-18 12:58 ` [igt-dev] [PATCH i-g-t v2] " Katarzyna Dec
2020-02-18 20:11 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib: Check if device is not wedged while opening fd (rev2) Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox