Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd008e5b authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter
Browse files

drm: Implement O_NONBLOCK support on /dev/dri/cardN



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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Testcase: igt/kms_flip/nonblocing_read
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 1bcecfac
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -515,10 +515,12 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
	size_t total;
	ssize_t 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);