diff mbox series

[i-g-t,1/2] lib: Immediately cancel a spinner for an expired timeout

Message ID 20210105212606.3399854-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t,1/2] lib: Immediately cancel a spinner for an expired timeout | expand

Commit Message

Chris Wilson Jan. 5, 2021, 9:26 p.m. UTC
If the relative timeout to igt_spin_set_timeout() is in the past,
immediately end the spinner.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2903
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_dummyload.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 6ecaf8506..34ad92216 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -485,10 +485,14 @@  void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
 	pthread_attr_t attr;
 	int timerfd;
 
-	igt_assert(ns > 0);
 	if (!spin)
 		return;
 
+	if (ns <= 0) {
+		igt_spin_end(spin);
+		return;
+	}
+
 	igt_assert(spin->timerfd == -1);
 	timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
 	igt_assert(timerfd >= 0);