From 5e7519121de3c0e97ec27d33d6164278e86e75c5 Mon Sep 17 00:00:00 2001 From: Mika Kuoppala Date: Tue, 23 Apr 2019 17:15:58 +0300 Subject: lib/igt_dummyload: Introduce igt_spin_reset Libify resetting a spin for reuse. v2: use also in perf_pmu v3: s/cmd_spin/cmd_precondition v4: remove early return for !spin (Chris) Cc: Chris Wilson Cc: Tvrtko Ursulin Signed-off-by: Mika Kuoppala Reviewed-by: Chris Wilson --- lib/igt_dummyload.c | 17 +++++++++++++++++ lib/igt_dummyload.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index 1d57a53c..65957ed1 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -260,6 +260,8 @@ emit_recursive_batch(igt_spin_t *spin, obj[SCRATCH].flags = EXEC_OBJECT_PINNED; obj[BATCH].flags = EXEC_OBJECT_PINNED; + spin->cmd_precondition = *spin->batch; + return fence_fd; } @@ -366,6 +368,21 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns) spin->timer = timer; } +/** + * igt_spin_reset: + * @spin: spin state from igt_spin_new() + * + * Reset the state of spin, allowing its reuse. + */ +void igt_spin_reset(igt_spin_t *spin) +{ + if (igt_spin_has_poll(spin)) + spin->poll[SPIN_POLL_START_IDX] = 0; + + *spin->batch = spin->cmd_precondition; + __sync_synchronize(); +} + /** * igt_spin_end: * @spin: spin state from igt_spin_new() diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h index d6482089..34537f27 100644 --- a/lib/igt_dummyload.h +++ b/lib/igt_dummyload.h @@ -37,6 +37,7 @@ typedef struct igt_spin { timer_t timer; struct igt_list link; uint32_t *batch; + uint32_t cmd_precondition; int out_fence; struct drm_i915_gem_exec_object2 obj[2]; struct drm_i915_gem_execbuffer2 execbuf; @@ -68,6 +69,7 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts); igt_spin_factory(fd, &((struct igt_spin_factory){__VA_ARGS__})) void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns); +void igt_spin_reset(igt_spin_t *spin); void igt_spin_end(igt_spin_t *spin); void igt_spin_free(int fd, igt_spin_t *spin); -- cgit v1.2.3