]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm: Implement O_NONBLOCK support on /dev/dri/cardN
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 7 Oct 2014 13:13:51 +0000 (14:13 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 8 Oct 2014 13:07:07 +0000 (15:07 +0200)
The implmentation is simple in the extreme: we only want to wait for
events if the device was opened in blocking mode, otherwise we grab what
is available and report an error if there was none.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Testcase: igt/kms_flip/nonblocing_read
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_fops.c

index ed7bc68f7e8700041894c7f35685af449c4deb2e..91e1105f28006eae6a4e1e1a654a20c1315cff80 100644 (file)
@@ -515,10 +515,12 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
        size_t total;
        ssize_t ret;
 
-       ret = wait_event_interruptible(file_priv->event_wait,
-                                      !list_empty(&file_priv->event_list));
-       if (ret < 0)
-               return ret;
+       if ((filp->f_flags & O_NONBLOCK) == 0) {
+               ret = wait_event_interruptible(file_priv->event_wait,
+                                              !list_empty(&file_priv->event_list));
+               if (ret < 0)
+                       return ret;
+       }
 
        total = 0;
        while (drm_dequeue_event(file_priv, total, count, &e)) {
@@ -532,7 +534,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
                e->destroy(e);
        }
 
-       return total;
+       return total ?: -EAGAIN;
 }
 EXPORT_SYMBOL(drm_read);