]> Pileus Git - ~andy/linux/commitdiff
drm/i915: Inifite timeout for wait ioctl
authorBen Widawsky <ben@bwidawsk.net>
Tue, 5 Jun 2012 22:24:24 +0000 (15:24 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Jun 2012 10:25:46 +0000 (12:25 +0200)
Change the ns_timeout parameter of the wait ioctl to a signed value.
Doing this allows the kernel to provide an infinite wait when a timeout
of less than 0 is provided. This mimics select/poll.

Initially the parameter was meant to match up with the GL spec 1:1, but
after being made aware of how much 2^64 - 1 nanoseconds actually is, I
do not think anyone will ever notice the loss of 1 bit.

The infinite timeout on waiting is similar to the existing i915
userspace interface with the exception that struct_mutex is dropped
while doing the wait in this ioctl.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem.c
include/drm/i915_drm.h

index af67803e635fb8d64b7feb83a0f05cfc96329c76..deaa0d4bb456e582c01a205cc9a76f5542f7a3cb 100644 (file)
@@ -2082,11 +2082,14 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
        struct drm_i915_gem_wait *args = data;
        struct drm_i915_gem_object *obj;
        struct intel_ring_buffer *ring = NULL;
-       struct timespec timeout;
+       struct timespec timeout_stack, *timeout = NULL;
        u32 seqno = 0;
        int ret = 0;
 
-       timeout = ns_to_timespec(args->timeout_ns);
+       if (args->timeout_ns >= 0) {
+               timeout_stack = ns_to_timespec(args->timeout_ns);
+               timeout = &timeout_stack;
+       }
 
        ret = i915_mutex_lock_interruptible(dev);
        if (ret)
@@ -2122,9 +2125,11 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
        drm_gem_object_unreference(&obj->base);
        mutex_unlock(&dev->struct_mutex);
 
-       ret = __wait_seqno(ring, seqno, true, &timeout);
-       WARN_ON(!timespec_valid(&timeout));
-       args->timeout_ns = timespec_to_ns(&timeout);
+       ret = __wait_seqno(ring, seqno, true, timeout);
+       if (timeout) {
+               WARN_ON(!timespec_valid(timeout));
+               args->timeout_ns = timespec_to_ns(timeout);
+       }
        return ret;
 
 out:
index bab174334da574fd5f481cb1612e782061802b6e..aae346e7f6359e8323f6dfe270673a3336797346 100644 (file)
@@ -893,7 +893,7 @@ struct drm_i915_gem_wait {
        __u32 bo_handle;
        __u32 flags;
        /** Number of nanoseconds to wait, Returns time remaining. */
-       __u64 timeout_ns;
+       __s64 timeout_ns;
 };
 
 #endif                         /* _I915_DRM_H_ */