From 09a4b5d74664220c0f5077590c9e6ab7d288cdff Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 29 May 2015 15:48:43 -0700 Subject: drm/vc4: Make userspace's infinite waits actually infinite. We use ~0 (584 years) to indicate "wait forever", so don't actually set up a timer for 584 years from now. Saves about 1% CPU. Signed-off-by: Eric Anholt --- drivers/gpu/drm/vc4/vc4_gem.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 2aad41118cec..7e8070668eb4 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -142,15 +142,18 @@ vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno, uint64_t timeout_ns) break; } - if (time_after_eq(jiffies, timeout_expire)) { - ret = -ETIME; - break; - } - if (vc4->finished_seqno >= seqno) break; - schedule_timeout(timeout_expire - jiffies); + if (timeout_ns != ~0ull) { + if (time_after_eq(jiffies, timeout_expire)) { + ret = -ETIME; + break; + } + schedule_timeout(timeout_expire - jiffies); + } else { + schedule(); + } } finish_wait(&vc4->job_wait_queue, &wait); @@ -513,7 +516,7 @@ vc4_wait_for_seqno_ioctl_helper(struct drm_device *dev, unsigned long start = jiffies; int ret = vc4_wait_for_seqno(dev, seqno, *timeout_ns); - if (ret == -EINTR || ret == -ERESTARTSYS) { + if ((ret == -EINTR || ret == -ERESTARTSYS) && *timeout_ns != ~0ull) { uint64_t delta = jiffies_to_nsecs(jiffies - start); if (*timeout_ns >= delta) *timeout_ns -= delta; -- cgit v1.2.1