diff options
author | Eric Anholt <eric@anholt.net> | 2015-05-29 15:48:43 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2015-06-04 14:15:38 -0700 |
commit | 09a4b5d74664220c0f5077590c9e6ab7d288cdff (patch) | |
tree | 8172b485a1113b57d8ee531f00d1facf9ab73f37 | |
parent | fa1ad658e659f0a0f1f056d0dd131aad5d0167c6 (diff) | |
download | linux-09a4b5d74664220c0f5077590c9e6ab7d288cdff.tar.gz |
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 <eric@anholt.net>
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_gem.c | 17 |
1 files 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; |