[igt-dev] [PATCH i-g-t v3] lib/hang_ctx: Make use of dummyload library to create recursive batch
Antonio Argenziano
antonio.argenziano at intel.com
Tue Jul 10 23:45:26 UTC 2018
An hanging batch is nothing more than a spinning batch that never gets
stopped, so re-use the routines implemented in dummyload.c.
v2:
- Let caller decide spin loop size
- Now builds with meson.
v3:
- Only use loose loops for hangs (Chris)
Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/igt_gt.c | 57 ++++++++-------------------------------------------------
lib/meson.build | 1 +
2 files changed, 9 insertions(+), 49 deletions(-)
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 89b318ae..a363b409 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -40,6 +40,7 @@
#include "ioctl_wrappers.h"
#include "intel_reg.h"
#include "intel_chipset.h"
+#include "igt_dummyload.h"
/**
* SECTION:igt_gt
@@ -271,14 +272,10 @@ igt_hang_t igt_hang_ctx(int fd,
unsigned flags,
uint64_t *offset)
{
- struct drm_i915_gem_relocation_entry reloc;
- struct drm_i915_gem_execbuffer2 execbuf;
- struct drm_i915_gem_exec_object2 exec;
+ igt_spin_t *spinning_batch;
+ struct igt_spin_factory opts = {};
struct drm_i915_gem_context_param param;
- uint32_t b[16];
unsigned ban;
- unsigned len;
- int gen;
igt_require_hang_ring(fd, ring);
@@ -302,52 +299,14 @@ igt_hang_t igt_hang_ctx(int fd,
if ((flags & HANG_ALLOW_BAN) == 0)
context_set_ban(fd, ctx, 0);
- memset(&reloc, 0, sizeof(reloc));
- memset(&exec, 0, sizeof(exec));
- memset(&execbuf, 0, sizeof(execbuf));
-
- exec.handle = gem_create(fd, 4096);
- exec.relocation_count = 1;
- exec.relocs_ptr = to_user_pointer(&reloc);
-
- memset(b, 0xc5, sizeof(b));
-
- len = 0;
- gen = intel_gen(intel_get_drm_devid(fd));
- if (gen >= 8) {
- b[len++] = MI_BATCH_BUFFER_START | 1 << 8 | 1;
- b[len++] = 0;
- b[len++] = 0;
- } else if (gen >= 6) {
- b[len++] = MI_BATCH_BUFFER_START | 1 << 8;
- b[len++] = 0;
- } else {
- b[len++] = MI_BATCH_BUFFER_START | 2 << 6;
- b[len] = 0;
- if (gen < 4) {
- b[len] |= 1;
- reloc.delta = 1;
- }
- len++;
- }
- b[len++] = MI_BATCH_BUFFER_END;
- b[len] = MI_NOOP;
- gem_write(fd, exec.handle, 0, b, sizeof(b));
-
- reloc.offset = sizeof(uint32_t);
- reloc.target_handle = exec.handle;
- reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
-
- execbuf.buffers_ptr = to_user_pointer(&exec);
- execbuf.buffer_count = 1;
- execbuf.flags = ring;
- i915_execbuffer2_set_context_id(execbuf, ctx);
- gem_execbuf(fd, &execbuf);
+ opts.ctx = ctx;
+ opts.engine = ring;
+ spinning_batch = igt_spin_batch_factory(fd, &opts);
if (offset)
- *offset = exec.offset;
+ *offset = spinning_batch->obj[1].offset; /* The batch is the last object */
- return (igt_hang_t){ exec.handle, ctx, ban, flags };
+ return (igt_hang_t){ spinning_batch->obj[1].handle, ctx, ban, flags };
}
/**
diff --git a/lib/meson.build b/lib/meson.build
index 1a355414..868801c2 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -134,6 +134,7 @@ lib_igt_chipset = declare_dependency(link_with : lin_igt_chipset_build,
lib_igt_perf_build = static_library('igt_perf',
['igt_perf.c'],
+ dependencies: [libdrm],
include_directories : inc)
lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build,
--
2.16.2
More information about the igt-dev
mailing list