[PATCH i-g-t 33/81] tests/i915/gem_ringfill: Convert to intel_ctx_t
Jason Ekstrand
jason at jlekstrand.net
Sat Apr 17 03:20:46 UTC 2021
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
tests/i915/gem_ringfill.c | 48 +++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/tests/i915/gem_ringfill.c b/tests/i915/gem_ringfill.c
index 78903707..4fbc7b5d 100644
--- a/tests/i915/gem_ringfill.c
+++ b/tests/i915/gem_ringfill.c
@@ -93,7 +93,7 @@ static void fill_ring(int fd,
}
}
-static void setup_execbuf(int fd,
+static void setup_execbuf(int fd, const intel_ctx_t *ctx,
struct drm_i915_gem_execbuffer2 *execbuf,
struct drm_i915_gem_exec_object2 *obj,
struct drm_i915_gem_relocation_entry *reloc,
@@ -114,6 +114,8 @@ static void setup_execbuf(int fd,
if (gen > 3 && gen < 6)
execbuf->flags |= I915_EXEC_SECURE;
+ execbuf->rsvd1 = ctx->id;
+
obj[0].handle = gem_create(fd, 4096);
gem_write(fd, obj[0].handle, 0, &bbe, sizeof(bbe));
execbuf->buffer_count = 1;
@@ -167,7 +169,8 @@ static void setup_execbuf(int fd,
check_bo(fd, obj[0].handle);
}
-static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
+static void run_test(int fd, const intel_ctx_t *ctx, unsigned ring,
+ unsigned flags, unsigned timeout)
{
struct drm_i915_gem_exec_object2 obj[2];
struct drm_i915_gem_relocation_entry reloc[1024];
@@ -175,15 +178,15 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
igt_hang_t hang;
if (flags & (SUSPEND | HIBERNATE)) {
- run_test(fd, ring, 0, 0);
+ run_test(fd, ctx, ring, 0, 0);
gem_quiescent_gpu(fd);
}
- setup_execbuf(fd, &execbuf, obj, reloc, ring);
+ setup_execbuf(fd, ctx, &execbuf, obj, reloc, ring);
memset(&hang, 0, sizeof(hang));
if (flags & HANG)
- hang = igt_hang_ring(fd, ring & ~(3<<13));
+ hang = igt_hang_ctx(fd, ctx->id, ring & ~(3<<13), 0);
if (flags & (CHILD | FORKED | BOMB)) {
int nchild;
@@ -197,16 +200,19 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
igt_debug("Forking %d children\n", nchild);
igt_fork(child, nchild) {
+ const intel_ctx_t *child_ctx = NULL;
if (flags & NEWFD) {
int this;
this = gem_reopen_driver(fd);
- gem_context_copy_engines(fd, 0, this, 0);
+ child_ctx = intel_ctx_create(fd, &ctx->cfg);
fd = this;
- setup_execbuf(fd, &execbuf, obj, reloc, ring);
+ setup_execbuf(fd, child_ctx, &execbuf, obj, reloc, ring);
}
fill_ring(fd, &execbuf, flags, timeout);
+ if (child_ctx)
+ intel_ctx_destroy(fd, child_ctx);
}
if (flags & SUSPEND)
@@ -234,7 +240,7 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
if (flags & (SUSPEND | HIBERNATE)) {
gem_quiescent_gpu(fd);
- run_test(fd, ring, 0, 0);
+ run_test(fd, ctx, ring, 0, 0);
}
}
@@ -285,6 +291,7 @@ igt_main
{ NULL }
}, *m;
bool master = false;
+ const intel_ctx_t *ctx;
int fd = -1;
igt_fixture {
@@ -304,22 +311,20 @@ igt_main
ring_size = gem_measure_ring_inflight(fd, ALL_ENGINES, 0);
igt_info("Ring size: %d batches\n", ring_size);
igt_require(ring_size);
+
+ ctx = intel_ctx_create_all_physical(fd);
}
/* Legacy path for selecting "rings". */
for (m = modes; m->suffix; m++) {
igt_subtest_with_dynamic_f("legacy-%s", m->suffix) {
- const struct intel_execution_ring *e;
-
igt_skip_on(m->flags & NEWFD && master);
- for (e = intel_execution_rings; e->name; e++) {
- if (!gem_has_ring(fd, eb_ring(e)))
- continue;
-
+ for_each_ring(e, fd) {
igt_dynamic_f("%s", e->name) {
igt_require(gem_can_store_dword(fd, eb_ring(e)));
- run_test(fd, eb_ring(e),
+ run_test(fd, intel_ctx_0(fd),
+ eb_ring(e),
m->flags,
m->timeout);
gem_quiescent_gpu(fd);
@@ -334,12 +339,13 @@ igt_main
const struct intel_execution_engine2 *e;
igt_skip_on(m->flags & NEWFD && master);
- __for_each_physical_engine(fd, e) {
+ for_each_ctx_engine(fd, ctx, e) {
if (!gem_class_can_store_dword(fd, e->class))
continue;
igt_dynamic_f("%s", e->name) {
- run_test(fd, e->flags,
+ run_test(fd, ctx,
+ e->flags,
m->flags,
m->timeout);
gem_quiescent_gpu(fd);
@@ -351,17 +357,19 @@ igt_main
igt_subtest("basic-all") {
const struct intel_execution_engine2 *e;
- __for_each_physical_engine(fd, e) {
+ for_each_ctx_engine(fd, ctx, e) {
if (!gem_class_can_store_dword(fd, e->class))
continue;
igt_fork(child, 1)
- run_test(fd, e->flags, 0, 1);
+ run_test(fd, ctx, e->flags, 0, 1);
}
igt_waitchildren();
}
- igt_fixture
+ igt_fixture {
+ intel_ctx_destroy(fd, ctx);
close(fd);
+ }
}
--
2.31.1
More information about the Intel-gfx-trybot
mailing list