summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMika Kuoppala <mika.kuoppala@linux.intel.com>2019-04-23 17:15:58 +0300
committerMika Kuoppala <mika.kuoppala@linux.intel.com>2019-04-24 10:55:43 +0300
commit5e7519121de3c0e97ec27d33d6164278e86e75c5 (patch)
treefd1296da4b1d4db235be3f92958e408245769ce5 /lib
parent504367d33b787de2ba8e007a5b620cfd6f0b3074 (diff)
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 <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_dummyload.c17
-rw-r--r--lib/igt_dummyload.h2
2 files changed, 19 insertions, 0 deletions
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;
}
@@ -367,6 +369,21 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
}
/**
+ * 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);