diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-21 14:13:16 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-23 16:42:36 +0000 |
commit | 305ebcedc36e98f3118ac27a5bbde0ce7cd71a74 (patch) | |
tree | 3e392be546ac6e667b13ad6b494d724ab4822707 /tests/gem_ctx_thrash.c | |
parent | f9b6fd624be9692e9a892c0976fa72cedefc9fed (diff) |
Iterate over physical engines
We current have a single for_each_engine() iterator which we use to
generate both a set of uABI engines and a set of physical engines.
Determining what uABI ring-id corresponds to an actual HW engine is
tricky, so pull that out to a library function and introduce
for_each_physical_engine() for cases where we want to issue requests
once on each HW ring (avoiding aliasing issues).
v2: Remember can_store_dword for gem_sync
v3: Find more open-coded for_each_physical
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests/gem_ctx_thrash.c')
-rw-r--r-- | tests/gem_ctx_thrash.c | 61 |
1 files changed, 6 insertions, 55 deletions
diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c index b5d334f4..2cd9cfeb 100644 --- a/tests/gem_ctx_thrash.c +++ b/tests/gem_ctx_thrash.c @@ -86,33 +86,10 @@ static unsigned get_num_contexts(int fd, int num_engines) return count; } -static int has_engine(int fd, const struct intel_execution_engine *e, uint32_t ctx) -{ - uint32_t bbe = MI_BATCH_BUFFER_END; - struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 exec; - int ret; - - memset(&exec, 0, sizeof(exec)); - exec.handle = gem_create(fd, 4096); - gem_write(fd, exec.handle, 0, &bbe, sizeof(bbe)); - - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = to_user_pointer(&exec); - execbuf.buffer_count = 1; - execbuf.flags = e->exec_id | e->flags; - execbuf.rsvd1 = ctx; - ret = __gem_execbuf(fd, &execbuf); - gem_close(fd, exec.handle); - - return ret; -} - static void single(const char *name, bool all_engines) { struct drm_i915_gem_exec_object2 *obj; struct drm_i915_gem_relocation_entry *reloc; - const struct intel_execution_engine *e; unsigned engines[16]; uint64_t size; uint32_t *ctx, *map, scratch; @@ -130,22 +107,9 @@ static void single(const char *name, bool all_engines) num_engines = 0; if (all_engines) { - for (e = intel_execution_engines; e->name; e++) { - if (e->exec_id == 0) - continue; - - if (has_engine(fd, e, 0)) - continue; - - if (e->exec_id == I915_EXEC_BSD) { - int is_bsd2 = e->flags != 0; - if (gem_has_bsd2(fd) != is_bsd2) - continue; - } - - igt_require(has_engine(fd, e, 1) == -ENOENT); - - engines[num_engines++] = e->exec_id | e->flags; + unsigned engine; + for_each_physical_engine(fd, engine) { + engines[num_engines++] = engine; if (num_engines == ARRAY_SIZE(engines)) break; } @@ -242,8 +206,7 @@ static void single(const char *name, bool all_engines) static void processes(void) { - const struct intel_execution_engine *e; - unsigned engines[16]; + unsigned engines[16], engine; int num_engines; struct rlimit rlim; unsigned num_ctx; @@ -253,20 +216,8 @@ static void processes(void) fd = drm_open_driver(DRIVER_INTEL); num_engines = 0; - for (e = intel_execution_engines; e->name; e++) { - if (e->exec_id == 0) - continue; - - if (has_engine(fd, e, 0)) - continue; - - if (e->exec_id == I915_EXEC_BSD) { - int is_bsd2 = e->flags != 0; - if (gem_has_bsd2(fd) != is_bsd2) - continue; - } - - engines[num_engines++] = e->exec_id | e->flags; + for_each_physical_engine(fd, engine) { + engines[num_engines++] = engine; if (num_engines == ARRAY_SIZE(engines)) break; } |