[igt-dev] [PATCH i-g-t 1/6] lib: Fix gem_measure_ring_inflight
Chris Wilson
chris at chris-wilson.co.uk
Mon Sep 2 04:15:43 UTC 2019
Any use of __for_each_physical_engine breaks library use of
for_each_physical_ring and in this case (e.g. gem_busy/close-race) leads
to GPU hangs.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Andi Shyti <andi.shyti at intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
lib/i915/gem_ring.c | 26 ++++++++++++++++----------
lib/i915/gem_submission.h | 2 ++
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index bf7f439e1..272264659 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -21,12 +21,13 @@
* IN THE SOFTWARE.
*/
-#include "gem_ring.h"
-
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+#include "gem_ring.h"
+#include "gem_submission.h"
+
#include "intel_reg.h"
#include "drmtest.h"
#include "ioctl_wrappers.h"
@@ -140,18 +141,23 @@ __gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags
unsigned int
gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags flags)
{
- if (engine == ALL_ENGINES) {
- unsigned int global_min = ~0u;
+ unsigned int min = ~0u;
+ fd = gem_reopen_driver(fd);
+
+ if (engine == ALL_ENGINES) {
for_each_physical_engine(fd, engine) {
- unsigned int engine_min = __gem_measure_ring_inflight(fd, engine, flags);
+ unsigned int count =
+ __gem_measure_ring_inflight(fd, engine, flags);
- if (engine_min < global_min)
- global_min = engine_min;
+ if (count < min)
+ min = count;
}
-
- return global_min;
+ } else {
+ min = __gem_measure_ring_inflight(fd, engine, flags);
}
- return __gem_measure_ring_inflight(fd, engine, flags);
+ close(fd);
+
+ return min;
}
diff --git a/lib/i915/gem_submission.h b/lib/i915/gem_submission.h
index f94eabb20..1f1d63fe5 100644
--- a/lib/i915/gem_submission.h
+++ b/lib/i915/gem_submission.h
@@ -24,6 +24,8 @@
#ifndef GEM_SUBMISSION_H
#define GEM_SUBMISSION_H
+#include <stdint.h>
+
#define GEM_SUBMISSION_SEMAPHORES (1 << 0)
#define GEM_SUBMISSION_EXECLISTS (1 << 1)
#define GEM_SUBMISSION_GUC (1 << 2)
--
2.23.0
More information about the igt-dev
mailing list