dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
@ 2014-10-07 13:13 Chris Wilson
  2014-10-07 19:33 ` Jesse Barnes
  2014-10-08  9:16 ` Daniel Vetter
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2014-10-07 13:13 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel

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
---
 drivers/gpu/drm/drm_fops.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index ed7bc68f7e87..91e1105f2800 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -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);
 
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
  2014-10-07 13:13 [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN Chris Wilson
@ 2014-10-07 19:33 ` Jesse Barnes
  2014-10-08  9:16 ` Daniel Vetter
  1 sibling, 0 replies; 5+ messages in thread
From: Jesse Barnes @ 2014-10-07 19:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, dri-devel

On Tue,  7 Oct 2014 14:13:51 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> 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
> ---
>  drivers/gpu/drm/drm_fops.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index ed7bc68f7e87..91e1105f2800 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -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);

I'd prefer "total" to be spelled out after the ? (is this just a GNU
thing or does recent C implicitly use the first operand too?), but
that's no biggie.  Looks fine.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
  2014-10-07 13:13 [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN Chris Wilson
  2014-10-07 19:33 ` Jesse Barnes
@ 2014-10-08  9:16 ` Daniel Vetter
  2014-10-08  9:45   ` Chris Wilson
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2014-10-08  9:16 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, dri-devel

On Tue, Oct 7, 2014 at 3:13 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> 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

Testcase for nonblocking behaviour in kms_flip?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
  2014-10-08  9:16 ` Daniel Vetter
@ 2014-10-08  9:45   ` Chris Wilson
  2014-10-08 13:09     ` Daniel Vetter
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2014-10-08  9:45 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, dri-devel

On Wed, Oct 08, 2014 at 11:16:38AM +0200, Daniel Vetter wrote:
> On Tue, Oct 7, 2014 at 3:13 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > 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
> 
> Testcase for nonblocking behaviour in kms_flip?

To the further dismay of anyone running kms_flip today,
Testcase: igt/kms_flip/nonblocing_read
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
  2014-10-08  9:45   ` Chris Wilson
@ 2014-10-08 13:09     ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2014-10-08 13:09 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, intel-gfx, dri-devel

On Wed, Oct 08, 2014 at 10:45:48AM +0100, Chris Wilson wrote:
> On Wed, Oct 08, 2014 at 11:16:38AM +0200, Daniel Vetter wrote:
> > On Tue, Oct 7, 2014 at 3:13 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > > 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
> >
> > Testcase for nonblocking behaviour in kms_flip?
>
> To the further dismay of anyone running kms_flip today,
> Testcase: igt/kms_flip/nonblocing_read

Not if they upgrade to -nightly ;-) Thanks for the patch, merged to
topic/core-stuff.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-08 13:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-07 13:13 [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN Chris Wilson
2014-10-07 19:33 ` Jesse Barnes
2014-10-08  9:16 ` Daniel Vetter
2014-10-08  9:45   ` Chris Wilson
2014-10-08 13:09     ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox