diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-12-30 11:02:42 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-12-30 14:24:40 +0000 |
commit | 1384f8df232ae5232bf2db2de8cbd6f69b25236b (patch) | |
tree | c7878fe5ffd6bebb5cfe9ce7e288a353a4f7675a | |
parent | 3714a967f69f7c7d6ec32e7b09f64ceb0a11bec1 (diff) |
i915: Rename legacy for_each_engine to for_each_ring
Improve the differentiation between the legacy ring selector ABI and the
more recent engine selection API.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Andi Shyti <andi.shyti@intel.com>
28 files changed, 190 insertions, 188 deletions
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c index 456b1f4b..9e57df3a 100644 --- a/benchmarks/gem_syslatency.c +++ b/benchmarks/gem_syslatency.c @@ -44,6 +44,8 @@ #include <linux/unistd.h> +#include "i915/gem_ring.h" + #define sigev_notify_thread_id _sigev_un._tid static volatile int done; @@ -88,7 +90,7 @@ static void *gem_busyspin(void *arg) fd = drm_open_driver(DRIVER_INTEL); nengine = 0; - for_each_physical_engine(e, fd) + for_each_physical_ring(e, fd) engines[nengine++] = eb_ring(e); memset(obj, 0, sizeof(obj)); diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c index a57bf4c5..f224e822 100644 --- a/lib/i915/gem_ring.c +++ b/lib/i915/gem_ring.c @@ -154,7 +154,7 @@ gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags f fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_NONBLOCK); if (engine == ALL_ENGINES) { - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { unsigned int count = __gem_measure_ring_inflight(fd, eb_ring(e), flags); @@ -169,3 +169,37 @@ gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags f return min; } + +bool gem_ring_is_physical_engine(int fd, unsigned ring) +{ + if (ring == I915_EXEC_DEFAULT) + return false; + + /* BSD uses an extra flag to chose between aliasing modes */ + if ((ring & 63) == I915_EXEC_BSD) { + bool explicit_bsd = ring & (3 << 13); + bool has_bsd2 = gem_has_bsd2(fd); + return explicit_bsd ? has_bsd2 : !has_bsd2; + } + + return true; +} + +bool gem_ring_has_physical_engine(int fd, unsigned ring) +{ + if (!gem_ring_is_physical_engine(fd, ring)) + return false; + + return gem_has_ring(fd, ring); +} + +const struct intel_execution_ring intel_execution_rings[] = { + { "default", NULL, 0, 0 }, + { "render", "rcs0", I915_EXEC_RENDER, 0 }, + { "bsd", "vcs0", I915_EXEC_BSD, 0 }, + { "bsd1", "vcs0", I915_EXEC_BSD, 1<<13 /*I915_EXEC_BSD_RING1*/ }, + { "bsd2", "vcs1", I915_EXEC_BSD, 2<<13 /*I915_EXEC_BSD_RING2*/ }, + { "blt", "bcs0", I915_EXEC_BLT, 0 }, + { "vebox", "vecs0", I915_EXEC_VEBOX, 0 }, + { NULL, 0, 0 } +}; diff --git a/lib/i915/gem_ring.h b/lib/i915/gem_ring.h index c69adce0..d2a0c2f4 100644 --- a/lib/i915/gem_ring.h +++ b/lib/i915/gem_ring.h @@ -26,6 +26,30 @@ #include <stdbool.h> +extern const struct intel_execution_ring { + const char *name; + const char *full_name; + unsigned exec_id; + unsigned flags; +} intel_execution_rings[]; + +#define eb_ring(e) ((e)->exec_id | (e)->flags) + +#define for_each_ring(it__, fd__) \ + for (const struct intel_execution_ring *it__ = intel_execution_rings;\ + it__->name; \ + it__++) \ + for_if (gem_has_ring(fd__, eb_ring(it__))) + +#define for_each_physical_ring(it__, fd__) \ + for (const struct intel_execution_ring *it__ = intel_execution_rings;\ + it__->name; \ + it__++) \ + for_if (gem_ring_has_physical_engine(fd__, eb_ring(it__))) + +bool gem_ring_is_physical_engine(int fd, unsigned int ring); +bool gem_ring_has_physical_engine(int fd, unsigned int ring); + enum measure_ring_flags { MEASURE_RING_NEW_CTX = 1 }; diff --git a/lib/igt_core.h b/lib/igt_core.h index 5d835260..20667387 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -1387,4 +1387,6 @@ void igt_kmsg(const char *format, ...); #define USEC_PER_SEC (1000*MSEC_PER_SEC) #define NSEC_PER_SEC (1000*USEC_PER_SEC) +#define for_if(expr__) if (!(expr__)) {} else + #endif /* IGT_CORE_H */ diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 453446da..7dfcac03 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -549,17 +549,6 @@ unsigned intel_detect_and_clear_missed_interrupts(int fd) return missed; } -const struct intel_execution_engine intel_execution_engines[] = { - { "default", NULL, 0, 0 }, - { "render", "rcs0", I915_EXEC_RENDER, 0 }, - { "bsd", "vcs0", I915_EXEC_BSD, 0 }, - { "bsd1", "vcs0", I915_EXEC_BSD, 1<<13 /*I915_EXEC_BSD_RING1*/ }, - { "bsd2", "vcs1", I915_EXEC_BSD, 2<<13 /*I915_EXEC_BSD_RING2*/ }, - { "blt", "bcs0", I915_EXEC_BLT, 0 }, - { "vebox", "vecs0", I915_EXEC_VEBOX, 0 }, - { NULL, 0, 0 } -}; - bool gem_class_can_store_dword(int fd, int class) { uint16_t devid = intel_get_drm_devid(fd); @@ -616,26 +605,3 @@ int gem_execbuf_flags_to_engine_class(unsigned int flags) igt_assert(0); } } - -bool gem_ring_is_physical_engine(int fd, unsigned ring) -{ - if (ring == I915_EXEC_DEFAULT) - return false; - - /* BSD uses an extra flag to chose between aliasing modes */ - if ((ring & 63) == I915_EXEC_BSD) { - bool explicit_bsd = ring & (3 << 13); - bool has_bsd2 = gem_has_bsd2(fd); - return explicit_bsd ? has_bsd2 : !has_bsd2; - } - - return true; -} - -bool gem_ring_has_physical_engine(int fd, unsigned ring) -{ - if (!gem_ring_is_physical_engine(fd, ring)) - return false; - - return gem_has_ring(fd, ring); -} diff --git a/lib/igt_gt.h b/lib/igt_gt.h index e880cd4e..2ea360cc 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -65,32 +65,6 @@ unsigned intel_detect_and_clear_missed_interrupts(int fd); #define ALL_ENGINES ~0u /* Use in interfaces to iterate all engines */ -extern const struct intel_execution_engine { - const char *name; - const char *full_name; - unsigned exec_id; - unsigned flags; -} intel_execution_engines[]; - -#define eb_ring(e) ((e)->exec_id | (e)->flags) - -#define for_if(expr__) if (!(expr__)) {} else - -#define for_each_engine(it__, fd__) \ - for (const struct intel_execution_engine *it__ = intel_execution_engines;\ - it__->name; \ - it__++) \ - for_if (gem_has_ring(fd__, eb_ring(it__))) - -#define for_each_physical_engine(it__, fd__) \ - for (const struct intel_execution_engine *it__ = intel_execution_engines;\ - it__->name; \ - it__++) \ - for_if (gem_ring_has_physical_engine(fd__, eb_ring(it__))) - -bool gem_ring_is_physical_engine(int fd, unsigned int ring); -bool gem_ring_has_physical_engine(int fd, unsigned int ring); - bool gem_can_store_dword(int fd, unsigned int engine); bool gem_class_can_store_dword(int fd, int class); diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c index 0242dc77..dbeb2577 100644 --- a/tests/amdgpu/amd_prime.c +++ b/tests/amdgpu/amd_prime.c @@ -27,6 +27,7 @@ #include <sys/poll.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_vgem.h" @@ -180,7 +181,7 @@ static void i915_to_amd(int i915, int amd, amdgpu_device_handle device) struct cork c; nengine = 0; - for_each_physical_engine(e, i915) + for_each_physical_ring(e, i915) engines[nengine++] = eb_ring(e); igt_require(nengine); diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c index da850a10..08bfc9fd 100644 --- a/tests/i915/gem_concurrent_all.c +++ b/tests/i915/gem_concurrent_all.c @@ -49,6 +49,7 @@ #include <drm.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_vgem.h" @@ -966,7 +967,7 @@ static igt_hang_t all_hang(void) { igt_hang_t hang = igt_hang_ring(fd, I915_EXEC_RENDER); - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { struct drm_i915_gem_execbuffer2 eb = hang.spin->execbuf; eb.flags = eb_ring(e); diff --git a/tests/i915/gem_cs_prefetch.c b/tests/i915/gem_cs_prefetch.c index f329ba7e..4830f62b 100644 --- a/tests/i915/gem_cs_prefetch.c +++ b/tests/i915/gem_cs_prefetch.c @@ -36,6 +36,7 @@ * very last gtt pte. */ #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" IGT_TEST_DESCRIPTION("Test the CS prefetch behaviour on batches."); @@ -140,9 +141,9 @@ static void test_ring(unsigned ring) igt_main { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; - for (e = intel_execution_engines; e->name; e++) + for (e = intel_execution_rings; e->name; e++) igt_subtest_f("%s", e->name) test_ring(eb_ring(e)); } diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c index f65a8a7a..1b7d1852 100644 --- a/tests/i915/gem_ctx_persistence.c +++ b/tests/i915/gem_ctx_persistence.c @@ -370,7 +370,7 @@ static void test_nohangcheck_hostile(int i915) igt_require(__enable_hangcheck(dir, false)); - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { int64_t timeout = reset_timeout_ms * NSEC_PER_MSEC; uint32_t ctx = gem_context_create(i915); igt_spin_t *spin; @@ -407,7 +407,7 @@ static void test_nohangcheck_hang(int i915) igt_require(__enable_hangcheck(dir, false)); - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { int64_t timeout = reset_timeout_ms * NSEC_PER_MSEC; uint32_t ctx = gem_context_create(i915); igt_spin_t *spin; @@ -475,7 +475,7 @@ static void test_noheartbeat_many(int i915, int count, unsigned int flags) * cleaned up. */ - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { igt_spin_t *spin[count]; if (!set_preempt_timeout(i915, e->full_name, 250)) @@ -529,7 +529,7 @@ static void test_noheartbeat_close(int i915, unsigned int flags) * heartbeat has already been disabled. */ - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { igt_spin_t *spin; uint32_t ctx; int err; @@ -1357,7 +1357,7 @@ igt_main for (test = tests; test->name; test++) { igt_subtest_with_dynamic_f("legacy-engines-%s", test->name) { - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { igt_dynamic_f("%s", e->name) { do_test(test->func, i915, eb_ring(e), diff --git a/tests/i915/gem_ctx_switch.c b/tests/i915/gem_ctx_switch.c index 874dc5ae..6208dacd 100644 --- a/tests/i915/gem_ctx_switch.c +++ b/tests/i915/gem_ctx_switch.c @@ -41,6 +41,7 @@ #include "drm.h" #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #define INTERRUPTIBLE 0x1 @@ -305,7 +306,7 @@ igt_main { const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); const struct intel_execution_engine2 *e2; - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; static const struct { const char *name; unsigned int flags; @@ -338,7 +339,7 @@ igt_main } /* Legacy testing must be first. */ - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { struct intel_execution_engine2 e2__; e2__ = gem_eb_flags_to_engine(eb_ring(e)); diff --git a/tests/i915/gem_ctx_thrash.c b/tests/i915/gem_ctx_thrash.c index 142bb65f..5478ebf4 100644 --- a/tests/i915/gem_ctx_thrash.c +++ b/tests/i915/gem_ctx_thrash.c @@ -31,6 +31,7 @@ #include <sys/resource.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_sysfs.h" @@ -105,7 +106,7 @@ static void single(const char *name, bool all_engines) num_engines = 0; if (all_engines) { - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { if (!gem_can_store_dword(fd, eb_ring(e))) continue; @@ -230,7 +231,7 @@ static void processes(void) fd = drm_open_driver(DRIVER_INTEL); num_engines = 0; - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { engines[num_engines++] = eb_ring(e); if (num_engines == ARRAY_SIZE(engines)) break; diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c index ae53227c..19c623c2 100644 --- a/tests/i915/gem_eio.c +++ b/tests/i915/gem_eio.c @@ -446,7 +446,7 @@ static void test_inflight(int fd, unsigned int wait) max = min(max - 1, ARRAY_SIZE(fence)); igt_debug("Using %d inflight batches\n", max); - for_each_engine(e, parent_fd) { + for_each_ring(e, parent_fd) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_exec_object2 obj[2]; struct drm_i915_gem_execbuffer2 execbuf; @@ -575,7 +575,7 @@ static void test_inflight_contexts(int fd, unsigned int wait) igt_require(gem_has_exec_fence(fd)); gem_require_contexts(fd); - for_each_engine(e, parent_fd) { + for_each_ring(e, parent_fd) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_exec_object2 obj[2]; struct drm_i915_gem_execbuffer2 execbuf; @@ -718,7 +718,7 @@ static void test_inflight_internal(int fd, unsigned int wait) memset(&execbuf, 0, sizeof(execbuf)); execbuf.buffers_ptr = to_user_pointer(obj); execbuf.buffer_count = 2; - for_each_engine(e, fd) { + for_each_ring(e, fd) { execbuf.flags = eb_ring(e) | I915_EXEC_FENCE_OUT; gem_execbuf_wr(fd, &execbuf); @@ -829,7 +829,7 @@ static void test_reset_stress(int fd, unsigned int flags) { uint32_t ctx0 = context_create_safe(fd); - for_each_engine(e, fd) + for_each_ring(e, fd) reset_stress(fd, ctx0, e->name, eb_ring(e), flags); gem_context_destroy(fd, ctx0); diff --git a/tests/i915/gem_exec_create.c b/tests/i915/gem_exec_create.c index 4d5baec5..6529da7e 100644 --- a/tests/i915/gem_exec_create.c +++ b/tests/i915/gem_exec_create.c @@ -40,6 +40,7 @@ #include "drm.h" #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #define ENGINE_FLAGS (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK) @@ -69,7 +70,7 @@ static void all(int fd, unsigned flags, int timeout, int ncpus) /* Note: modifies engine map on context 0 */ } else { - for_each_physical_engine(e, fd) + for_each_physical_ring(e, fd) engines[nengine++] = eb_ring(e); } igt_require(nengine); diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c index af08c385..a149b022 100644 --- a/tests/i915/gem_exec_fence.c +++ b/tests/i915/gem_exec_fence.c @@ -932,7 +932,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) limit = ring_size / 3; nengine = 0; - for_each_physical_engine(e, fd) + for_each_physical_ring(e, fd) engines[nengine++] = eb_ring(e); igt_require(nengine); @@ -1298,7 +1298,7 @@ static void test_syncobj_wait(int fd) gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); n = 0; - for_each_engine(e, fd) { + for_each_ring(e, fd) { obj.handle = gem_create(fd, 4096); gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); @@ -2058,7 +2058,7 @@ static void test_syncobj_timeline_wait(int fd) gem_write(fd, obj.handle, 0, bbe, sizeof(bbe)); n = 0; - for_each_engine(engine, fd) { + for_each_ring(engine, fd) { obj.handle = gem_create(fd, 4096); gem_write(fd, obj.handle, 0, bbe, sizeof(bbe)); diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c index 403e498b..a2cac71a 100644 --- a/tests/i915/gem_exec_flush.c +++ b/tests/i915/gem_exec_flush.c @@ -24,6 +24,7 @@ #include <time.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_x86.h" @@ -555,7 +556,7 @@ static const char *yesno(bool x) igt_main { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); const struct batch { const char *name; @@ -602,7 +603,7 @@ igt_main igt_fork_hang_detector(fd); } - for (e = intel_execution_engines; e->name; e++) igt_subtest_group { + for (e = intel_execution_rings; e->name; e++) igt_subtest_group { unsigned ring = eb_ring(e); unsigned timeout = 5 + 120*!!e->exec_id; diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c index 6c5a4bc6..48a4db46 100644 --- a/tests/i915/gem_exec_latency.c +++ b/tests/i915/gem_exec_latency.c @@ -313,7 +313,7 @@ static void latency_from_ring(int fd, reloc.presumed_offset = obj[1].offset; reloc.target_handle = flags & CORK ? 1 : 0; - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { igt_spin_t *spin = NULL; IGT_CORK_HANDLE(c); @@ -475,7 +475,7 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in nengine = 0; if (engine == ALL_ENGINES) { - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { if (!gem_can_store_dword(fd, eb_ring(e))) continue; @@ -652,7 +652,7 @@ static double clockrate(int i915, int reg) igt_main { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; int device = -1; igt_fixture { @@ -686,7 +686,7 @@ igt_main igt_fixture igt_require(intel_gen(intel_get_drm_devid(device)) >= 7); - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { if (e->exec_id == 0) continue; diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c index e679c512..40b98184 100644 --- a/tests/i915/gem_exec_params.c +++ b/tests/i915/gem_exec_params.c @@ -39,6 +39,7 @@ #include "drm.h" #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_device.h" #include "sw_sync.h" @@ -337,7 +338,7 @@ static void test_larger_than_life_batch(int fd) igt_require(size < gem_aperture_size(fd)); intel_require_memory(2, size, CHECK_RAM); /* batch + shadow */ - for_each_engine(e, fd) { + for_each_ring(e, fd) { /* Keep the batch_len implicit [0] */ execbuf.flags = eb_ring(e); @@ -361,7 +362,7 @@ int fd; igt_main { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; igt_fixture { fd = drm_open_driver(DRIVER_INTEL); @@ -395,7 +396,7 @@ igt_main } igt_subtest("control") { - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { if (has_ring(fd, eb_ring(e))) { execbuf.flags = eb_ring(e); gem_execbuf(fd, &execbuf); @@ -564,7 +565,7 @@ igt_main igt_subtest("rs-invalid") { bool has_rs = has_resource_streamer(fd); - for_each_engine(it, fd) { + for_each_ring(it, fd) { int expect = -EINVAL; if (has_rs && (eb_ring(it) == 0 || diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c index 8c5661db..42b0ab70 100644 --- a/tests/i915/gem_exec_suspend.c +++ b/tests/i915/gem_exec_suspend.c @@ -31,6 +31,7 @@ #include <unistd.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_dummyload.h" #include "igt_gt.h" @@ -67,7 +68,7 @@ static void check_bo(int fd, uint32_t handle) static void test_all(int fd, unsigned flags) { - for_each_physical_engine(e, fd) + for_each_physical_ring(e, fd) if (gem_can_store_dword(fd, eb_ring(e))) run_test(fd, eb_ring(e), flags & ~0xff); } @@ -107,7 +108,7 @@ static void run_test(int fd, unsigned engine, unsigned flags) * GPU is then unlikely to be active!) */ if (has_semaphores(fd)) { - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { if (gem_can_store_dword(fd, eb_ring(e))) engines[nengine++] = eb_ring(e); } @@ -300,7 +301,7 @@ igt_main { "-S4", HIBERNATE }, { NULL, 0 } }, *m; - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; igt_hang_t hang; int fd; @@ -325,7 +326,7 @@ igt_main igt_subtest("basic-S4") run_test(fd, ALL_ENGINES, HIBERNATE); - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { for (m = modes; m->suffix; m++) { igt_subtest_f("%s-uncached%s", e->name, m->suffix) run_test(fd, eb_ring(e), m->mode | UNCACHED); diff --git a/tests/i915/gem_exec_whisper.c b/tests/i915/gem_exec_whisper.c index 29d6c6d2..263db570 100644 --- a/tests/i915/gem_exec_whisper.c +++ b/tests/i915/gem_exec_whisper.c @@ -28,6 +28,7 @@ */ #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_debugfs.h" #include "igt_rapl.h" @@ -202,7 +203,7 @@ static void whisper(int fd, unsigned engine, unsigned flags) nengine = 0; if (engine == ALL_ENGINES) { - for_each_physical_engine(e, fd) { + for_each_physical_ring(e, fd) { if (gem_can_store_dword(fd, eb_ring(e))) engines[nengine++] = eb_ring(e); } @@ -572,7 +573,7 @@ igt_main whisper(fd, ALL_ENGINES, m->flags | ALL); } - for (const struct intel_execution_engine *e = intel_execution_engines; + for (const struct intel_execution_ring *e = intel_execution_rings; e->name; e++) { for (const struct mode *m = modes; m->name; m++) { if (m->flags & CHAIN) diff --git a/tests/i915/gem_reset_stats.c b/tests/i915/gem_reset_stats.c index d55b8586..e1feecb6 100644 --- a/tests/i915/gem_reset_stats.c +++ b/tests/i915/gem_reset_stats.c @@ -41,6 +41,7 @@ #include <signal.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_sysfs.h" @@ -72,7 +73,7 @@ static void sync_gpu(void) gem_quiescent_gpu(device); } -static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e) +static int noop(int fd, uint32_t ctx, const struct intel_execution_ring *e) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 eb; @@ -101,7 +102,7 @@ static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e) static int has_engine(int fd, uint32_t ctx, - const struct intel_execution_engine *e) + const struct intel_execution_ring *e) { int handle = noop(fd, ctx, e); if (handle < 0) @@ -110,7 +111,7 @@ static int has_engine(int fd, return 1; } -static void check_context(const struct intel_execution_engine *e) +static void check_context(const struct intel_execution_ring *e) { gem_require_contexts(device); igt_require(has_engine(device, gem_context_create(device), e)); @@ -152,7 +153,7 @@ static struct timespec ts_injected; #define BAN HANG_ALLOW_BAN #define ASYNC 2 static void inject_hang(int fd, uint32_t ctx, - const struct intel_execution_engine *e, + const struct intel_execution_ring *e, unsigned flags) { igt_hang_t hang; @@ -202,7 +203,7 @@ static int _assert_reset_status(int idx, int fd, int ctx, int status) #define assert_reset_status(idx, fd, ctx, status) \ igt_assert(_assert_reset_status(idx, fd, ctx, status) == 0) -static void test_rs(const struct intel_execution_engine *e, +static void test_rs(const struct intel_execution_ring *e, int num_fds, int hang_index, int rs_assumed_no_hang) { int fd[MAX_FD]; @@ -248,7 +249,7 @@ static void test_rs(const struct intel_execution_engine *e, } #define MAX_CTX 100 -static void test_rs_ctx(const struct intel_execution_engine *e, +static void test_rs_ctx(const struct intel_execution_ring *e, int num_fds, int num_ctx, int hang_index, int hang_context) { @@ -324,7 +325,7 @@ static void test_rs_ctx(const struct intel_execution_engine *e, } } -static void test_ban(const struct intel_execution_engine *e) +static void test_ban(const struct intel_execution_ring *e) { struct local_drm_i915_reset_stats rs_bad, rs_good; int fd_bad, fd_good; @@ -378,7 +379,7 @@ static void test_ban(const struct intel_execution_engine *e) close(fd_good); } -static void test_ban_ctx(const struct intel_execution_engine *e) +static void test_ban_ctx(const struct intel_execution_ring *e) { struct local_drm_i915_reset_stats rs_bad, rs_good; int fd, ban, retry = 10; @@ -436,7 +437,7 @@ static void test_ban_ctx(const struct intel_execution_engine *e) close(fd); } -static void test_unrelated_ctx(const struct intel_execution_engine *e) +static void test_unrelated_ctx(const struct intel_execution_ring *e) { int fd1,fd2; int ctx_guilty, ctx_unrelated; @@ -475,7 +476,7 @@ static int get_reset_count(int fd, int ctx) return rs.reset_count; } -static void test_close_pending_ctx(const struct intel_execution_engine *e) +static void test_close_pending_ctx(const struct intel_execution_ring *e) { int fd = gem_reopen_driver(device); uint32_t ctx = gem_context_create(fd); @@ -489,7 +490,7 @@ static void test_close_pending_ctx(const struct intel_execution_engine *e) close(fd); } -static void test_close_pending(const struct intel_execution_engine *e) +static void test_close_pending(const struct intel_execution_ring *e) { int fd = gem_reopen_driver(device); @@ -504,7 +505,7 @@ static void noop_on_each_ring(int fd, const bool reverse) const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 eb; struct drm_i915_gem_exec_object2 obj; - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; memset(&obj, 0, sizeof(obj)); obj.handle = gem_create(fd, 4096); @@ -515,14 +516,14 @@ static void noop_on_each_ring(int fd, const bool reverse) eb.buffer_count = 1; if (reverse) { - for (e = intel_execution_engines; e->name; e++) + for (e = intel_execution_rings; e->name; e++) ; - while (--e >= intel_execution_engines) { + while (--e >= intel_execution_rings) { eb.flags = eb_ring(e); __gem_execbuf(fd, &eb); } } else { - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { eb.flags = eb_ring(e); __gem_execbuf(fd, &eb); } @@ -532,7 +533,7 @@ static void noop_on_each_ring(int fd, const bool reverse) gem_close(fd, obj.handle); } -static void test_close_pending_fork(const struct intel_execution_engine *e, +static void test_close_pending_fork(const struct intel_execution_ring *e, const bool reverse) { int fd = gem_reopen_driver(device); @@ -574,7 +575,7 @@ static void test_close_pending_fork(const struct intel_execution_engine *e, close(fd); } -static void test_reset_count(const struct intel_execution_engine *e, +static void test_reset_count(const struct intel_execution_ring *e, const bool create_ctx) { int fd = gem_reopen_driver(device); @@ -694,13 +695,13 @@ static void test_params(void) close(fd); } -static const struct intel_execution_engine * -next_engine(int fd, const struct intel_execution_engine *e) +static const struct intel_execution_ring * +next_engine(int fd, const struct intel_execution_ring *e) { do { e++; if (e->name == NULL) - e = intel_execution_engines; + e = intel_execution_rings; if (e->exec_id == 0) e++; } while (!has_engine(fd, 0, e)); @@ -708,9 +709,9 @@ next_engine(int fd, const struct intel_execution_engine *e) return e; } -static void defer_hangcheck(const struct intel_execution_engine *engine) +static void defer_hangcheck(const struct intel_execution_ring *engine) { - const struct intel_execution_engine *next; + const struct intel_execution_ring *next; int fd, count_start, count_end; int seconds = 30; @@ -767,7 +768,7 @@ static bool gem_has_reset_stats(int fd) igt_main { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; igt_fixture { bool has_reset_stats; @@ -795,7 +796,7 @@ igt_main igt_subtest_f("params-ctx") RUN_TEST(test_params_ctx()); - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { igt_subtest_f("reset-stats-%s", e->name) RUN_TEST(test_rs(e, 4, 1, 0)); diff --git a/tests/i915/gem_ringfill.c b/tests/i915/gem_ringfill.c index c499cb0d..78903707 100644 --- a/tests/i915/gem_ringfill.c +++ b/tests/i915/gem_ringfill.c @@ -309,11 +309,11 @@ igt_main /* Legacy path for selecting "rings". */ for (m = modes; m->suffix; m++) { igt_subtest_with_dynamic_f("legacy-%s", m->suffix) { - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; igt_skip_on(m->flags & NEWFD && master); - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { if (!gem_has_ring(fd, eb_ring(e))) continue; diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c index f1a4ee91..c14c89ae 100644 --- a/tests/i915/gem_shrink.c +++ b/tests/i915/gem_shrink.c @@ -28,6 +28,7 @@ */ #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_gt.h" #include "igt_debugfs.h" @@ -450,7 +451,7 @@ igt_main CHECK_SWAP | CHECK_RAM); nengine = 0; - for_each_engine(e, fd) + for_each_ring(e, fd) engines[nengine++] = eb_ring(e); igt_require(nengine); diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c index 19bc4638..adb95e8d 100644 --- a/tests/i915/gem_spin_batch.c +++ b/tests/i915/gem_spin_batch.c @@ -23,6 +23,7 @@ */ #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #define MAX_ERROR 5 /* % */ @@ -144,7 +145,7 @@ static void spin_all(int i915, unsigned int flags) struct igt_spin *spin, *n; IGT_LIST_HEAD(list); - for_each_physical_engine(e, i915) { + for_each_physical_ring(e, i915) { uint32_t ctx; ctx = 0; @@ -173,7 +174,7 @@ static void spin_all(int i915, unsigned int flags) igt_main { const struct intel_execution_engine2 *e2; - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; struct intel_execution_engine2 e2__; int fd = -1; @@ -183,7 +184,7 @@ igt_main igt_fork_hang_detector(fd); } - for (e = intel_execution_engines; e->name; e++) { + for (e = intel_execution_rings; e->name; e++) { e2__ = gem_eb_flags_to_engine(eb_ring(e)); if (e2__.flags == -1) continue; diff --git a/tests/i915/gem_sync.c b/tests/i915/gem_sync.c index a82bda92..6ad31517 100644 --- a/tests/i915/gem_sync.c +++ b/tests/i915/gem_sync.c @@ -25,6 +25,7 @@ #include <pthread.h> #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt_debugfs.h" #include "igt_dummyload.h" #include "igt_gt.h" @@ -1185,7 +1186,7 @@ igt_main /* Legacy for selecting rings. */ for_each_test(t, individual) { igt_subtest_with_dynamic_f("%s", t->name) { - for (const struct intel_execution_engine *l = intel_execution_engines; l->name; l++) { + for (const struct intel_execution_ring *l = intel_execution_rings; l->name; l++) { igt_dynamic_f("%s", l->name) { t->func(fd, eb_ring(l), t->num_children, t->timeout); diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c index 5e6973be..33b60300 100644 --- a/tests/i915/gem_userptr_blits.c +++ b/tests/i915/gem_userptr_blits.c @@ -61,6 +61,7 @@ #include "i915_drm.h" #include "i915/gem.h" +#include "i915/gem_ring.h" #include "igt.h" #include "igt_sysfs.h" #include "sw_sync.h" @@ -1522,7 +1523,7 @@ static void test_readonly(int i915) gem_userptr(i915, space, total, true, userptr_flags, &rhandle); - for_each_engine(e, i915) { + for_each_ring(e, i915) { char *ref, *result; /* First tweak the backing store through the write */ diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c index 7767eb2b..e4cb0d4d 100644 --- a/tests/i915/i915_module_load.c +++ b/tests/i915/i915_module_load.c @@ -20,6 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ +#include "i915/gem_ring.h" #include "igt.h" #include "igt_debugfs.h" #include "igt_aux.h" @@ -148,7 +149,7 @@ static void store_all(int fd) nengine = 0; intel_detect_and_clear_missed_interrupts(fd); - for_each_engine(e, fd) { + for_each_ring(e, fd) { if (!gem_can_store_dword(fd, eb_ring(e))) continue; @@ -278,12 +279,12 @@ static void gem_exec_store(void) { int fd; - const struct intel_execution_engine *e; + const struct intel_execution_ring *e; fd = __drm_open_driver(DRIVER_INTEL); igt_fork_hang_detector(fd); - for (e = intel_execution_engines; e->name; e++) + for (e = intel_execution_rings; e->name; e++) store_dword(fd, eb_ring(e)); store_all(fd); diff --git a/tests/kms_busy.c b/tests/kms_busy.c index 9e483f80..df1f8e11 100644 --- a/tests/kms_busy.c +++ b/tests/kms_busy.c @@ -70,7 +70,7 @@ static void do_cleanup_display(igt_display_t *dpy) static void flip_to_fb(igt_display_t *dpy, int pipe, igt_output_t *output, - struct igt_fb *fb, unsigned ring, int timeout, + struct igt_fb *fb, int timeout, const char *name, bool modeset) { struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN }; @@ -81,7 +81,6 @@ static void flip_to_fb(igt_display_t *dpy, int pipe, fence = igt_cork_plug(&cork, dpy->drm_fd); t = igt_spin_new(dpy->drm_fd, - .engine = ring, .fence = fence, .dependency = fb->gem_handle, .flags = IGT_SPIN_FENCE_IN); @@ -131,7 +130,7 @@ static void flip_to_fb(igt_display_t *dpy, int pipe, igt_spin_free(dpy->drm_fd, t); } -static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset) +static void test_flip(igt_display_t *dpy, int pipe, bool modeset) { struct igt_fb fb[2]; int warmup[] = { 0, 1, 0, -1 }; @@ -169,10 +168,10 @@ static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset) igt_info("Using timeout of %dms\n", timeout); /* Make the frontbuffer busy and try to flip to itself */ - flip_to_fb(dpy, pipe, output, &fb[0], ring, timeout, "fb[0]", modeset); + flip_to_fb(dpy, pipe, output, &fb[0], timeout, "fb[0]", modeset); /* Repeat for flip to second buffer */ - flip_to_fb(dpy, pipe, output, &fb[1], ring, timeout, "fb[1]", modeset); + flip_to_fb(dpy, pipe, output, &fb[1], timeout, "fb[1]", modeset); do_cleanup_display(dpy); igt_remove_fb(dpy->drm_fd, &fb[1]); @@ -180,10 +179,9 @@ static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset) } static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary, - struct igt_fb *busy_fb, unsigned ring) + struct igt_fb *busy_fb) { igt_spin_t *t = igt_spin_new(dpy->drm_fd, - .engine = ring, .dependency = busy_fb->gem_handle, .flags = IGT_SPIN_NO_PREEMPTION); struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN }; @@ -216,7 +214,7 @@ static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary, igt_spin_end(t); } -static void test_hang(igt_display_t *dpy, unsigned ring, +static void test_hang(igt_display_t *dpy, enum pipe pipe, bool modeset, bool hang_newfb) { struct igt_fb fb[2]; @@ -237,12 +235,12 @@ static void test_hang(igt_display_t *dpy, unsigned ring, /* Test modeset disable with hang */ igt_output_set_pipe(output, PIPE_NONE); igt_plane_set_fb(primary, &fb[1]); - test_atomic_commit_hang(dpy, primary, &fb[hang_newfb], ring); + test_atomic_commit_hang(dpy, primary, &fb[hang_newfb]); /* Test modeset enable with hang */ igt_plane_set_fb(primary, &fb[0]); igt_output_set_pipe(output, pipe); - test_atomic_commit_hang(dpy, primary, &fb[!hang_newfb], ring); + test_atomic_commit_hang(dpy, primary, &fb[!hang_newfb]); } else { /* * Test what happens with a single hanging pageflip. @@ -250,7 +248,7 @@ static void test_hang(igt_display_t *dpy, unsigned ring, * timeouts taking care of it. */ igt_plane_set_fb(primary, &fb[1]); - test_atomic_commit_hang(dpy, primary, &fb[hang_newfb], ring); + test_atomic_commit_hang(dpy, primary, &fb[hang_newfb]); } do_cleanup_display(dpy); @@ -258,8 +256,7 @@ static void test_hang(igt_display_t *dpy, unsigned ring, igt_remove_fb(dpy->drm_fd, &fb[0]); } -static void test_pageflip_modeset_hang(igt_display_t *dpy, - unsigned ring, enum pipe pipe) +static void test_pageflip_modeset_hang(igt_display_t *dpy, enum pipe pipe) { struct igt_fb fb; struct drm_event_vblank ev; @@ -273,7 +270,6 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy, igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); t = igt_spin_new(dpy->drm_fd, - .engine = ring, .dependency = fb.gem_handle, .flags = IGT_SPIN_NO_PREEMPTION); @@ -294,8 +290,6 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy, igt_main { igt_display_t display = { .drm_fd = -1, .n_pipes = IGT_MAX_PIPES }; - /* we only test on render */ - const struct intel_execution_engine *e = &intel_execution_engines[1]; enum pipe n; igt_fixture { @@ -303,6 +297,7 @@ igt_main igt_require_gem(fd); gem_require_mmap_wc(fd); + igt_require(gem_has_ring(fd, I915_EXEC_DEFAULT)); kmstest_set_vt_graphics_mode(); igt_display_require(&display, fd); @@ -314,13 +309,11 @@ igt_main enum pipe pipe; igt_output_t *output; - igt_require(gem_has_ring(display.drm_fd, eb_ring(e))); - for_each_pipe_with_valid_output(&display, pipe, output) { igt_dynamic("flip") - test_flip(&display, eb_ring(e), pipe, false); + test_flip(&display, pipe, false); igt_dynamic("modeset") - test_flip(&display, eb_ring(e), pipe, true); + test_flip(&display, pipe, true); break; } } @@ -334,65 +327,56 @@ igt_main igt_display_require_output_on_pipe(&display, n); } - igt_subtest_f("basic-flip-pipe-%s", - kmstest_pipe_name(n)) { - igt_require(gem_has_ring(display.drm_fd, eb_ring(e))); - - test_flip(&display, eb_ring(e), n, false); + igt_subtest_f("basic-flip-pipe-%s", kmstest_pipe_name(n)) { + test_flip(&display, n, false); } - igt_subtest_f("basic-modeset-pipe-%s", - kmstest_pipe_name(n)) { - igt_require(gem_has_ring(display.drm_fd, eb_ring(e))); + igt_subtest_f("basic-modeset-pipe-%s", kmstest_pipe_name(n)) { - test_flip(&display, eb_ring(e), n, true); + test_flip(&display, n, true); } igt_fixture { - igt_require(gem_has_ring(display.drm_fd, eb_ring(e))); - hang = igt_allow_hang(display.drm_fd, 0, 0); } - igt_subtest_f("extended-pageflip-modeset-hang-oldfb-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) { - igt_require(gem_has_ring(display.drm_fd, eb_ring(e))); - - test_pageflip_modeset_hang(&display, eb_ring(e), n); + igt_subtest_f("extended-pageflip-modeset-hang-oldfb-pipe-%s", + kmstest_pipe_name(n)) { + test_pageflip_modeset_hang(&display, n); } igt_fixture igt_require(display.is_atomic); - igt_subtest_f("extended-pageflip-hang-oldfb-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) - test_hang(&display, eb_ring(e), n, false, false); + igt_subtest_f("extended-pageflip-hang-oldfb-pipe-%s", + kmstest_pipe_name(n)) + test_hang(&display, n, false, false); - igt_subtest_f("extended-pageflip-hang-newfb-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) - test_hang(&display, eb_ring(e), n, false, true); + igt_subtest_f("extended-pageflip-hang-newfb-pipe-%s", + kmstest_pipe_name(n)) + test_hang(&display, n, false, true); - igt_subtest_f("extended-modeset-hang-oldfb-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) - test_hang(&display, eb_ring(e), n, true, false); + igt_subtest_f("extended-modeset-hang-oldfb-pipe-%s", + kmstest_pipe_name(n)) + test_hang(&display, n, true, false); - igt_subtest_f("extended-modeset-hang-newfb-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) - test_hang(&display, eb_ring(e), n, true, true); + igt_subtest_f("extended-modeset-hang-newfb-pipe-%s", + kmstest_pipe_name(n)) + test_hang(&display, n, true, true); - igt_subtest_f("extended-modeset-hang-oldfb-with-reset-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) { + igt_subtest_f("extended-modeset-hang-oldfb-with-reset-pipe-%s", + kmstest_pipe_name(n)) { igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 1); - test_hang(&display, eb_ring(e), n, true, false); + test_hang(&display, n, true, false); igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 0); } - igt_subtest_f("extended-modeset-hang-newfb-with-reset-%s-pipe-%s", - e->name, kmstest_pipe_name(n)) { + igt_subtest_f("extended-modeset-hang-newfb-with-reset-pipe-%s", + kmstest_pipe_name(n)) { igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 1); - test_hang(&display, eb_ring(e), n, true, true); + test_hang(&display, n, true, true); igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 0); } |