summaryrefslogtreecommitdiff
path: root/lib/igt_dummyload.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-08-09 13:10:52 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-12-13 19:12:03 +0000
commitbab762ddef24057a6b07568db3734791b6e6b930 (patch)
tree5303d99b5fddf1fb4a2b0ecd97b17980efcf672d /lib/igt_dummyload.c
parent4112f30aedbb252bf8cdd27dbba485c0458faca7 (diff)
lib/dummyload: Wrap global list inside its own mutex
Give the list a mutex, for we try to iterate over it from many a random context. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'lib/igt_dummyload.c')
-rw-r--r--lib/igt_dummyload.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index bb2be557..d19b4e5e 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -57,6 +57,7 @@
static const int BATCH_SIZE = 4096;
static IGT_LIST(spin_list);
+static pthread_mutex_t list_lock = PTHREAD_MUTEX_INITIALIZER;
static void
fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
@@ -182,7 +183,9 @@ __igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)
emit_recursive_batch(spin, fd, ctx, engine, dep);
igt_assert(gem_bo_busy(fd, spin->handle));
+ pthread_mutex_lock(&list_lock);
igt_list_add(&spin->link, &spin_list);
+ pthread_mutex_unlock(&list_lock);
return spin;
}
@@ -281,7 +284,9 @@ void igt_spin_batch_free(int fd, igt_spin_t *spin)
if (!spin)
return;
+ pthread_mutex_lock(&list_lock);
igt_list_del(&spin->link);
+ pthread_mutex_unlock(&list_lock);
if (spin->timer)
timer_delete(spin->timer);
@@ -297,6 +302,8 @@ void igt_terminate_spin_batches(void)
{
struct igt_spin *iter;
+ pthread_mutex_lock(&list_lock);
igt_list_for_each(iter, &spin_list, link)
igt_spin_batch_end(iter);
+ pthread_mutex_unlock(&list_lock);
}