[igt-dev] [PATCH i-g-t 22/77] tests/i915/gem_exec_suspend: Convert to intel_ctx_t (v2)
Jason Ekstrand
jason at jlekstrand.net
Mon Jun 14 16:36:37 UTC 2021
v2 (Zbigniew Kempczyński):
- intel_ctx_destroy() the context
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
tests/i915/gem_exec_suspend.c | 53 ++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index d13c443e2..0ef26ce11 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -51,7 +51,8 @@
#define CACHED (1<<8)
#define HANG (2<<8)
-static void run_test(int fd, unsigned engine, unsigned flags);
+static void run_test(int fd, const intel_ctx_t *ctx,
+ unsigned engine, unsigned flags);
static void check_bo(int fd, uint32_t handle)
{
@@ -66,12 +67,13 @@ static void check_bo(int fd, uint32_t handle)
munmap(map, 4096);
}
-static void test_all(int fd, unsigned flags)
+static void test_all(int fd, const intel_ctx_t *ctx, unsigned flags)
{
- run_test(fd, ALL_ENGINES, flags & ~0xff);
+ run_test(fd, ctx, ALL_ENGINES, flags & ~0xff);
}
-static void run_test(int fd, unsigned engine, unsigned flags)
+static void run_test(int fd, const intel_ctx_t *ctx,
+ unsigned engine, unsigned flags)
{
const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -86,7 +88,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
if (engine == ALL_ENGINES) {
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))
engines[nengine++] = e->flags;
}
@@ -97,7 +99,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
/* Before suspending, check normal operation */
if (mode(flags) != NOSLEEP)
- test_all(fd, flags);
+ test_all(fd, ctx, flags);
gem_quiescent_gpu(fd);
@@ -107,6 +109,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
execbuf.flags = 1 << 11;
if (gen < 6)
execbuf.flags |= I915_EXEC_SECURE;
+ execbuf.rsvd1 = ctx->id;
memset(obj, 0, sizeof(obj));
obj[0].handle = gem_create(fd, 4096);
@@ -203,7 +206,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
/* After resume, make sure it still works */
if (mode(flags) != NOSLEEP)
- test_all(fd, flags);
+ test_all(fd, ctx, flags);
}
struct battery_sample {
@@ -230,7 +233,8 @@ static double d_time(const struct battery_sample *after,
(after->tv.tv_nsec - before->tv.tv_nsec) * 1e-9); /* s */
}
-static void power_test(int i915, unsigned engine, unsigned flags)
+static void power_test(int i915, const intel_ctx_t *ctx,
+ unsigned engine, unsigned flags)
{
struct battery_sample before, after;
char *status;
@@ -250,7 +254,7 @@ static void power_test(int i915, unsigned engine, unsigned flags)
igt_set_autoresume_delay(5 * 60); /* 5 minutes; longer == more stable */
igt_assert(get_power(dir, &before));
- run_test(i915, engine, flags);
+ run_test(i915, ctx, engine, flags);
igt_assert(get_power(dir, &after));
igt_set_autoresume_delay(0);
@@ -274,45 +278,47 @@ igt_main
}, *m;
const struct intel_execution_engine2 *e;
igt_hang_t hang;
+ const intel_ctx_t *ctx;
int fd;
igt_fixture {
fd = drm_open_driver_master(DRIVER_INTEL);
igt_require_gem(fd);
igt_require(gem_can_store_dword(fd, 0));
+ ctx = intel_ctx_create_all_physical(fd);
igt_fork_hang_detector(fd);
}
igt_subtest("basic")
- run_test(fd, ALL_ENGINES, NOSLEEP);
+ run_test(fd, ctx, ALL_ENGINES, NOSLEEP);
igt_subtest("basic-S0")
- run_test(fd, ALL_ENGINES, IDLE);
+ run_test(fd, ctx, ALL_ENGINES, IDLE);
igt_subtest("basic-S3-devices")
- run_test(fd, ALL_ENGINES, SUSPEND_DEVICES);
+ run_test(fd, ctx, ALL_ENGINES, SUSPEND_DEVICES);
igt_subtest("basic-S3")
- run_test(fd, ALL_ENGINES, SUSPEND);
+ run_test(fd, ctx, ALL_ENGINES, SUSPEND);
igt_subtest("basic-S4-devices")
- run_test(fd, ALL_ENGINES, HIBERNATE_DEVICES);
+ run_test(fd, ctx, ALL_ENGINES, HIBERNATE_DEVICES);
igt_subtest("basic-S4")
- run_test(fd, ALL_ENGINES, HIBERNATE);
+ run_test(fd, ctx, ALL_ENGINES, HIBERNATE);
for (m = modes; m->suffix; m++) {
igt_subtest_with_dynamic_f("uncached%s", m->suffix) {
- __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, m->mode | UNCACHED);
+ run_test(fd, ctx, e->flags, m->mode | UNCACHED);
}
}
igt_subtest_with_dynamic_f("cached%s", m->suffix) {
- __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, m->mode | CACHED);
+ run_test(fd, ctx, e->flags, m->mode | CACHED);
}
}
}
@@ -323,17 +329,18 @@ igt_main
}
igt_subtest("hang-S3")
- run_test(fd, 0, SUSPEND | HANG);
+ run_test(fd, intel_ctx_0(fd), 0, SUSPEND | HANG);
igt_subtest("hang-S4")
- run_test(fd, 0, HIBERNATE | HANG);
+ run_test(fd, intel_ctx_0(fd), 0, HIBERNATE | HANG);
igt_subtest("power-S0")
- power_test(fd, 0, IDLE);
+ power_test(fd, intel_ctx_0(fd), 0, IDLE);
igt_subtest("power-S3")
- power_test(fd, 0, SUSPEND);
+ power_test(fd, intel_ctx_0(fd), 0, SUSPEND);
igt_fixture {
igt_disallow_hang(fd, hang);
+ intel_ctx_destroy(fd, ctx);
close(fd);
}
}
--
2.31.1
More information about the igt-dev
mailing list