summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-07-26 23:28:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-07-26 23:29:49 +0100
commit5a37420ee5d19be248cc38fced0bf90212a36e74 (patch)
tree90f758fd111b313dd6ea38ca555b6b9f70516e5a
parent6980775bcadec862cd5e5affd65928ef79e5b580 (diff)
i915/gem_exec_balancer: Beware being stuck on a full ring
As we submit a set of semaphores that wait upon us, we have to avoid overfilling the ring. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
-rw-r--r--tests/i915/gem_exec_balancer.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/i915/gem_exec_balancer.c b/tests/i915/gem_exec_balancer.c
index be0be18c0..35a032ccb 100644
--- a/tests/i915/gem_exec_balancer.c
+++ b/tests/i915/gem_exec_balancer.c
@@ -21,7 +21,9 @@
* IN THE SOFTWARE.
*/
+#include <fcntl.h>
#include <sched.h>
+#include <sys/ioctl.h>
#include "i915/gem.h"
#include "i915/gem_ring.h"
@@ -2262,6 +2264,20 @@ static uint32_t sema_create(int i915, uint64_t addr, uint32_t **x)
return handle;
}
+static int __execbuf(int i915, struct drm_i915_gem_execbuffer2 *execbuf)
+{
+ int err;
+
+ err = 0;
+ if (ioctl(i915, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) {
+ err = -errno;
+ igt_assume(err);
+ }
+
+ errno = 0;
+ return err;
+}
+
static uint32_t *sema(int i915, uint32_t ctx)
{
uint32_t *ctl;
@@ -2279,8 +2295,9 @@ static uint32_t *sema(int i915, uint32_t ctx)
for (int n = 1; n <= 32; n++) {
int64_t poll = 1;
- execbuf.batch_start_offset = 64 * n,
- gem_execbuf(i915, &execbuf);
+ execbuf.batch_start_offset = 64 * n;
+ if (__execbuf(i915, &execbuf))
+ break;
/* Force a breadcrumb to be installed on each request */
gem_wait(i915, batch.handle, &poll);
@@ -2323,6 +2340,12 @@ static void __waits(int i915, int timeout, uint32_t ctx, unsigned int count)
static void waits(int i915, int timeout)
{
+ bool nonblock;
+
+ nonblock = fcntl(i915, F_GETFL) & O_NONBLOCK;
+ if (!nonblock)
+ fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) | O_NONBLOCK);
+
for (int class = 0; class < 32; class++) {
struct i915_engine_class_instance *ci;
unsigned int count;
@@ -2342,6 +2365,9 @@ static void waits(int i915, int timeout)
free(ci);
}
+ if (!nonblock)
+ fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) & ~O_NONBLOCK);
+
gem_quiescent_gpu(i915);
}